private static String getCwd() throws IOException { final File cwd = new File(System.getProperty("user.dir", ".")) .getCanonicalFile(); return URIUtils.normalizeURI(cwd.toURI()).toString(); } }
/** * Set the namespace for this configuration * * <p>All schema loading via URIs (using {@link SchemaLoader#get(URI)} or * when encountering a JSON Reference in a schema) will be resolved against * the provided namespace.</p> * * @param uri the URI * @return this * @throws NullPointerException URI is null * @throws IllegalArgumentException URI is not absolute, or is not a path * URI (ie, does not end with {@code /}) */ public URITranslatorConfigurationBuilder setNamespace(final URI uri) { BUNDLE.checkNotNull(uri, "uriChecks.nullInput"); final URI normalized = URIUtils.normalizeURI(uri); URIUtils.checkPathURI(normalized); namespace = normalized; return this; }
PathRedirectRegistry() { super(URIUtils.uriNormalizer(), URIUtils.pathURIChecker(), URIUtils.uriNormalizer(), URIUtils.pathURIChecker()); }
public URIDownloadersRegistry() { super(URIUtils.schemeNormalizer(), URIUtils.schemeChecker(), Functions.<URIDownloader>identity(), ArgumentChecker.<URIDownloader>anythingGoes()); putAll(DEFAULT_DOWNLOADERS); }
SchemaRedirectRegistry() { super(URIUtils.schemaURINormalizer(), URIUtils.schemaURIChecker(), URIUtils.schemaURINormalizer(), URIUtils.schemaURIChecker()); }
@Test(dataProvider = "invalidPathURIs") public void invalidPathURIsAreRejected(final String uri, final String key) { try { URIUtils.checkPathURI(URI.create(uri)); fail("No exception thrown!"); } catch (IllegalArgumentException e) { assertEquals(e.getMessage(), BUNDLE.printf(key, uri)); } }
/** * Set the namespace for this configuration * * <p>All schema loading via URIs (using {@link SchemaLoader#get(URI)} or * when encountering a JSON Reference in a schema) will be resolved against * the provided namespace.</p> * * @param uri the URI * @return this * @throws NullPointerException URI is null * @throws IllegalArgumentException URI is not absolute, or is not a path * URI (ie, does not end with {@code /}) */ public URITranslatorConfigurationBuilder setNamespace(final URI uri) { BUNDLE.checkNotNull(uri, "uriChecks.nullInput"); final URI normalized = URIUtils.normalizeURI(uri); URIUtils.checkPathURI(normalized); namespace = normalized; return this; }
PathRedirectRegistry() { super(URIUtils.uriNormalizer(), URIUtils.pathURIChecker(), URIUtils.uriNormalizer(), URIUtils.pathURIChecker()); }
public URIDownloadersRegistry() { super(URIUtils.schemeNormalizer(), URIUtils.schemeChecker(), Functions.<URIDownloader>identity(), ArgumentChecker.<URIDownloader>anythingGoes()); putAll(DEFAULT_DOWNLOADERS); }
SchemaRedirectRegistry() { super(URIUtils.schemaURINormalizer(), URIUtils.schemaURIChecker(), URIUtils.schemaURINormalizer(), URIUtils.schemaURIChecker()); }
/** * Set the namespace for this configuration * * <p>All schema loading via URIs (using {@link SchemaLoader#get(URI)} or * when encountering a JSON Reference in a schema) will be resolved against * the provided namespace.</p> * * @param uri the URI * @return this * @throws NullPointerException URI is null * @throws IllegalArgumentException URI is not absolute, or is not a path * URI (ie, does not end with {@code /}) */ public URITranslatorConfigurationBuilder setNamespace(final URI uri) { BUNDLE.checkNotNull(uri, "uriChecks.nullInput"); final URI normalized = URIUtils.normalizeURI(uri); URIUtils.checkPathURI(normalized); namespace = normalized; return this; }
public URI translate(final URI source) { URI uri = URIUtils.normalizeURI(namespace.resolve(source)); final String fragment = uri.getFragment(); try { uri = new URI(uri.getScheme(), uri.getSchemeSpecificPart(), null); } catch (URISyntaxException e) { throw new IllegalStateException("How did I get there??", e); } for (final Map.Entry<URI, URI> entry: pathRedirects.entrySet()) { final URI relative = entry.getKey().relativize(uri); if (!relative.equals(uri)) uri = entry.getValue().resolve(relative); } uri = JsonRef.fromURI(uri).getLocator(); if (schemaRedirects.containsKey(uri)) uri = schemaRedirects.get(uri); try { return new URI(uri.getScheme(), uri.getSchemeSpecificPart(), fragment); } catch (URISyntaxException e) { throw new IllegalStateException("How did I get there??", e); } } }
PathRedirectRegistry() { super(URIUtils.uriNormalizer(), URIUtils.pathURIChecker(), URIUtils.uriNormalizer(), URIUtils.pathURIChecker()); }
public URIDownloadersRegistry() { super(URIUtils.schemeNormalizer(), URIUtils.schemeChecker(), Functions.<URIDownloader>identity(), ArgumentChecker.<URIDownloader>anythingGoes()); putAll(DEFAULT_DOWNLOADERS); }
SchemaRedirectRegistry() { super(URIUtils.schemaURINormalizer(), URIUtils.schemaURIChecker(), URIUtils.schemaURINormalizer(), URIUtils.schemaURIChecker()); }
public URI translate(final URI source) { URI uri = URIUtils.normalizeURI(namespace.resolve(source)); final String fragment = uri.getFragment(); try { uri = new URI(uri.getScheme(), uri.getSchemeSpecificPart(), null); } catch (URISyntaxException e) { throw new IllegalStateException("How did I get there??", e); } for (final Map.Entry<URI, URI> entry: pathRedirects.entrySet()) { final URI relative = entry.getKey().relativize(uri); if (!relative.equals(uri)) uri = entry.getValue().resolve(relative); } uri = JsonRef.fromURI(uri).getLocator(); if (schemaRedirects.containsKey(uri)) uri = schemaRedirects.get(uri); try { return new URI(uri.getScheme(), uri.getSchemeSpecificPart(), fragment); } catch (URISyntaxException e) { throw new IllegalStateException("How did I get there??", e); } } }
public URI translate(final URI source) { URI uri = URIUtils.normalizeURI(namespace.resolve(source)); final String fragment = uri.getFragment(); try { uri = new URI(uri.getScheme(), uri.getSchemeSpecificPart(), null); } catch (URISyntaxException e) { throw new IllegalStateException("How did I get there??", e); } for (final Map.Entry<URI, URI> entry: pathRedirects.entrySet()) { final URI relative = entry.getKey().relativize(uri); if (!relative.equals(uri)) uri = entry.getValue().resolve(relative); } uri = JsonRef.fromURI(uri).getLocator(); if (schemaRedirects.containsKey(uri)) uri = schemaRedirects.get(uri); try { return new URI(uri.getScheme(), uri.getSchemeSpecificPart(), fragment); } catch (URISyntaxException e) { throw new IllegalStateException("How did I get there??", e); } } }
@Test(dataProvider = "uriData") public void urisAreCorrectlyNormalized(final URI orig, final URI dst) { assertEquals(URIUtils.normalizeURI(orig), dst); }
/** * Build a JSON Reference from a URI * * @param uri the provided URI * @return the JSON Reference * @throws NullPointerException the provided URI is null */ public static JsonRef fromURI(final URI uri) { BUNDLE.checkNotNull(uri, "jsonRef.nullURI"); final URI normalized = URIUtils.normalizeURI(uri); if (HASHONLY_URI.equals(normalized) || EMPTY_URI.equals(normalized)) return EmptyJsonRef.getInstance(); return "jar".equals(normalized.getScheme()) ? new JarJsonRef(normalized) : new HierarchicalJsonRef(normalized); }
/** * Build a JSON Reference from a URI * * @param uri the provided URI * @return the JSON Reference * @throws NullPointerException the provided URI is null */ public static JsonRef fromURI(final URI uri) { BUNDLE.checkNotNull(uri, "jsonRef.nullURI"); final URI normalized = URIUtils.normalizeURI(uri); if (HASHONLY_URI.equals(normalized) || EMPTY_URI.equals(normalized)) return EmptyJsonRef.getInstance(); return "jar".equals(normalized.getScheme()) ? new JarJsonRef(normalized) : new HierarchicalJsonRef(normalized); }