From c10c30a727b8f3bce64c0c347a08c111845a3da2 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Fri, 13 Mar 2020 08:10:48 +0100 Subject: [PATCH] Adapt to changes in Argeo Commons. --- .../META-INF/spring/osgi.xml | 2 +- .../org.argeo.cms.ui.workbench/bnd.bnd | 2 +- .../META-INF/spring/osgi.xml | 2 +- org.argeo.slc.client.rap/bnd.bnd | 2 +- .../META-INF/spring/osgi.xml | 2 +- .../controllers/DistTreeContentProvider.java | 8 +- .../META-INF/spring/osgi.xml | 2 +- org.argeo.slc.client.ui/bnd.bnd | 1 + org.argeo.slc.client.ui/pom.xml | 5 + .../client/ui/editors/ProcessBuilderPage.java | 209 +++++++----------- .../slc/client/ui/editors/ProcessEditor.java | 74 +++---- .../client/ui/views/JcrProcessListView.java | 57 ++--- .../slc/jcr/execution/JcrProcessThread.java | 22 +- .../slc/jcr/execution/JcrRealizedFlow.java | 66 +++--- org.argeo.slc.repo/bnd.bnd | 3 +- org.argeo.slc.spring/bnd.bnd | 2 +- 16 files changed, 190 insertions(+), 269 deletions(-) diff --git a/legacy/argeo-commons/org.argeo.cms.ui.workbench/META-INF/spring/osgi.xml b/legacy/argeo-commons/org.argeo.cms.ui.workbench/META-INF/spring/osgi.xml index 36c8e2f4e..da9785e5d 100644 --- a/legacy/argeo-commons/org.argeo.cms.ui.workbench/META-INF/spring/osgi.xml +++ b/legacy/argeo-commons/org.argeo.cms.ui.workbench/META-INF/spring/osgi.xml @@ -18,7 +18,7 @@ + filter="(cn=ego)" /> diff --git a/legacy/argeo-commons/org.argeo.cms.ui.workbench/bnd.bnd b/legacy/argeo-commons/org.argeo.cms.ui.workbench/bnd.bnd index da2875c31..d485eeb9d 100644 --- a/legacy/argeo-commons/org.argeo.cms.ui.workbench/bnd.bnd +++ b/legacy/argeo-commons/org.argeo.cms.ui.workbench/bnd.bnd @@ -9,7 +9,7 @@ Import-Package: org.argeo.cms.auth,\ org.argeo.cms,\ org.argeo.cms.ui,\ org.argeo.eclipse.spring,\ -org.argeo.eclipse.ui.utils,\ +org.argeo.eclipse.ui.util,\ org.eclipse.core.runtime.jobs,\ org.eclipse.jface.window,\ org.eclipse.swt,\ diff --git a/org.argeo.slc.client.rap/META-INF/spring/osgi.xml b/org.argeo.slc.client.rap/META-INF/spring/osgi.xml index baa7f2d89..149c7a2bd 100644 --- a/org.argeo.slc.client.rap/META-INF/spring/osgi.xml +++ b/org.argeo.slc.client.rap/META-INF/spring/osgi.xml @@ -13,5 +13,5 @@ - + diff --git a/org.argeo.slc.client.rap/bnd.bnd b/org.argeo.slc.client.rap/bnd.bnd index 87118c043..7b46665df 100644 --- a/org.argeo.slc.client.rap/bnd.bnd +++ b/org.argeo.slc.client.rap/bnd.bnd @@ -11,6 +11,6 @@ javax.servlet,\ javax.servlet.http,\ org.argeo.eclipse.spring,\ org.argeo.slc.repo.core,\ -org.argeo.cms.util,\ +org.argeo.cms.ui.util,\ * \ No newline at end of file diff --git a/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml b/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml index 48e9a1b62..324c66f8b 100644 --- a/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml +++ b/org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml @@ -15,7 +15,7 @@ + filter="(cn=ego)" /> \ No newline at end of file diff --git a/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeContentProvider.java b/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeContentProvider.java index f1858d3d9..3b378e953 100644 --- a/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeContentProvider.java +++ b/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeContentProvider.java @@ -12,6 +12,7 @@ import javax.jcr.RepositoryFactory; import javax.jcr.Session; import javax.jcr.nodetype.NodeType; +import org.argeo.api.NodeConstants; import org.argeo.api.NodeUtils; import org.argeo.api.security.Keyring; import org.argeo.cms.ArgeoNames; @@ -44,7 +45,7 @@ public class DistTreeContentProvider implements ITreeContentProvider { try { if (nodeSession != null) dispose(); - nodeSession = nodeRepository.login(); + nodeSession = nodeRepository.login(NodeConstants.HOME); String reposPath = NodeUtils.getUserHome(nodeSession).getPath() + RepoConstants.REPOSITORIES_BASE_PATH; @@ -56,7 +57,8 @@ public class DistTreeContentProvider implements ITreeContentProvider { Node repoNode = repos.nextNode(); if (repoNode.isNodeType(ArgeoTypes.ARGEO_REMOTE_REPOSITORY)) { String label = repoNode.isNodeType(NodeType.MIX_TITLE) - ? repoNode.getProperty(Property.JCR_TITLE).getString() : repoNode.getName(); + ? repoNode.getProperty(Property.JCR_TITLE).getString() + : repoNode.getName(); repositories.add(new RepoElem(repositoryFactory, keyring, repoNode, label)); } } @@ -106,7 +108,7 @@ public class DistTreeContentProvider implements ITreeContentProvider { throw new SlcException("User must be authenticated."); // make sure base directory is available - Node repos = JcrUtils.mkdirs(homeNode, RepoConstants.REPOSITORIES_BASE_PATH,null); + Node repos = JcrUtils.mkdirs(homeNode, RepoConstants.REPOSITORIES_BASE_PATH, null); if (nodeSession.hasPendingChanges()) nodeSession.save(); diff --git a/org.argeo.slc.client.ui/META-INF/spring/osgi.xml b/org.argeo.slc.client.ui/META-INF/spring/osgi.xml index b27a06559..79eb6bc86 100644 --- a/org.argeo.slc.client.ui/META-INF/spring/osgi.xml +++ b/org.argeo.slc.client.ui/META-INF/spring/osgi.xml @@ -12,7 +12,7 @@ + filter="(cn=ego)" /> diff --git a/org.argeo.slc.client.ui/bnd.bnd b/org.argeo.slc.client.ui/bnd.bnd index 497210cbc..d24c331e7 100644 --- a/org.argeo.slc.client.ui/bnd.bnd +++ b/org.argeo.slc.client.ui/bnd.bnd @@ -7,6 +7,7 @@ org.eclipse.rap.ui.workbench;resolution:=optional Bundle-Activator: org.argeo.slc.client.ui.ClientUiPlugin Import-Package: org.argeo.eclipse.spring,\ +org.argeo.api,\ org.eclipse.core.runtime,\ org.osgi.*;version=0.0.0,\ * diff --git a/org.argeo.slc.client.ui/pom.xml b/org.argeo.slc.client.ui/pom.xml index f4571db4c..951a43792 100644 --- a/org.argeo.slc.client.ui/pom.xml +++ b/org.argeo.slc.client.ui/pom.xml @@ -20,6 +20,11 @@ + + org.argeo.commons + org.argeo.api + ${version.argeo-commons} + org.argeo.commons org.argeo.eclipse.ui diff --git a/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java b/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java index 638d3a2d2..b83b8d820 100644 --- a/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java +++ b/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java @@ -21,10 +21,12 @@ import java.util.List; import java.util.SortedSet; import java.util.TreeSet; +import javax.jcr.LoginException; 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 javax.jcr.observation.Event; import javax.jcr.observation.EventListener; @@ -38,10 +40,10 @@ import org.argeo.slc.SlcException; import org.argeo.slc.SlcNames; import org.argeo.slc.SlcTypes; import org.argeo.slc.client.ui.SlcImages; -import org.argeo.slc.primitive.PrimitiveAccessor; -import org.argeo.slc.primitive.PrimitiveUtils; import org.argeo.slc.execution.ExecutionProcess; import org.argeo.slc.jcr.SlcJcrUtils; +import org.argeo.slc.primitive.PrimitiveAccessor; +import org.argeo.slc.primitive.PrimitiveUtils; import org.eclipse.jface.viewers.CellEditor; import org.eclipse.jface.viewers.ColumnLabelProvider; import org.eclipse.jface.viewers.ColumnViewer; @@ -96,6 +98,7 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { final static String NONE = ""; private Node processNode; + private Session agentSession; private TreeViewer flowsViewer; private TableViewer valuesViewer; @@ -110,6 +113,11 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { public ProcessBuilderPage(ProcessEditor editor, Node processNode) { super(editor, ID, "Definition"); this.processNode = processNode; + try { + this.agentSession = processNode.getSession().getRepository().login(); + } catch (RepositoryException e) { + throw new SlcException("Cannot open agent session", e); + } } @Override @@ -137,11 +145,9 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { statusChanged(); } }; - ObservationManager observationManager = processNode.getSession() - .getWorkspace().getObservationManager(); - observationManager.addEventListener(statusObserver, - Event.PROPERTY_CHANGED, processNode.getPath(), true, null, - null, false); + ObservationManager observationManager = processNode.getSession().getWorkspace().getObservationManager(); + observationManager.addEventListener(statusObserver, Event.PROPERTY_CHANGED, processNode.getPath(), true, + null, null, false); // make sure all controls are in line with status statusChanged(); @@ -228,16 +234,14 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { flowsComposite.setLayout(new GridLayout(1, false)); flowsViewer = new TreeViewer(flowsComposite); - flowsViewer.getTree().setLayoutData( - new GridData(SWT.FILL, SWT.FILL, true, true)); + flowsViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); flowsViewer.setLabelProvider(new FlowsLabelProvider()); flowsViewer.setContentProvider(new FlowsContentProvider()); flowsViewer.addSelectionChangedListener(new FlowsSelectionListener()); int operations = DND.DROP_COPY | DND.DROP_MOVE; Transfer[] tt = new Transfer[] { TextTransfer.getInstance() }; - flowsViewer.addDropSupport(operations, tt, new FlowsDropListener( - flowsViewer)); + flowsViewer.addDropSupport(operations, tt, new FlowsDropListener(flowsViewer)); // Context menu addContextMenu(); @@ -329,8 +333,7 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { /** Adds initial flows from the editor input if any */ protected void addInitialFlows() { - for (String path : ((ProcessEditorInput) getEditorInput()) - .getInitialFlowPaths()) { + for (String path : ((ProcessEditorInput) getEditorInput()).getInitialFlowPaths()) { addFlow(path); } } @@ -338,42 +341,33 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { /** * Adds a new flow. * - * @param path - * the path of the flow + * @param path the path of the flow */ protected void addFlow(String path) { try { - Node flowNode = processNode.getSession().getNode(path); - Node realizedFlowNode = processNode.getNode(SLC_FLOW).addNode( - SLC_FLOW); - realizedFlowNode.setProperty(SLC_NAME, - flowNode.getProperty(SLC_NAME).getString()); + Node flowNode = agentSession.getNode(path); + Node realizedFlowNode = processNode.getNode(SLC_FLOW).addNode(SLC_FLOW); + realizedFlowNode.setProperty(SLC_NAME, flowNode.getProperty(SLC_NAME).getString()); realizedFlowNode.addMixin(SlcTypes.SLC_REALIZED_FLOW); - Node address = realizedFlowNode.addNode(SLC_ADDRESS, - NodeType.NT_ADDRESS); + Node address = realizedFlowNode.addNode(SLC_ADDRESS, NodeType.NT_ADDRESS); address.setProperty(Property.JCR_PATH, path); // copy spec attributes Node specAttrsBase; if (flowNode.hasProperty(SLC_SPEC)) { - Node executionSpecNode = flowNode.getProperty(SLC_SPEC) - .getNode(); + Node executionSpecNode = flowNode.getProperty(SLC_SPEC).getNode(); specAttrsBase = executionSpecNode; - String executionSpecName = executionSpecNode.getProperty( - SLC_NAME).getString(); + String executionSpecName = executionSpecNode.getProperty(SLC_NAME).getString(); realizedFlowNode.setProperty(SLC_SPEC, executionSpecName); } else specAttrsBase = flowNode; - specAttrs: for (NodeIterator nit = specAttrsBase.getNodes(); nit - .hasNext();) { + specAttrs: for (NodeIterator nit = specAttrsBase.getNodes(); nit.hasNext();) { Node specAttrNode = nit.nextNode(); String attrName = specAttrNode.getName(); - if (!specAttrNode - .isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE)) + if (!specAttrNode.isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE)) continue specAttrs; - Node realizedAttrNode = realizedFlowNode.addNode(specAttrNode - .getName()); + Node realizedAttrNode = realizedFlowNode.addNode(specAttrNode.getName()); JcrUtils.copy(specAttrNode, realizedAttrNode); // override with flow value @@ -381,8 +375,7 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { // assuming this is a primitive Node attrNode = flowNode.getNode(attrName); if (attrNode.hasProperty(SLC_VALUE)) - realizedAttrNode.setProperty(SLC_VALUE, attrNode - .getProperty(SLC_VALUE).getValue()); + realizedAttrNode.setProperty(SLC_VALUE, attrNode.getProperty(SLC_VALUE).getValue()); } } @@ -394,8 +387,7 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { String name = rFlowNode.getProperty(SLC_NAME).getString(); editorTitle.append(name).append(' '); } - ((ProcessEditor) getEditor()) - .setEditorTitle(editorTitle.toString()); + ((ProcessEditor) getEditor()).setEditorTitle(editorTitle.toString()); flowsViewer.refresh(); formPart.markDirty(); @@ -407,8 +399,7 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { @SuppressWarnings("unchecked") protected void removeSelectedFlows() { if (!flowsViewer.getSelection().isEmpty()) { - Iterator it = ((StructuredSelection) flowsViewer - .getSelection()).iterator(); + Iterator it = ((StructuredSelection) flowsViewer.getSelection()).iterator(); while (it.hasNext()) { Node node = (Node) it.next(); try { @@ -424,15 +415,13 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { protected void removeAllFlows() { try { - for (NodeIterator nit = processNode.getNode(SLC_FLOW).getNodes(); nit - .hasNext();) { + for (NodeIterator nit = processNode.getNode(SLC_FLOW).getNodes(); nit.hasNext();) { nit.nextNode().remove(); } flowsViewer.refresh(); formPart.markDirty(); } catch (RepositoryException e) { - throw new SlcException("Cannot remove flows from " + processNode, - e); + throw new SlcException("Cannot remove flows from " + processNode, e); } } @@ -449,20 +438,17 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { try { return processNode.getProperty(SLC_STATUS).getString(); } catch (RepositoryException e) { - throw new SlcException("Cannot retrieve status for " + processNode, - e); + throw new SlcException("Cannot retrieve status for " + processNode, e); } } /** Optimization so that we don't call the node each time */ protected static Boolean isEditable(String status) { - return status.equals(ExecutionProcess.NEW) - || status.equals(ExecutionProcess.INITIALIZED); + return status.equals(ExecutionProcess.NEW) || status.equals(ExecutionProcess.INITIALIZED); } protected static Boolean isFinished(String status) { - return status.equals(ExecutionProcess.COMPLETED) - || status.equals(ExecutionProcess.ERROR) + return status.equals(ExecutionProcess.COMPLETED) || status.equals(ExecutionProcess.ERROR) || status.equals(ExecutionProcess.KILLED); } @@ -476,6 +462,7 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { @Override public void dispose() { JcrUtils.unregisterQuietly(processNode, statusObserver); + JcrUtils.logoutQuietly(agentSession); super.dispose(); } @@ -490,29 +477,24 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { String type = specAttrNode.getProperty(SLC_TYPE).getString(); if (PrimitiveAccessor.TYPE_PASSWORD.equals(type)) return "****************"; - Object value = PrimitiveUtils.convert(type, specAttrNode - .getProperty(SLC_VALUE).getString()); + Object value = PrimitiveUtils.convert(type, specAttrNode.getProperty(SLC_VALUE).getString()); return value.toString(); } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) { if (specAttrNode.hasProperty(SLC_VALUE)) { - int value = (int) specAttrNode.getProperty(SLC_VALUE) - .getLong(); + int value = (int) specAttrNode.getProperty(SLC_VALUE).getLong(); NodeIterator children = specAttrNode.getNodes(); int index = 0; while (children.hasNext()) { Node child = children.nextNode(); if (index == value) - return child.getProperty(Property.JCR_TITLE) - .getString(); + return child.getProperty(Property.JCR_TITLE).getString(); index++; } - throw new SlcException("No child node with index " + value - + " for spec attribute " + specAttrNode); + throw new SlcException("No child node with index " + value + " for spec attribute " + specAttrNode); } else return ""; } - throw new SlcException("Unsupported type for spec attribute " - + specAttrNode); + throw new SlcException("Unsupported type for spec attribute " + specAttrNode); } catch (RepositoryException e) { throw new SlcException("Cannot get value", e); } @@ -529,8 +511,7 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { try { Node node = (Node) obj; List children = new ArrayList(); - for (NodeIterator nit = node.getNode(SLC_FLOW).getNodes(); nit - .hasNext();) { + for (NodeIterator nit = node.getNode(SLC_FLOW).getNodes(); nit.hasNext();) { Node flowNode = nit.nextNode(); children.add(flowNode); } @@ -568,16 +549,13 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { try { if (node.isNodeType(SlcTypes.SLC_REALIZED_FLOW)) { if (node.hasNode(SLC_ADDRESS)) { - String path = node.getNode(SLC_ADDRESS) - .getProperty(Property.JCR_PATH).getString(); - String executionModuleName = SlcJcrUtils - .moduleName(path); + String path = node.getNode(SLC_ADDRESS).getProperty(Property.JCR_PATH).getString(); + String executionModuleName = SlcJcrUtils.moduleName(path); // Node executionModuleNode = node.getSession().getNode( // SlcJcrUtils.modulePath(path)); // String executionModuleName = executionModuleNode // .getProperty(SLC_NAME).getString(); - return executionModuleName + ":" - + SlcJcrUtils.flowRelativePath(path); + return executionModuleName + ":" + SlcJcrUtils.flowRelativePath(path); } } } catch (RepositoryException e) { @@ -592,13 +570,11 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { try { if (node.isNodeType(SlcTypes.SLC_REALIZED_FLOW)) { if (node.hasProperty(SLC_STATUS)) { - String status = node.getProperty(SLC_STATUS) - .getString(); + String status = node.getProperty(SLC_STATUS).getString(); // TODO: factorize with process view ? if (status.equals(ExecutionProcess.RUNNING)) return SlcImages.PROCESS_RUNNING; - else if (status.equals(ExecutionProcess.ERROR) - || status.equals(ExecutionProcess.KILLED)) + else if (status.equals(ExecutionProcess.ERROR) || status.equals(ExecutionProcess.KILLED)) return SlcImages.PROCESS_ERROR; else if (status.equals(ExecutionProcess.COMPLETED)) return SlcImages.PROCESS_COMPLETED; @@ -620,8 +596,7 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { valuesViewer.setInput(getEditorSite()); return; } - Node realizedFlowNode = (Node) ((IStructuredSelection) evt - .getSelection()).getFirstElement(); + Node realizedFlowNode = (Node) ((IStructuredSelection) evt.getSelection()).getFirstElement(); valuesViewer.setInput(realizedFlowNode); } } @@ -676,25 +651,20 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { for (String path : paths) { try { // either a node or a whole directory can have been dragged - QueryManager qm = processNode.getSession().getWorkspace() - .getQueryManager(); - String statement = "SELECT * FROM [" - + SlcTypes.SLC_EXECUTION_FLOW - + "] WHERE ISDESCENDANTNODE(['" + path - + "']) OR ISSAMENODE(['" + path + "'])"; + QueryManager qm = processNode.getSession().getWorkspace().getQueryManager(); + String statement = "SELECT * FROM [" + SlcTypes.SLC_EXECUTION_FLOW + "] WHERE ISDESCENDANTNODE(['" + + path + "']) OR ISSAMENODE(['" + path + "'])"; Query query = qm.createQuery(statement, Query.JCR_SQL2); // order paths - for (NodeIterator nit = query.execute().getNodes(); nit - .hasNext();) { + for (NodeIterator nit = query.execute().getNodes(); nit.hasNext();) { String currPath = nit.nextNode().getPath(); // do not add twice a same flow if (!resultPaths.contains(currPath)) resultPaths.add(currPath); } } catch (RepositoryException e) { - throw new SlcException("Cannot query flows under " + path, - e); + throw new SlcException("Cannot query flows under " + path, e); } } for (String p : resultPaths) { @@ -705,8 +675,7 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { } @Override - public boolean validateDrop(Object target, int operation, - TransferData transferType) { + public boolean validateDrop(Object target, int operation, TransferData transferType) { return isEditable(getProcessStatus()); } } @@ -723,17 +692,14 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { try { Node realizedFlowNode = (Node) inputElement; List specAttributes = new ArrayList(); - specAttrs: for (NodeIterator nit = realizedFlowNode.getNodes(); nit - .hasNext();) { + specAttrs: for (NodeIterator nit = realizedFlowNode.getNodes(); nit.hasNext();) { Node specAttrNode = nit.nextNode(); - if (!specAttrNode - .isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE)) + if (!specAttrNode.isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE)) continue specAttrs; // workaround to enable hiding of necessary but unusable // flow parameters else if (specAttrNode.hasProperty(SlcNames.SLC_IS_HIDDEN) - && specAttrNode.getProperty(SlcNames.SLC_IS_HIDDEN) - .getBoolean()) + && specAttrNode.getProperty(SlcNames.SLC_IS_HIDDEN).getBoolean()) continue specAttrs; specAttributes.add(specAttrNode); } @@ -762,28 +728,22 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { protected CellEditor getCellEditor(Object element) { try { Node specAttrNode = (Node) element; - if (specAttrNode - .isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) { - String type = specAttrNode.getProperty(SLC_TYPE) - .getString(); + if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) { + String type = specAttrNode.getProperty(SLC_TYPE).getString(); if (PrimitiveAccessor.TYPE_PASSWORD.equals(type)) { - return new TextCellEditor(tableViewer.getTable(), - SWT.PASSWORD); + return new TextCellEditor(tableViewer.getTable(), SWT.PASSWORD); } else { return new TextCellEditor(tableViewer.getTable()); } - } else if (specAttrNode - .isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) { + } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) { NodeIterator children = specAttrNode.getNodes(); ArrayList items = new ArrayList(); while (children.hasNext()) { Node child = children.nextNode(); if (child.isNodeType(NodeType.MIX_TITLE)) - items.add(child.getProperty(Property.JCR_TITLE) - .getString()); + items.add(child.getProperty(Property.JCR_TITLE).getString()); } - return new ComboBoxCellEditor(tableViewer.getTable(), - items.toArray(new String[items.size()])); + return new ComboBoxCellEditor(tableViewer.getTable(), items.toArray(new String[items.size()])); } return null; } catch (RepositoryException e) { @@ -795,14 +755,11 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { protected boolean canEdit(Object element) { try { Node specAttrNode = (Node) element; - Boolean cannotEdit = specAttrNode.getProperty(SLC_IS_IMMUTABLE) - .getBoolean() - || specAttrNode.getProperty(SLC_IS_CONSTANT) - .getBoolean(); + Boolean cannotEdit = specAttrNode.getProperty(SLC_IS_IMMUTABLE).getBoolean() + || specAttrNode.getProperty(SLC_IS_CONSTANT).getBoolean(); return !cannotEdit && isSupportedAttributeType(specAttrNode); } catch (RepositoryException e) { - throw new SlcException("Cannot check whether " + element - + " is editable", e); + throw new SlcException("Cannot check whether " + element + " is editable", e); } } @@ -810,10 +767,8 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { * Supports {@link SlcTypes#SLC_PRIMITIVE_SPEC_ATTRIBUTE} and * {@link SlcTypes#SLC_REF_SPEC_ATTRIBUTE} */ - protected boolean isSupportedAttributeType(Node specAttrNode) - throws RepositoryException { - return specAttrNode - .isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE) + protected boolean isSupportedAttributeType(Node specAttrNode) throws RepositoryException { + return specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE) || specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE); } @@ -821,26 +776,21 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { protected Object getValue(Object element) { Node specAttrNode = (Node) element; try { - if (specAttrNode - .isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) { + if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) { if (!specAttrNode.hasProperty(SLC_VALUE)) return NONE; - String type = specAttrNode.getProperty(SLC_TYPE) - .getString(); + String type = specAttrNode.getProperty(SLC_TYPE).getString(); // TODO optimize based on data type? - Object value = PrimitiveUtils.convert(type, specAttrNode - .getProperty(SLC_VALUE).getString()); + Object value = PrimitiveUtils.convert(type, specAttrNode.getProperty(SLC_VALUE).getString()); return value.toString(); - } else if (specAttrNode - .isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) { + } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) { if (!specAttrNode.hasProperty(SLC_VALUE)) return 0; // return the index of the sub node as set by setValue() // in the future we may manage references as well return (int) specAttrNode.getProperty(SLC_VALUE).getLong(); } - throw new SlcException("Unsupported type for spec attribute " - + specAttrNode); + throw new SlcException("Unsupported type for spec attribute " + specAttrNode); } catch (RepositoryException e) { throw new SlcException("Cannot get value for " + element, e); } @@ -850,18 +800,13 @@ public class ProcessBuilderPage extends FormPage implements SlcNames { protected void setValue(Object element, Object value) { try { Node specAttrNode = (Node) element; - if (specAttrNode - .isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) { - String type = specAttrNode.getProperty(SLC_TYPE) - .getString(); - SlcJcrUtils.setPrimitiveAsProperty(specAttrNode, SLC_VALUE, - type, value); + if (specAttrNode.isNodeType(SlcTypes.SLC_PRIMITIVE_SPEC_ATTRIBUTE)) { + String type = specAttrNode.getProperty(SLC_TYPE).getString(); + SlcJcrUtils.setPrimitiveAsProperty(specAttrNode, SLC_VALUE, type, value); valuesViewer.refresh(); formPart.markDirty(); - } else if (specAttrNode - .isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) { - specAttrNode.setProperty(SLC_VALUE, - ((Integer) value).longValue()); + } else if (specAttrNode.isNodeType(SlcTypes.SLC_REF_SPEC_ATTRIBUTE)) { + specAttrNode.setProperty(SLC_VALUE, ((Integer) value).longValue()); valuesViewer.refresh(); formPart.markDirty(); } diff --git a/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditor.java b/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditor.java index e0ff78589..4546ee9d8 100644 --- a/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditor.java +++ b/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditor.java @@ -26,6 +26,7 @@ import javax.jcr.Repository; import javax.jcr.RepositoryException; import javax.jcr.Session; +import org.argeo.api.NodeConstants; import org.argeo.eclipse.ui.dialogs.ErrorFeedback; import org.argeo.jcr.JcrUtils; import org.argeo.slc.SlcException; @@ -52,7 +53,8 @@ public class ProcessEditor extends FormEditor implements SlcTypes, SlcNames { public final static String ID = ClientUiPlugin.ID + ".processEditor"; private Repository repository; - private Session session; + private Session homeSession; + private Session agentSession; private Node processNode; private ProcessController processController; private ServerPushSession pushSession; @@ -62,13 +64,13 @@ public class ProcessEditor extends FormEditor implements SlcTypes, SlcNames { private ExecutionModulesManager modulesManager; @Override - public void init(IEditorSite site, IEditorInput input) - throws PartInitException { + public void init(IEditorSite site, IEditorInput input) throws PartInitException { super.init(site, input); pushSession = new ServerPushSession(); pushSession.start(); try { - session = repository.login(); + homeSession = repository.login(NodeConstants.HOME); + agentSession = repository.login(); } catch (RepositoryException e1) { throw new SlcException("Cannot log in to repository"); } @@ -77,10 +79,9 @@ public class ProcessEditor extends FormEditor implements SlcTypes, SlcNames { String processPath = pei.getProcessPath(); try { if (processPath != null) { - if (!session.itemExists(processPath)) - throw new SlcException("Process " + processPath - + " does not exist"); - processNode = session.getNode(processPath); + if (!homeSession.itemExists(processPath)) + throw new SlcException("Process " + processPath + " does not exist"); + processNode = homeSession.getNode(processPath); } else {// new processNode = newProcessNode(pei); } @@ -91,12 +92,10 @@ public class ProcessEditor extends FormEditor implements SlcTypes, SlcNames { } - protected Node newProcessNode(ProcessEditorInput pei) - throws RepositoryException { + protected Node newProcessNode(ProcessEditorInput pei) throws RepositoryException { String uuid = UUID.randomUUID().toString(); - String processPath = SlcJcrUtils.createExecutionProcessPath(session, - uuid); - Node processNode = JcrUtils.mkdirs(session, processPath, SLC_PROCESS); + String processPath = SlcJcrUtils.createExecutionProcessPath(homeSession, uuid); + Node processNode = JcrUtils.mkdirs(homeSession, processPath, SLC_PROCESS); processNode.setProperty(SLC_UUID, uuid); processNode.setProperty(SLC_STATUS, ExecutionProcess.NEW); Node processFlow = processNode.addNode(SLC_FLOW); @@ -115,14 +114,14 @@ public class ProcessEditor extends FormEditor implements SlcTypes, SlcNames { try { return processNode.getProperty(SLC_STATUS).getString(); } catch (RepositoryException e) { - throw new SlcException("Cannot retrieve status for " + processNode, - e); + throw new SlcException("Cannot retrieve status for " + processNode, e); } } @Override public void dispose() { - JcrUtils.logoutQuietly(session); + JcrUtils.logoutQuietly(homeSession); + JcrUtils.logoutQuietly(agentSession); if (pushSession != null) pushSession.stop(); super.dispose(); @@ -142,30 +141,22 @@ public class ProcessEditor extends FormEditor implements SlcTypes, SlcNames { try { // make sure modules are started for all nodes - for (NodeIterator nit = processNode.getNode(SLC_FLOW).getNodes(); nit - .hasNext();) { + for (NodeIterator nit = processNode.getNode(SLC_FLOW).getNodes(); nit.hasNext();) { Node flowNode = nit.nextNode(); try { - String flowDefPath = flowNode.getNode(SLC_ADDRESS) - .getProperty(Property.JCR_PATH).getString(); - Node executionModuleNode = flowNode.getSession().getNode( - SlcJcrUtils.modulePath(flowDefPath)); - if (!executionModuleNode.getProperty(SLC_STARTED) - .getBoolean()) - ClientUiPlugin.startStopExecutionModule(modulesManager, - executionModuleNode); + String flowDefPath = flowNode.getNode(SLC_ADDRESS).getProperty(Property.JCR_PATH).getString(); + Node executionModuleNode = agentSession.getNode(SlcJcrUtils.modulePath(flowDefPath)); + if (!executionModuleNode.getProperty(SLC_STARTED).getBoolean()) + ClientUiPlugin.startStopExecutionModule(modulesManager, executionModuleNode); } catch (Exception e) { - ErrorFeedback.show( - "Cannot start execution module related to " - + flowNode, e); + ErrorFeedback.show("Cannot start execution module related to " + flowNode, e); } } // Actually process ExecutionProcess process = processController.process(processNode); Map properties = new HashMap(); - properties.put(ExecutionModulesManager.SLC_PROCESS_ID, - process.getUuid()); + properties.put(ExecutionModulesManager.SLC_PROCESS_ID, process.getUuid()); // modulesManager.registerProcessNotifier(this, properties); } catch (Exception e) { ErrorFeedback.show("Execution of " + processNode + " failed", e); @@ -180,11 +171,8 @@ public class ProcessEditor extends FormEditor implements SlcTypes, SlcNames { void relaunch() { try { Node duplicatedNode = duplicateProcess(); - IWorkbenchPage activePage = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage(); - activePage.openEditor( - new ProcessEditorInput(duplicatedNode.getPath()), - ProcessEditor.ID); + IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + activePage.openEditor(new ProcessEditorInput(duplicatedNode.getPath()), ProcessEditor.ID); close(false); } catch (Exception e1) { throw new SlcException("Cannot relaunch " + processNode, e1); @@ -196,10 +184,8 @@ public class ProcessEditor extends FormEditor implements SlcTypes, SlcNames { try { Session session = processNode.getSession(); String uuid = UUID.randomUUID().toString(); - String destPath = SlcJcrUtils.createExecutionProcessPath(session, - uuid); - Node newNode = JcrUtils.mkdirs(session, destPath, - SlcTypes.SLC_PROCESS); + String destPath = SlcJcrUtils.createExecutionProcessPath(session, uuid); + Node newNode = JcrUtils.mkdirs(session, destPath, SlcTypes.SLC_PROCESS); Node rootRealizedFlowNode = newNode.addNode(SLC_FLOW); // copy node @@ -212,8 +198,7 @@ public class ProcessEditor extends FormEditor implements SlcTypes, SlcNames { // we just manage one level for the time being NodeIterator nit = rootRealizedFlowNode.getNodes(SLC_FLOW); while (nit.hasNext()) { - nit.nextNode().setProperty(SLC_STATUS, - ExecutionProcess.INITIALIZED); + nit.nextNode().setProperty(SLC_STATUS, ExecutionProcess.INITIALIZED); } session.save(); @@ -240,9 +225,8 @@ public class ProcessEditor extends FormEditor implements SlcTypes, SlcNames { try { String status = processNode.getProperty(SLC_STATUS).getString(); if (status.equals(ExecutionProcess.NEW)) - processNode.setProperty(SLC_STATUS, - ExecutionProcess.INITIALIZED); - session.save(); + processNode.setProperty(SLC_STATUS, ExecutionProcess.INITIALIZED); + homeSession.save(); builderPage.commit(true); editorDirtyStateChanged(); } catch (RepositoryException e) { diff --git a/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrProcessListView.java b/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrProcessListView.java index 4e2cf8015..696b39b72 100644 --- a/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrProcessListView.java +++ b/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrProcessListView.java @@ -31,6 +31,7 @@ import javax.jcr.observation.EventListener; import javax.jcr.observation.ObservationManager; import javax.jcr.query.Query; +import org.argeo.api.NodeConstants; import org.argeo.eclipse.ui.jcr.AsyncUiEventListener; import org.argeo.jcr.JcrUtils; import org.argeo.slc.SlcException; @@ -72,18 +73,16 @@ public class JcrProcessListView extends ViewPart { private EventListener processesObserver; - private DateFormat dateFormat = new SimpleDateFormat( - "EEE, dd MMM yyyy HH:mm:ss"); + private DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss"); private Integer queryLimit = 2000; public void createPartControl(Composite parent) { pushSession = new ServerPushSession(); pushSession.start(); try { - session = repository.login(); + session = repository.login(NodeConstants.HOME); } catch (RepositoryException re) { - throw new SlcException("Unable to log in Repository " + repository, - re); + throw new SlcException("Unable to log in Repository " + repository, re); } Table table = createTable(parent); viewer = new TableViewer(table); @@ -92,21 +91,17 @@ public class JcrProcessListView extends ViewPart { viewer.setInput(getViewSite()); viewer.addDoubleClickListener(new ViewDoubleClickListener()); - processesObserver = new AsyncUiEventListener(viewer.getTable() - .getDisplay()) { + processesObserver = new AsyncUiEventListener(viewer.getTable().getDisplay()) { protected void onEventInUiThread(List events) { // TODO optimize by updating only the changed process viewer.refresh(); } }; try { - ObservationManager observationManager = session.getWorkspace() - .getObservationManager(); + ObservationManager observationManager = session.getWorkspace().getObservationManager(); observationManager.addEventListener(processesObserver, - Event.NODE_ADDED | Event.NODE_REMOVED - | Event.PROPERTY_CHANGED, - SlcJcrUtils.getSlcProcessesBasePath(session), true, null, - null, false); + Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_CHANGED, + SlcJcrUtils.getSlcProcessesBasePath(session), true, null, null, false); } catch (RepositoryException e) { throw new SlcException("Cannot register listeners", e); } @@ -114,8 +109,7 @@ public class JcrProcessListView extends ViewPart { } protected Table createTable(Composite parent) { - int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL - | SWT.FULL_SELECTION; + int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION; // does not function with RAP, commented for the time being // | SWT.HIDE_SELECTION; @@ -153,13 +147,11 @@ public class JcrProcessListView extends ViewPart { try { // TODO filter, optimize with virtual table, ... String sql = "SELECT * from [slc:process] ORDER BY [jcr:lastModified] DESC"; - Query query = session.getWorkspace().getQueryManager() - .createQuery(sql, Query.JCR_SQL2); + Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2); // TODO paging query.setLimit(queryLimit); List nodes = new ArrayList(); - for (NodeIterator nit = query.execute().getNodes(); nit - .hasNext();) { + for (NodeIterator nit = query.execute().getNodes(); nit.hasNext();) { nodes.add(nit.nextNode()); } return nodes.toArray(); @@ -176,22 +168,18 @@ public class JcrProcessListView extends ViewPart { } - class LabelProvider extends ColumnLabelProvider implements - ITableLabelProvider { + class LabelProvider extends ColumnLabelProvider implements ITableLabelProvider { public Image getColumnImage(Object obj, int columnIndex) { if (columnIndex != 0) return null; try { Node node = (Node) obj; - String status = node.getProperty(SlcNames.SLC_STATUS) - .getString(); - if (status.equals(ExecutionProcess.NEW) - || status.equals(ExecutionProcess.INITIALIZED) + String status = node.getProperty(SlcNames.SLC_STATUS).getString(); + if (status.equals(ExecutionProcess.NEW) || status.equals(ExecutionProcess.INITIALIZED) || status.equals(ExecutionProcess.SCHEDULED)) return SlcImages.PROCESS_SCHEDULED; - else if (status.equals(ExecutionProcess.ERROR) - || status.equals(ExecutionProcess.UNKOWN)) + else if (status.equals(ExecutionProcess.ERROR) || status.equals(ExecutionProcess.UNKOWN)) return SlcImages.PROCESS_ERROR; else if (status.equals(ExecutionProcess.COMPLETED)) return SlcImages.PROCESS_COMPLETED; @@ -212,9 +200,7 @@ public class JcrProcessListView extends ViewPart { switch (index) { case 0: - return dateFormat.format(node - .getProperty(Property.JCR_LAST_MODIFIED).getDate() - .getTime()); + return dateFormat.format(node.getProperty(Property.JCR_LAST_MODIFIED).getDate().getTime()); case 1: return "local"; case 2: @@ -232,17 +218,14 @@ public class JcrProcessListView extends ViewPart { class ViewDoubleClickListener implements IDoubleClickListener { public void doubleClick(DoubleClickEvent evt) { - Object obj = ((IStructuredSelection) evt.getSelection()) - .getFirstElement(); + Object obj = ((IStructuredSelection) evt.getSelection()).getFirstElement(); try { if (obj instanceof Node) { Node node = (Node) obj; if (node.isNodeType(SlcTypes.SLC_PROCESS)) { - IWorkbenchPage activePage = PlatformUI.getWorkbench() - .getActiveWorkbenchWindow().getActivePage(); - activePage.openEditor( - new ProcessEditorInput(node.getPath()), - ProcessEditor.ID); + IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getActivePage(); + activePage.openEditor(new ProcessEditorInput(node.getPath()), ProcessEditor.ID); } } } catch (Exception e) { diff --git a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrProcessThread.java b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrProcessThread.java index 56b97d02e..d87649d6a 100644 --- a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrProcessThread.java +++ b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrProcessThread.java @@ -22,6 +22,7 @@ import javax.jcr.Node; import javax.jcr.RepositoryException; import javax.jcr.Session; +import org.argeo.api.NodeConstants; import org.argeo.jcr.JcrUtils; import org.argeo.slc.SlcException; import org.argeo.slc.SlcNames; @@ -33,8 +34,7 @@ import org.argeo.slc.runtime.ProcessThread; /** Where the actual execution takes place */ public class JcrProcessThread extends ProcessThread implements SlcNames { - public JcrProcessThread(ThreadGroup processesThreadGroup, - ExecutionModulesManager executionModulesManager, + public JcrProcessThread(ThreadGroup processesThreadGroup, ExecutionModulesManager executionModulesManager, JcrExecutionProcess process) { super(processesThreadGroup, executionModulesManager, process); } @@ -45,14 +45,11 @@ public class JcrProcessThread extends ProcessThread implements SlcNames { Session session = null; if (getProcess() instanceof JcrExecutionProcess) try { - session = ((JcrExecutionProcess) getProcess()).getRepository() - .login(); + session = ((JcrExecutionProcess) getProcess()).getRepository().login(NodeConstants.HOME); - List realizedFlows = getProcess() - .getRealizedFlows(); + List realizedFlows = getProcess().getRealizedFlows(); for (RealizedFlow realizedFlow : realizedFlows) { - Node realizedFlowNode = session - .getNode(((JcrRealizedFlow) realizedFlow).getPath()); + Node realizedFlowNode = session.getNode(((JcrRealizedFlow) realizedFlow).getPath()); setFlowStatus(realizedFlowNode, ExecutionProcess.RUNNING); try { @@ -61,8 +58,7 @@ public class JcrProcessThread extends ProcessThread implements SlcNames { // execute(realizedFlow, true); - setFlowStatus(realizedFlowNode, - ExecutionProcess.COMPLETED); + setFlowStatus(realizedFlowNode, ExecutionProcess.COMPLETED); } catch (RepositoryException e) { throw e; } catch (InterruptedException e) { @@ -74,8 +70,7 @@ public class JcrProcessThread extends ProcessThread implements SlcNames { } } } catch (RepositoryException e) { - throw new SlcException("Cannot process " - + getJcrExecutionProcess().getNodePath(), e); + throw new SlcException("Cannot process " + getJcrExecutionProcess().getNodePath(), e); } finally { JcrUtils.logoutQuietly(session); } @@ -83,8 +78,7 @@ public class JcrProcessThread extends ProcessThread implements SlcNames { super.process(); } - protected void setFlowStatus(Node realizedFlowNode, String status) - throws RepositoryException { + protected void setFlowStatus(Node realizedFlowNode, String status) throws RepositoryException { realizedFlowNode.setProperty(SLC_STATUS, status); realizedFlowNode.getSession().save(); } diff --git a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrRealizedFlow.java b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrRealizedFlow.java index e8f0145f0..b7444d44c 100644 --- a/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrRealizedFlow.java +++ b/org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrRealizedFlow.java @@ -7,7 +7,9 @@ import javax.jcr.Node; import javax.jcr.NodeIterator; import javax.jcr.Property; import javax.jcr.RepositoryException; +import javax.jcr.Session; +import org.argeo.jcr.JcrUtils; import org.argeo.slc.SlcException; import org.argeo.slc.SlcNames; import org.argeo.slc.SlcTypes; @@ -38,41 +40,47 @@ public class JcrRealizedFlow extends RealizedFlow implements SlcNames { String flowPath = realizedFlowNode.getNode(SLC_ADDRESS).getProperty(Property.JCR_PATH).getString(); // TODO: convert to local path if remote // FIXME start related module - Node flowNode = realizedFlowNode.getSession().getNode(flowPath); - String flowName = flowNode.getProperty(SLC_NAME).getString(); - String description = null; - if (flowNode.hasProperty(Property.JCR_DESCRIPTION)) - description = flowNode.getProperty(Property.JCR_DESCRIPTION).getString(); + Session agentSession = realizedFlowNode.getSession().getRepository().login(); + try { + Node flowNode = agentSession.getNode(flowPath); + String flowName = flowNode.getProperty(SLC_NAME).getString(); + String description = null; + if (flowNode.hasProperty(Property.JCR_DESCRIPTION)) + description = flowNode.getProperty(Property.JCR_DESCRIPTION).getString(); - Node executionModuleNode = flowNode.getSession().getNode(SlcJcrUtils.modulePath(flowPath)); - String executionModuleName = executionModuleNode.getProperty(SLC_NAME).getString(); - String executionModuleVersion = executionModuleNode.getProperty(SLC_VERSION).getString(); + Node executionModuleNode = flowNode.getSession().getNode(SlcJcrUtils.modulePath(flowPath)); + String executionModuleName = executionModuleNode.getProperty(SLC_NAME).getString(); + String executionModuleVersion = executionModuleNode.getProperty(SLC_VERSION).getString(); - RealizedFlow realizedFlow = this; - realizedFlow.setModuleName(executionModuleName); - realizedFlow.setModuleVersion(executionModuleVersion); + RealizedFlow realizedFlow = this; + realizedFlow.setModuleName(executionModuleName); + realizedFlow.setModuleVersion(executionModuleVersion); - // retrieve execution spec - DefaultExecutionSpec executionSpec = new DefaultExecutionSpec(); - Map attrs = readExecutionSpecAttributes(realizedFlowNode); - executionSpec.setAttributes(attrs); + // retrieve execution spec + DefaultExecutionSpec executionSpec = new DefaultExecutionSpec(); + Map attrs = readExecutionSpecAttributes(realizedFlowNode); + executionSpec.setAttributes(attrs); - // set execution spec name - if (flowNode.hasProperty(SlcNames.SLC_SPEC)) { - Node executionSpecNode = flowNode.getProperty(SLC_SPEC).getNode(); - executionSpec.setName(executionSpecNode.getProperty(SLC_NAME).getString()); - } + // set execution spec name + if (flowNode.hasProperty(SlcNames.SLC_SPEC)) { + Node executionSpecNode = flowNode.getProperty(SLC_SPEC).getNode(); + executionSpec.setName(executionSpecNode.getProperty(SLC_NAME).getString()); + } - // explicitly retrieve values - Map values = new HashMap(); - for (String attrName : attrs.keySet()) { - ExecutionSpecAttribute attr = attrs.get(attrName); - Object value = attr.getValue(); - values.put(attrName, value); - } + // explicitly retrieve values + Map values = new HashMap(); + for (String attrName : attrs.keySet()) { + ExecutionSpecAttribute attr = attrs.get(attrName); + Object value = attr.getValue(); + values.put(attrName, value); + } + + ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor(flowName, description, values, executionSpec); + realizedFlow.setFlowDescriptor(efd); - ExecutionFlowDescriptor efd = new ExecutionFlowDescriptor(flowName, description, values, executionSpec); - realizedFlow.setFlowDescriptor(efd); + } finally { + JcrUtils.logoutQuietly(agentSession); + } } else { throw new SlcException("Unsupported realized flow " + realizedFlowNode); } diff --git a/org.argeo.slc.repo/bnd.bnd b/org.argeo.slc.repo/bnd.bnd index 43b20ebc2..07af6b4f5 100644 --- a/org.argeo.slc.repo/bnd.bnd +++ b/org.argeo.slc.repo/bnd.bnd @@ -9,8 +9,7 @@ org.osgi.*;version=0.0.0,\ Private-Package: org.eclipse.aether.* -Require-Capability: cms.datamodel; filter:="(name=node)",\ -cms.datamodel; filter:="(name=slc)" +Require-Capability: cms.datamodel; filter:="(name=slc)" Provide-Capability: cms.datamodel; name=java,\ cms.datamodel; name=dist,\ cms.datamodel; name=docs,\ diff --git a/org.argeo.slc.spring/bnd.bnd b/org.argeo.slc.spring/bnd.bnd index 2b27e378d..7d7a35cfd 100644 --- a/org.argeo.slc.spring/bnd.bnd +++ b/org.argeo.slc.spring/bnd.bnd @@ -1,6 +1,6 @@ Import-Package: javax.jcr.nodetype,\ javax.jcr.security,\ -org.argeo.node,\ +org.argeo.api,\ org.apache.tools.ant.*;resolution:="optional",\ junit.framework;resolution:="optional",\ org.osgi.*;version=0.0.0,\ -- 2.39.2