OakpalPlan implements JsonObjectConvertible { static URI relativizeToBaseParent(final @NotNull URI baseUri, final @NotNull URI uri) throws URISyntaxException { if (baseUri.isOpaque() || uri.isOpaque()) { return uri; } else if (baseUri.getPath().contains("/") && baseUri.getPath().endsWith(".json")) { final String basePath = baseUri.getPath().substring(0, baseUri.getPath().lastIndexOf("/") + 1); final URI newBase = new URI(baseUri.getScheme(), baseUri.getUserInfo(), baseUri.getHost(), baseUri.getPort(), basePath, baseUri.getQuery(), baseUri.getFragment()); return newBase.relativize(uri); } else { return baseUri.relativize(uri); } } private  OakpalPlan(final @Nullable URL base,
                       final @Nullable JsonObject originalJson,
                       final @NotNull String name,
                       final @NotNull List<String> runModes,
                       final @NotNull List<String> checklists,
                       final @NotNull List<URL> preInstallUrls,
                       final @NotNull List<JcrNs> jcrNamespaces,
                       final @NotNull List<QNodeTypeDefinition> jcrNodetypes,
                       final @NotNull List<PrivilegeDefinition> jcrPrivileges,
                       final @NotNull List<ForcedRoot> forcedRoots,
                       final @NotNull List<CheckSpec> checks,
                       final boolean enablePreInstallHooks,
                       final @Nullable InstallHookPolicy installHookPolicy,
                       final @NotNull List<URL> repoInitUrls,
                       final @NotNull List<String> repoInits); @NotNull static JsonKeys keys(); URL getBase(); String getName(); JsonObject getOriginalJson(); List<String> getRunModes(); List<String> getChecklists(); List<URL> getPreInstallUrls(); List<JcrNs> getJcrNamespaces(); List<QNodeTypeDefinition> getJcrNodetypes(); List<PrivilegeDefinition> getJcrPrivileges(); List<ForcedRoot> getForcedRoots(); List<CheckSpec> getChecks(); boolean isEnablePreInstallHooks(); InstallHookPolicy getInstallHookPolicy(); List<URL> getRepoInitUrls(); List<String> getRepoInits(); @Override JsonObject toJson(); @Override String toString(); OakMachine.Builder toOakMachineBuilder(final @Nullable ErrorListener errorListener,
                                                  final @NotNull ClassLoader classLoader); static OakpalPlan fromJson(final @NotNull JsonObject json); static Result<OakpalPlan> fromJson(final @NotNull URL jsonUrl); static final URL EMPTY_PLAN_URL; static final URL BASIC_PLAN_URL; static final String DEFAULT_PLAN_NAME; }
@Test public void testRelativizeToBaseParent() throws Exception { final URI fooOpaque = new URI("mailto:foo@bar.com"); final URI barOpaque = new URL("http: assertSame("return uri when opaque", barOpaque, OakpalPlan.relativizeToBaseParent(fooOpaque, barOpaque)); final URI barOneJson = new URL("http: final URI barTwoJson = new URL("http: final URI barTwoRel = new URI("two.json"); assertEquals("return relative uri when base is not json", barTwoRel, OakpalPlan.relativizeToBaseParent(barOneJson, barTwoJson)); final URI fooRoot = new URL("http: final URI fooAbs = new URL("http: final URI fooRel = new URI("file.json"); assertEquals("return relative uri when base is not json", fooRel, OakpalPlan.relativizeToBaseParent(fooRoot, fooAbs)); }