]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java
Fix execution spec node added twice
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.jcr / src / main / java / org / argeo / slc / jcr / execution / JcrExecutionModulesListener.java
index f63acb5c06faac9f5a21054014fccba7314816c0..9e866dfc79051f37f303cb5239d30bb4f7d3dcb3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2012 Mathieu Baudier
+ * Copyright (C) 2007-2012 Argeo GmbH
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -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));