List of usage examples for java.net URI create
public static URI create(String str)
From source file:com.exallium.gitissue.api.utils.HttpPatch.java
public HttpPatch(String uri) { setURI(URI.create(uri)); }
From source file:com.github.pfmiles.minvelocity.biztest.JavaSourceFile.java
private static URI genMemFileUri(String fileName, String pkg) { String pkgPath = ""; if (StringUtils.isNotBlank(pkg)) pkgPath = pkg.replaceAll("\\.", "/") + "/"; return URI.create("mem:///src/" + pkgPath + fileName); }
From source file:io.orchestrate.client.itest.BaseClientTest.java
@BeforeClass public static void setUpClass() { final String apiKey = System.getProperty("orchestrate.apiKey"); if (apiKey == null || apiKey.length() < 1) { throw new IllegalStateException("Cannot run integration tests, 'apiKey' is blank."); }// ww w. j a v a 2 s. com URI uri = URI.create(System.getProperty("orchestrate.host", OrchestrateClient.Builder.DEFAULT_HOST)); String host = uri.getScheme() + "://" + uri.getHost(); int port = uri.getPort(); if (port == -1) { if (uri.getScheme().equals("https")) { port = 443; } else { port = 80; } } boolean ssl = uri.getScheme().equals("https"); client = OrchestrateClient.builder(apiKey).host(host).port(port).useSSL(ssl).build(); }
From source file:com.tremolosecurity.proxy.http.EntityMethod.java
public EntityMethod(String method, String uri) { this.method = method; this.setURI(URI.create(uri)); }
From source file:com.betfair.cougar.marshalling.impl.databinding.xml.XMLUtils.java
public static Schema getSchema(JAXBContext context) { Result result = new ResultImplementation(); SchemaOutputResolver outputResolver = new SchemaOutputResolverImpl(result); File tempFile = null;/*from ww w . j a va2 s .c om*/ try { context.generateSchema(outputResolver); String schemaFile = result.getSystemId(); if (schemaFile != null) { tempFile = new File(URI.create(schemaFile)); String content = FileUtils.readFileToString(tempFile); // JAXB nicely generates a schema with element refs, unfortunately it also adds the nillable attribute to the // referencing element, which is invalid, it has to go on the target. this string manipulation is to move the // nillable attribute to the correct place, preserving it's value. Map<String, Boolean> referenceElementsWithNillable = new HashMap<>(); BufferedReader br = new BufferedReader(new StringReader(content)); String line; while ((line = br.readLine()) != null) { if (line.contains("<xs:element") && line.contains(" ref=\"") && line.contains(" nillable=\"")) { // we've got a reference element with nillable set int refStartIndex = line.indexOf(" ref=\"") + 6; int refEndIndex = line.indexOf("\"", refStartIndex); int nillableStartIndex = line.indexOf(" nillable=\"") + 11; int nillableEndIndex = line.indexOf("\"", nillableStartIndex); String ref = line.substring(refStartIndex, refEndIndex); if (ref.startsWith("tns:")) { ref = ref.substring(4); } String nillable = line.substring(nillableStartIndex, nillableEndIndex); referenceElementsWithNillable.put(ref, Boolean.valueOf(nillable)); } } // if we got some hits, then we need to rewrite this schema if (!referenceElementsWithNillable.isEmpty()) { StringBuilder sb = new StringBuilder(); br = new BufferedReader(new StringReader(content)); while ((line = br.readLine()) != null) { // these we need to remove the nillable section from if (line.contains("<xs:element") && line.contains(" ref=\"") && line.contains(" nillable=\"")) { int nillableStartIndex = line.indexOf(" nillable=\""); int nillableEndIndex = line.indexOf("\"", nillableStartIndex + 11); line = line.substring(0, nillableStartIndex) + line.substring(nillableEndIndex + 1); } else if (line.contains("<xs:element name=\"")) { for (String key : referenceElementsWithNillable.keySet()) { // this we need to add the nillable back to String elementTagWithName = "<xs:element name=\"" + key + "\""; if (line.contains(elementTagWithName)) { int endOfElementName = line.indexOf(elementTagWithName) + elementTagWithName.length(); line = line.substring(0, endOfElementName) + " nillable=\"" + referenceElementsWithNillable.get(key) + "\"" + line.substring(endOfElementName); break; } } } sb.append(line).append("\n"); } content = sb.toString(); } SchemaFactory sf = SchemaFactory.newInstance(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI); return sf.newSchema(new StreamSource(new StringReader(content))); } } catch (IOException e) { throw new PanicInTheCougar(e); } catch (SAXException e) { throw new PanicInTheCougar(e); } finally { if (tempFile != null) tempFile.delete(); } return null; }
From source file:com.tremolosecurity.proxy.http.UriMethod.java
public UriMethod(String method, String uri) { this.method = method; this.uri = uri; this.setURI(URI.create(uri)); }
From source file:com.fatwire.dta.sscrawler.util.UriUtil.java
public static Map<String, String> extractParams(final String uri) { final String qs = URI.create(uri).getRawQuery(); final Map<String, String> map = new TreeMap<String, String>(); if (qs != null) { for (final String p : qs.split("&")) { final String[] nvp = p.split("="); try { final String key = URLDecoder.decode(nvp[0], UriUtil.UTF8); if (nvp.length > 0) { map.put(key, URLDecoder.decode(nvp[1], UriUtil.UTF8)); } else { map.put(key, null);//from ww w . j a va 2 s . c om } } catch (final UnsupportedEncodingException e) { UriUtil.log.error(e, e); } } } return map; }
From source file:org.openlmis.fulfillment.service.request.RequestHelper.java
/** * Creates a {@link URI} from the given string representation and with the given parameters. *//*from w w w. jav a 2s .com*/ public static URI createUri(String url, RequestParameters parameters) { UriComponentsBuilder builder = UriComponentsBuilder.newInstance().uri(URI.create(url)); RequestParameters.init().setAll(parameters).forEach(e -> e.getValue().forEach(one -> { try { builder.queryParam(e.getKey(), UriUtils.encodeQueryParam(String.valueOf(one), StandardCharsets.UTF_8.name())); } catch (UnsupportedEncodingException ex) { throw new EncodingException(ex); } })); return builder.build(true).toUri(); }
From source file:com.github.dozermapper.spring.functional_tests.SchemaLocationTest.java
@Test public void ensureHttpsSchemaAccessible() throws IOException { URI uri = URI.create("https://dozermapper.github.io/schema/dozer-spring.xsd"); String value = IOUtils.toString(uri, "utf-8"); Assert.assertTrue(value.contains("http://dozermapper.github.io/schema/dozer-spring")); }
From source file:com.github.tomakehurst.wiremock.common.SafeNames.java
public static String makeSafeFileName(StubMapping mapping, String extension) { String suffix = "-" + mapping.getId() + "." + extension; if (isNotEmpty(mapping.getName())) { return makeSafeName(mapping.getName()) + suffix; }//from w ww.j a v a 2 s .c o m UrlPattern urlMatcher = mapping.getRequest().getUrlMatcher(); if (urlMatcher.getPattern() instanceof AnythingPattern) { return suffix.substring(1); } String expectedUrl = urlMatcher.getExpected(); URI uri = URI.create(sanitise(expectedUrl)); return makeSafeNameFromUrl(uri.getPath()) + suffix; }