import org.apache.commons.logging.Log;
import org.argeo.cms.CmsException;
-import org.argeo.cms.KernelHeader;
+import org.argeo.cms.auth.AuthConstants;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
/** Package utilities */
class KernelUtils implements KernelConstants {
return asDictionary(props);
}
+ static File getExecutionDir(String relativePath) {
+ File executionDir = new File(getFrameworkProp("user.dir"));
+ if (relativePath == null)
+ return executionDir;
+ try {
+ return new File(executionDir, relativePath).getCanonicalFile();
+ } catch (IOException e) {
+ throw new CmsException("Cannot get canonical file", e);
+ }
+ }
+
static File getOsgiInstanceDir() {
return new File(Activator.getBundleContext()
.getProperty(OSGI_INSTANCE_AREA).substring("file:".length()))
.getAbsoluteFile();
}
+ static String getOsgiInstancePath(String relativePath) {
+ try {
+ if (relativePath == null)
+ return getOsgiInstanceDir().getCanonicalPath();
+ else
+ return new File(getOsgiInstanceDir(), relativePath)
+ .getCanonicalPath();
+ } catch (IOException e) {
+ throw new CmsException("Cannot get instance path for "
+ + relativePath, e);
+ }
+ }
+
static File getOsgiConfigurationFile(String relativePath) {
try {
return new File(new URI(Activator.getBundleContext().getProperty(
Subject subject = new Subject();
LoginContext lc;
try {
- lc = new LoginContext(KernelHeader.LOGIN_CONTEXT_ANONYMOUS, subject);
+ lc = new LoginContext(AuthConstants.LOGIN_CONTEXT_ANONYMOUS,
+ subject);
lc.login();
return subject;
} catch (LoginException e) {
}
}
+ static void logFrameworkProperties(Log log) {
+ BundleContext bc = Activator.getBundleContext();
+ String[] keys = { Constants.FRAMEWORK_STORAGE,
+ Constants.FRAMEWORK_OS_NAME, Constants.FRAMEWORK_OS_VERSION,
+ Constants.FRAMEWORK_PROCESSOR, Constants.FRAMEWORK_SECURITY,
+ Constants.FRAMEWORK_TRUST_REPOSITORIES,
+ Constants.FRAMEWORK_WINDOWSYSTEM, Constants.FRAMEWORK_VENDOR,
+ Constants.FRAMEWORK_VERSION, Constants.FRAMEWORK_STORAGE_CLEAN,
+ Constants.FRAMEWORK_LANGUAGE, Constants.FRAMEWORK_UUID };
+ for (String key : keys)
+ log.debug(key + "=" + bc.getProperty(key));
+ }
+
private KernelUtils() {
}