X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Finternal%2Fruntime%2FKernelUtils.java;h=7165966486824fa56d842ded78c824bee0d7dc82;hb=b897c27d370ad4772b5ae4b2c22cc505ef5d1a3f;hp=0e84af62af45d8c5b2d22b0261cb3e1dcc2170b9;hpb=94acaccee3d04f3b91f36d2b78ebae76bcd996de;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/internal/runtime/KernelUtils.java b/org.argeo.cms/src/org/argeo/cms/internal/runtime/KernelUtils.java index 0e84af62a..716596648 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/runtime/KernelUtils.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/runtime/KernelUtils.java @@ -1,6 +1,5 @@ package org.argeo.cms.internal.runtime; -import java.io.File; import java.io.IOException; import java.io.PrintStream; import java.net.URI; @@ -52,15 +51,15 @@ class KernelUtils implements KernelConstants { return asDictionary(props); } - static File getExecutionDir(String relativePath) { - File executionDir = new File(getFrameworkProp("user.dir")); + static Path getExecutionDir(String relativePath) { + Path executionDir = Paths.get(getFrameworkProp("user.dir")); if (relativePath == null) return executionDir; - try { - return new File(executionDir, relativePath).getCanonicalFile(); - } catch (IOException e) { - throw new IllegalArgumentException("Cannot get canonical file", e); - } +// try { + return executionDir.resolve(relativePath); +// } catch (IOException e) { +// throw new IllegalArgumentException("Cannot get canonical file", e); +// } } // static File getOsgiInstanceDir() { @@ -69,28 +68,34 @@ class KernelUtils implements KernelConstants { // } public static Path getOsgiInstancePath(String relativePath) { - return Paths.get(getOsgiInstanceUri(relativePath)); + URI uri = getOsgiInstanceUri(relativePath); + if (uri == null) // no data area available + return null; + return Paths.get(uri); } public static URI getOsgiInstanceUri(String relativePath) { String osgiInstanceBaseUri = getFrameworkProp(OSGI_INSTANCE_AREA); + if (osgiInstanceBaseUri == null) // no data area available + return null; + if (!osgiInstanceBaseUri.endsWith("/")) osgiInstanceBaseUri = osgiInstanceBaseUri + "/"; - if (osgiInstanceBaseUri != null) - return safeUri(osgiInstanceBaseUri + (relativePath != null ? relativePath : "")); - else - return Paths.get(System.getProperty("user.dir"), (relativePath != null ? relativePath : "")).toUri(); +// if (osgiInstanceBaseUri != null) + return safeUri(osgiInstanceBaseUri + (relativePath != null ? relativePath : "")); +// else +// return Paths.get(System.getProperty("user.dir"), (relativePath != null ? relativePath : "")).toUri(); } - static File getOsgiConfigurationFile(String relativePath) { - try { - return new File( - new URI(CmsActivator.getBundleContext().getProperty(OSGI_CONFIGURATION_AREA) + relativePath)) - .getCanonicalFile(); - } catch (Exception e) { - throw new IllegalArgumentException("Cannot get configuration file for " + relativePath, e); - } - } +// static File getOsgiConfigurationFile(String relativePath) { +// try { +// return new File( +// new URI(CmsActivator.getBundleContext().getProperty(OSGI_CONFIGURATION_AREA) + relativePath)) +// .getCanonicalFile(); +// } catch (Exception e) { +// throw new IllegalArgumentException("Cannot get configuration file for " + relativePath, e); +// } +// } static String getFrameworkProp(String key, String def) { String value;