From: Mathieu Baudier Date: Thu, 21 Mar 2013 11:42:31 +0000 (+0000) Subject: Fix execution spec node added twice X-Git-Tag: argeo-slc-2.1.7~387 X-Git-Url: http://git.argeo.org/?a=commitdiff_plain;h=ce8f53763eec2a2b9e15e97f2eaa8468b551ea31;p=gpl%2Fargeo-slc.git Fix execution spec node added twice git-svn-id: https://svn.argeo.org/slc/trunk@6185 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- diff --git a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java index 473dcb343..9e866dfc7 100644 --- a/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java +++ b/runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionModulesListener.java @@ -243,8 +243,9 @@ public class JcrExecutionModulesListener implements ExecutionModulesListener, String relativePath, ExecutionFlowDescriptor efd) throws RepositoryException { Node flowNode = null; - Iterator names = Arrays.asList(relativePath.split("/")) - .iterator(); + List pathTokens = Arrays.asList(relativePath.split("/")); + + Iterator 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));