Remove hours and add title property to the result process path on request of O. Capillon
authorBruno Sinou <bsinou@argeo.org>
Thu, 15 Nov 2012 13:00:07 +0000 (13:00 +0000)
committerBruno Sinou <bsinou@argeo.org>
Thu, 15 Nov 2012 13:00:07 +0000 (13:00 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@5830 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/SlcJcrUtils.java

index ab2f1540521673273d2ec2e97281392b181f64ec..3473827cdd7a2e921cd12f9905689c8442fefdc7 100644 (file)
@@ -17,11 +17,14 @@ package org.argeo.slc.jcr;
 
 import java.util.Calendar;
 import java.util.GregorianCalendar;
+import java.util.List;
 
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
+import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
 
 import org.argeo.jcr.JcrUtils;
 import org.argeo.jcr.UserJcrUtils;
@@ -112,8 +115,26 @@ public class SlcJcrUtils implements SlcNames {
        public static String createResultPath(Session session, String uuid)
                        throws RepositoryException {
                Calendar now = new GregorianCalendar();
-               return SlcJcrResultUtils.getSlcResultsBasePath(session) + '/'
-                               + JcrUtils.dateAsPath(now, true) + uuid;
+               StringBuffer absPath = new StringBuffer(
+                               SlcJcrResultUtils.getSlcResultsBasePath(session) + '/');
+               // Remove hours and add title property to the result process path on
+               // request of O. Capillon
+               // return getSlcProcessesBasePath(session) + '/'
+               // + JcrUtils.dateAsPath(now, true) + uuid;
+               String relPath = JcrUtils.dateAsPath(now, false);
+               List<String> names = JcrUtils.tokenize(relPath);
+               for (String name : names) {
+                       absPath.append(name + "/");
+                       Node node = JcrUtils.mkdirs(session, absPath.toString());
+                       try {
+                               node.addMixin(NodeType.MIX_TITLE);
+                               node.setProperty(Property.JCR_TITLE, name.substring(1));
+                       } catch (RepositoryException e) {
+                               throw new SlcException(
+                                               "unable to create execution process path", e);
+                       }
+               }
+               return absPath.toString() + uuid;
        }
 
        /**