Refine search
@Override public URI apply( String value ) { try { String normalizedUri = new URI( value ).normalize().getPath(); if ( normalizedUri.endsWith( "/" ) ) { // Force the string end without "/" normalizedUri = normalizedUri.substring( 0, normalizedUri.length() - 1 ); } return new URI( normalizedUri ); } catch ( URISyntaxException e ) { throw new IllegalArgumentException( "not a valid URI" ); } }
@Test public void shouldLoadThirdPartyJaxRsClasses() throws Exception { server = CommunityServerBuilder.serverOnRandomPorts() .withThirdPartyJaxRsPackage( "org.dummy.web.service", DummyThirdPartyWebService.DUMMY_WEB_SERVICE_MOUNT_POINT ) .usingDataDir( folder.directory( name.getMethodName() ).getAbsolutePath() ) .build(); server.start(); URI thirdPartyServiceUri = new URI( server.baseUri() .toString() + DummyThirdPartyWebService.DUMMY_WEB_SERVICE_MOUNT_POINT ).normalize(); String response = CLIENT.resource( thirdPartyServiceUri.toString() ) .get( String.class ); assertEquals( "hello", response ); // Assert that extensions gets initialized int nodesCreated = createSimpleDatabase( server.getDatabase().getGraph() ); thirdPartyServiceUri = new URI( server.baseUri() .toString() + DummyThirdPartyWebService.DUMMY_WEB_SERVICE_MOUNT_POINT + "/inject-test" ).normalize(); response = CLIENT.resource( thirdPartyServiceUri.toString() ) .get( String.class ); assertEquals( String.valueOf( nodesCreated ), response ); }
/** * Initializes a path object given the scheme, authority and path string. * * @param scheme * the scheme string. * @param authority * the authority string. * @param path * the path string. */ private void initialize(String scheme, String authority, String path) { try { this.uri = new URI(scheme, authority, normalizePath(path), null, null).normalize(); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } }
public static URI normalizeFileURI(URI uri) { try { File uriFile = new File(uri.getPath()); String uriStr = uriFile.toURI().normalize().toString(); if (uriStr.endsWith("/")) { uriStr = uriStr.substring(0, uriStr.length() - 1); } return new URI(uriStr); } catch (URISyntaxException e) { throw new IllegalArgumentException( "URI: " + uri + " is not in the expected format"); } }
private String resolveUrlSource(String base, Object... format) { if (format.length != 0) { base = String.format(base, format); } try { return new URI(base).normalize().toURL().toString(); } catch (Exception e) { LOG.log(Level.ALL, "Variable selenide.reportsUrl is incorrect: " + base, e); return null; } }
private RetCode doValidation(final Reporter reporter, final List<File> files) throws IOException, ProcessingException { final File schemaFile = files.remove(0); final String uri = schemaFile.toURI().normalize().toString(); JsonNode node; node = MAPPER.readTree(schemaFile); if (!syntaxValidator.schemaIsValid(node)) { System.err.println("Schema is invalid! Aborting..."); return SCHEMA_SYNTAX_ERROR; } final JsonSchema schema = factory.getJsonSchema(uri); RetCode ret = ALL_OK, retcode; for (final File file: files) { node = MAPPER.readTree(file); retcode = reporter.validateInstance(schema, file.toString(), node); if (retcode != ALL_OK) ret = retcode; } return ret; }
private String normalize(String theValue) { if (theValue == null) { return null; } try { URI retVal = new URI(getValue()).normalize(); String urlString = retVal.toString(); if (urlString.endsWith("/") && urlString.length() > 1) { retVal = new URI(urlString.substring(0, urlString.length() - 1)); } return retVal.toASCIIString(); } catch (URISyntaxException e) { // ourLog.debug("Failed to normalize URL '{}', message was: {}", urlString, e.toString()); return theValue; } }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { final String redirectToUrl = String.format("%s/%s?%s", exchange.getRequestURL(), OAuthTokenWebListener.ExtractingTokenInterceptor.PATH_PREFIX, exchange.getQueryString()); final URI redirectToUri = URI.create(redirectToUrl).normalize(); logger.log(Level.INFO, "Redirecting to " + redirectToUri); exchange.setResponseCode(StatusCodes.FOUND); exchange.getResponseHeaders().put(Headers.LOCATION, redirectToUri.toString()); exchange.endExchange(); } }
private String normalize(String theValue) { if (theValue == null) { return null; } try { URI retVal = new URI(getValue()).normalize(); String urlString = retVal.toString(); if (urlString.endsWith("/") && urlString.length() > 1) { retVal = new URI(urlString.substring(0, urlString.length() - 1)); } return retVal.toASCIIString(); } catch (URISyntaxException e) { // ourLog.debug("Failed to normalize URL '{}', message was: {}", urlString, e.toString()); return theValue; } }
/** * Removes relative parts from the given path. * * @param path element * @return fixed path */ private String getFixedPath(String path) { path = path.replaceAll("\\/", "/").replaceAll("\\\\\\.", "."); try { path = new URI(path).normalize().getPath(); } catch (URISyntaxException e) { e.printStackTrace(); } return path.replaceAll("/\\.{1,2}/", "/").replaceAll("^\\.{0,2}/", ""); }
private String normalize(String theValue) { if (theValue == null) { return null; } try { URI retVal = new URI(getValue()).normalize(); String urlString = retVal.toString(); if (urlString.endsWith("/") && urlString.length() > 1) { retVal = new URI(urlString.substring(0, urlString.length() - 1)); } return retVal.toASCIIString(); } catch (URISyntaxException e) { // ourLog.debug("Failed to normalize URL '{}', message was: {}", urlString, e.toString()); return theValue; } }
private String normalize(String theValue) { if (theValue == null) { return null; } URI retVal; try { retVal = new URI(theValue).normalize(); String urlString = retVal.toString(); if (urlString.endsWith("/") && urlString.length() > 1) { retVal = new URI(urlString.substring(0, urlString.length() - 1)); } } catch (URISyntaxException e) { ourLog.debug("Failed to normalize URL '{}', message was: {}", theValue, e.toString()); return theValue; } return retVal.toASCIIString(); }
/** * @param scheme the scheme string of the URI * @param authority the Authority of the URI * @param path the path component of the URI * @param query the query component of the URI */ public StandardURI(String scheme, Authority authority, String path, String query) { try { // Use java.net.URI to parse the URI components. java.net.URI uri; if (AlluxioURI.CUR_DIR.equals(path)) { uri = new java.net.URI(scheme, authority.toString().equals("") ? null : authority.toString(), AlluxioURI.normalizePath(path), query, null); } else { uri = new java.net.URI(scheme, authority.toString().equals("") ? null : authority.toString(), AlluxioURI.normalizePath(path), query, null).normalize(); } mScheme = uri.getScheme(); mSchemeSpecificPart = uri.getSchemeSpecificPart(); mAuthority = authority; mPath = uri.getPath(); mQuery = uri.getQuery(); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } }