- try {
- Node rootRealizedFlowNode = getNode().getNode(SLC_FLOW);
- // we just manage one level for the time being
- NodeIterator nit = rootRealizedFlowNode.getNodes(SLC_FLOW);
- while (nit.hasNext()) {
- Node realizedFlowNode = nit.nextNode();
-
- // set status on realized flow
- realizedFlowNode.setProperty(SLC_STATUS,
- ExecutionProcess.RUNNING);
- realizedFlowNode.getSession().save();
- try {
- execute(realizedFlowNode);
-
- // set status on realized flow
- realizedFlowNode.setProperty(SLC_STATUS,
- ExecutionProcess.COMPLETED);
- realizedFlowNode.getSession().save();
- } catch (RepositoryException e) {
- throw e;
- } catch (InterruptedException e) {
- // set status on realized flow
- realizedFlowNode.setProperty(SLC_STATUS,
- ExecutionProcess.KILLED);
- realizedFlowNode.getSession().save();
- throw e;
- } catch (RuntimeException e) {
- // set status on realized flow
- realizedFlowNode.setProperty(SLC_STATUS,
- ExecutionProcess.ERROR);
- realizedFlowNode.getSession().save();
- throw e;
- }
- }
- } catch (RepositoryException e) {
- throw new ArgeoException("Cannot process " + getNode(), e);
- }
- }
-
- /** Configure the realized flows */
- protected void execute(Node realizedFlowNode) throws RepositoryException,
- InterruptedException {
- if (realizedFlowNode.hasNode(SLC_ADDRESS)) {
- String flowPath = realizedFlowNode.getNode(SLC_ADDRESS)
- .getProperty(Property.JCR_PATH).getString();
- // TODO: convert to local path if remote
-
- Node flowNode = realizedFlowNode.getSession().getNode(flowPath);
- String flowName = flowNode.getProperty(SLC_NAME).getString();
-
- String executionModuleName = SlcJcrUtils
- .flowExecutionModuleName(flowPath);
- String executionModuleVersion = SlcJcrUtils
- .flowExecutionModuleVersion(flowPath);
-
- RealizedFlow realizedFlow = new RealizedFlow();
- realizedFlow.setModuleName(executionModuleName);
- realizedFlow.setModuleVersion(executionModuleVersion);
-
- // retrieve execution spec
- DefaultExecutionSpec executionSpec = null;
- if (flowNode.hasProperty(SlcNames.SLC_SPEC)) {
- Node executionSpecNode = flowNode.getProperty(SLC_SPEC)
- .getNode();
- executionSpec = new DefaultExecutionSpec();
- executionSpec.setBeanName(executionSpecNode.getProperty(
- SLC_NAME).getString());
- executionSpec
- .setAttributes(readExecutionSpecAttributes(executionSpecNode));
- }
- // TODO: will with original attr
- Map<String, ExecutionSpecAttribute> attrs = readExecutionSpecAttributes(realizedFlowNode);
- Map<String, Object> values = new HashMap<String, Object>();
- for (String attrName : attrs.keySet()) {
- if (flowNode.hasNode(attrName)) {
- // we assume this is a primitive
- // since ref are not yet implemented
- Node valueNode = flowNode.getNode(attrName);
- String type = valueNode.getProperty(SLC_TYPE).getString();
- String valueStr = valueNode.getProperty(SLC_VALUE)
- .getString();
- Object value = PrimitiveUtils.convert(type, valueStr);
- values.put(attrName, value);
- } else {
- ExecutionSpecAttribute attr = attrs.get(attrName);
- Object value = attr.getValue();
- values.put(attrName, value);
+ Session session = null;
+ if (getProcess() instanceof JcrExecutionProcess)
+ try {
+ session = ((JcrExecutionProcess) getProcess()).getRepository()
+ .login();
+
+ List<RealizedFlow> realizedFlows = getProcess()
+ .getRealizedFlows();
+ for (RealizedFlow realizedFlow : realizedFlows) {
+ Node realizedFlowNode = session
+ .getNode(((JcrRealizedFlow) realizedFlow).getPath());
+ setFlowStatus(realizedFlowNode, ExecutionProcess.RUNNING);
+
+ try {
+ //
+ // EXECUTE THE FLOW
+ //
+ execute(realizedFlow, true);
+
+ setFlowStatus(realizedFlowNode,
+ ExecutionProcess.COMPLETED);
+ } catch (RepositoryException e) {
+ throw e;
+ } catch (InterruptedException e) {
+ setFlowStatus(realizedFlowNode, ExecutionProcess.KILLED);
+ throw e;
+ } catch (RuntimeException e) {
+ setFlowStatus(realizedFlowNode, ExecutionProcess.ERROR);
+ throw e;
+ }