]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.cms/src/org/argeo/cms/internal/kernel/KernelUtils.java
Fix add member to LDIF group
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / internal / kernel / KernelUtils.java
index 80c166e0a9db33fddfe94594ac842adbc1df4c59..912d9fa995d2c58ea38fb350361ca4c219fa5092 100644 (file)
@@ -2,6 +2,7 @@ package org.argeo.cms.internal.kernel;
 
 import java.io.File;
 import java.io.IOException;
+import java.net.URI;
 import java.util.Collections;
 import java.util.Dictionary;
 import java.util.Enumeration;
@@ -15,7 +16,6 @@ import org.apache.commons.logging.Log;
 import org.argeo.cms.CmsException;
 import org.argeo.cms.KernelHeader;
 import org.argeo.cms.internal.auth.GrantedAuthorityPrincipal;
-import org.osgi.framework.BundleContext;
 import org.springframework.security.authentication.AnonymousAuthenticationToken;
 import org.springframework.security.authentication.AuthenticationManager;
 import org.springframework.security.core.Authentication;
@@ -26,6 +26,7 @@ import org.springframework.security.core.userdetails.UserDetails;
 /** Package utilities */
 class KernelUtils implements KernelConstants {
        private final static String OSGI_INSTANCE_AREA = "osgi.instance.area";
+       private final static String OSGI_CONFIGURATION_AREA = "osgi.configuration.area";
 
        static Dictionary<String, ?> asDictionary(Properties props) {
                Hashtable<String, Object> hashtable = new Hashtable<String, Object>();
@@ -46,9 +47,32 @@ class KernelUtils implements KernelConstants {
                return asDictionary(props);
        }
 
-       static File getOsgiInstanceDir(BundleContext bundleContext) {
-               return new File(bundleContext.getProperty(OSGI_INSTANCE_AREA)
-                               .substring("file:".length())).getAbsoluteFile();
+       static File getOsgiInstanceDir() {
+               return new File(Activator.getBundleContext()
+                               .getProperty(OSGI_INSTANCE_AREA).substring("file:".length()))
+                               .getAbsoluteFile();
+       }
+
+       static File getOsgiConfigurationFile(String relativePath) {
+               try {
+                       return new File(new URI(Activator.getBundleContext().getProperty(
+                                       OSGI_CONFIGURATION_AREA)
+                                       + relativePath)).getCanonicalFile();
+               } catch (Exception e) {
+                       throw new CmsException("Cannot get configuration file for "
+                                       + relativePath, e);
+               }
+       }
+
+       static String getFrameworkProp(String key, String def) {
+               String value = Activator.getBundleContext().getProperty(key);
+               if (value == null)
+                       return def;
+               return value;
+       }
+
+       static String getFrameworkProp(String key) {
+               return getFrameworkProp(key, null);
        }
 
        // Security