]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.cms/src/org/argeo/cms/internal/kernel/KernelUtils.java
Introduce CMS API
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / internal / kernel / KernelUtils.java
index c1e20892456fd26792956f3ce2532a3ddce9738c..81c9242b2589c6114fdcc885ac8b054fa8ff38ce 100644 (file)
@@ -7,6 +7,7 @@ import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Properties;
+import java.util.TreeSet;
 
 import javax.security.auth.Subject;
 import javax.security.auth.login.LoginContext;
@@ -16,6 +17,7 @@ import javax.servlet.http.HttpServletRequest;
 import org.apache.commons.logging.Log;
 import org.argeo.cms.CmsException;
 import org.argeo.cms.auth.AuthConstants;
+import org.osgi.framework.BundleContext;
 
 /** Package utilities */
 class KernelUtils implements KernelConstants {
@@ -41,6 +43,17 @@ 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()))
@@ -126,6 +139,24 @@ class KernelUtils implements KernelConstants {
                        Object headerValue = request.getHeader(headerName);
                        log.debug(headerName + ": " + headerValue);
                }
+               log.debug(request.getRequestURI()+"\n");
+       }
+
+       static void logFrameworkProperties(Log log) {
+               BundleContext bc = Activator.getBundleContext();
+               for (Object sysProp : new TreeSet<Object>(System.getProperties()
+                               .keySet())) {
+                       log.debug(sysProp + "=" + bc.getProperty(sysProp.toString()));
+               }
+               // 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() {