]> git.argeo.org Git - gpl/argeo-slc.git/commitdiff
Fix execution spec node added twice
authorMathieu Baudier <mbaudier@argeo.org>
Thu, 21 Mar 2013 11:42:31 +0000 (11:42 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Thu, 21 Mar 2013 11:42:31 +0000 (11:42 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@6185 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java

index 473dcb343434fc7a7a055624bafeed08fc1f5de9..9e866dfc79051f37f303cb5239d30bb4f7d3dcb3 100644 (file)
@@ -243,8 +243,9 @@ public class JcrExecutionModulesListener implements ExecutionModulesListener,
                        String relativePath, ExecutionFlowDescriptor efd)
                        throws RepositoryException {
                Node flowNode = null;
-               Iterator<String> names = Arrays.asList(relativePath.split("/"))
-                               .iterator();
+               List<String> pathTokens = Arrays.asList(relativePath.split("/"));
+
+               Iterator<String> names = pathTokens.iterator();
                // create intermediary paths
                Node currNode = moduleNode;
                while (names.hasNext()) {
@@ -262,8 +263,7 @@ public class JcrExecutionModulesListener implements ExecutionModulesListener,
 
                // name, description
                flowNode.setProperty(SLC_NAME, efd.getName());
-               String[] tokens = relativePath.split("/");
-               String endName = tokens[tokens.length - 1];
+               String endName = pathTokens.get(pathTokens.size() - 1);
                flowNode.setProperty(Property.JCR_TITLE, endName);
                if (efd.getDescription() != null
                                && !efd.getDescription().trim().equals("")) {
@@ -300,9 +300,12 @@ public class JcrExecutionModulesListener implements ExecutionModulesListener,
                for (String attr : efd.getValues().keySet()) {
                        ExecutionSpecAttribute esa = executionSpec.getAttributes()
                                        .get(attr);
+                       if (!flowNode.hasNode(attr))
+                               throw new SlcException("No spec node for attribute '" + attr
+                                               + "' in flow " + flowNode.getPath());
                        if (esa instanceof PrimitiveSpecAttribute) {
                                PrimitiveSpecAttribute psa = (PrimitiveSpecAttribute) esa;
-                               Node valueNode = flowNode.addNode(attr);
+                               Node valueNode = flowNode.getNode(attr);
                                valueNode.setProperty(SLC_TYPE, psa.getType());
                                SlcJcrUtils.setPrimitiveAsProperty(valueNode, SLC_VALUE,
                                                (PrimitiveValue) efd.getValues().get(attr));