]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/SlcJcrUtils.java
Add password spec type
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.jcr / src / main / java / org / argeo / slc / jcr / SlcJcrUtils.java
index 52931218bcbe1c15142c9ec4744b16c6b55c9304..e0e52c0d517d4c071d50188f8ad6118ae1c99fe3 100644 (file)
@@ -76,12 +76,27 @@ public class SlcJcrUtils implements SlcNames {
        }
 
        /** Create a new execution process path based on the current time */
-       public static String createExecutionProcessPath(String uuid) {
+       public static String createExecutionProcessPath(Session session, String uuid) {
                Calendar now = new GregorianCalendar();
-               return SlcJcrConstants.PROCESSES_BASE_PATH + '/'
+               return getSlcProcessesBasePath(session) + '/'
                                + JcrUtils.dateAsPath(now, true) + uuid;
        }
 
+       /** GEt the base for the user processeses. */
+       public static String getSlcProcessesBasePath(Session session) {
+               try {
+                       Node userHome = UserJcrUtils.getUserHome(session);
+                       if (userHome == null)
+                               throw new SlcException("No user home available for "
+                                               + session.getUserID());
+                       return userHome.getPath() + '/' + SlcNames.SLC_SYSTEM + '/'
+                                       + SlcNames.SLC_PROCESSES;
+               } catch (RepositoryException re) {
+                       throw new SlcException(
+                                       "Unexpected error while getting Slc Results Base Path.", re);
+               }
+       }
+
        /**
         * Create a new execution result path in the user home based on the current
         * time
@@ -89,9 +104,8 @@ public class SlcJcrUtils implements SlcNames {
        public static String createResultPath(Session session, String uuid)
                        throws RepositoryException {
                Calendar now = new GregorianCalendar();
-               return UserJcrUtils.getUserHome(session).getPath() + '/'
-                               + SlcNames.SLC_RESULTS + '/' + JcrUtils.dateAsPath(now, true)
-                               + uuid;
+               return SlcJcrResultUtils.getSlcResultsBasePath(session) + '/'
+                               + JcrUtils.dateAsPath(now, true) + uuid;
        }
 
        /**
@@ -113,10 +127,14 @@ public class SlcJcrUtils implements SlcNames {
                if (value instanceof CharSequence)
                        value = PrimitiveUtils.convert(type,
                                        ((CharSequence) value).toString());
+               if (value instanceof char[])
+                       value = new String((char[]) value);
 
                try {
                        if (type.equals(PrimitiveAccessor.TYPE_STRING))
                                node.setProperty(propertyName, value.toString());
+                       else if (type.equals(PrimitiveAccessor.TYPE_PASSWORD))
+                               node.setProperty(propertyName, value.toString());
                        else if (type.equals(PrimitiveAccessor.TYPE_INTEGER))
                                node.setProperty(propertyName, (long) ((Integer) value));
                        else if (type.equals(PrimitiveAccessor.TYPE_LONG))