Adapt to changes in Argeo Commons.
authorMathieu Baudier <mbaudier@argeo.org>
Fri, 13 Mar 2020 07:10:48 +0000 (08:10 +0100)
committerMathieu Baudier <mbaudier@argeo.org>
Fri, 13 Mar 2020 07:10:48 +0000 (08:10 +0100)
16 files changed:
legacy/argeo-commons/org.argeo.cms.ui.workbench/META-INF/spring/osgi.xml
legacy/argeo-commons/org.argeo.cms.ui.workbench/bnd.bnd
org.argeo.slc.client.rap/META-INF/spring/osgi.xml
org.argeo.slc.client.rap/bnd.bnd
org.argeo.slc.client.ui.dist/META-INF/spring/osgi.xml
org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/DistTreeContentProvider.java
org.argeo.slc.client.ui/META-INF/spring/osgi.xml
org.argeo.slc.client.ui/bnd.bnd
org.argeo.slc.client.ui/pom.xml
org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessBuilderPage.java
org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/editors/ProcessEditor.java
org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/views/JcrProcessListView.java
org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrProcessThread.java
org.argeo.slc.jcr/src/org/argeo/slc/jcr/execution/JcrRealizedFlow.java
org.argeo.slc.repo/bnd.bnd
org.argeo.slc.spring/bnd.bnd

index 36c8e2f4ec227a3131161a0ed06051e87c6962dd..da9785e5d563aabf9a0cbcfb5d4358ec6bf3a187 100644 (file)
@@ -18,7 +18,7 @@
        </list>\r
 \r
        <reference id="nodeRepository" interface="javax.jcr.Repository"\r
-               filter="(cn=home)" />\r
+               filter="(cn=ego)" />\r
                \r
        <reference id="nodeInstance" interface="org.argeo.api.NodeInstance" />\r
 \r
index da2875c31ce73ddfb33907c2d5ed2253f8f87183..d485eeb9d54425ad9caf8bb70533f86813178129 100644 (file)
@@ -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,\
index baa7f2d899c45ecb6c317b12b1a8cc3e34ed7e8f..149c7a2bd504ad096bbbc5dd8ddd10e4f023a528 100644 (file)
@@ -13,5 +13,5 @@
        <reference id="nodeRepository" interface="javax.jcr.Repository"\r
                filter="(cn=node)" />\r
        <reference id="repositoryFactory" interface="javax.jcr.RepositoryFactory" />\r
-       <reference id="keyring" interface="org.argeo.node.security.CryptoKeyring" />\r
+       <reference id="keyring" interface="org.argeo.api.security.CryptoKeyring" />\r
 </beans:beans>\r
index 87118c0431e4b8cdae513f9f303d4e0de9e1ab2d..7b46665dffa36e6383830d09eb02e363a9b469ef 100644 (file)
@@ -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
index 48e9a1b6227b1a6ca862db176242c469d4507da1..324c66f8bda2f11a5eefc46d053b46bb08be512e 100644 (file)
@@ -15,7 +15,7 @@
        <reference id="keyring" interface="org.argeo.api.security.CryptoKeyring" />\r
 \r
        <reference id="nodeRepository" interface="javax.jcr.Repository"\r
-               filter="(cn=home)" />\r
+               filter="(cn=ego)" />\r
 \r
        <reference id="slcRepoManager" interface="org.argeo.slc.repo.SlcRepoManager" />\r
 </beans:beans>
\ No newline at end of file
index f1858d3d9bc93b83044ddb04979024ada16284b5..3b378e953837eb3f0eb2623d58f96594d99e1004 100644 (file)
@@ -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();
 
index b27a065599635e2763a700361b4baeebe94cb981..79eb6bc86ec0f5a71e39e1dbf0068741c4b9d047 100644 (file)
@@ -12,7 +12,7 @@
 \r
        <!-- REFERENCES -->\r
        <reference id="repository" interface="javax.jcr.Repository"\r
-               filter="(cn=home)" />\r
+               filter="(cn=ego)" />\r
 \r
        <reference id="agent" interface="org.argeo.slc.execution.SlcAgent" />\r
 \r
index 497210cbc2e6d7b51ea1be8b738c3ce8c75f2c54..d24c331e7cf1ffb0a55cfdd26c7fda3036e80b5b 100644 (file)
@@ -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,\
 *
index f4571db4c4ae926a32385cb8b2955eebe0eb65d7..951a43792c403966250c11b629045f463f68be40 100644 (file)
                </dependency>
 
                <!-- Argeo Commons -->
+               <dependency>
+                       <groupId>org.argeo.commons</groupId>
+                       <artifactId>org.argeo.api</artifactId>
+                       <version>${version.argeo-commons}</version>
+               </dependency>
                <dependency>
                        <groupId>org.argeo.commons</groupId>
                        <artifactId>org.argeo.eclipse.ui</artifactId>
index 638d3a2d238280e704dab5a7305d4ebd67208b0c..b83b8d82076e36526492d01e10a59534793f3a06 100644 (file)
@@ -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 = "<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<Object> it = ((StructuredSelection) flowsViewer
-                                       .getSelection()).iterator();
+                       Iterator<Object> 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<Node> children = new ArrayList<Node>();
-                               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<Node> specAttributes = new ArrayList<Node>();
-                               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<String> items = new ArrayList<String>();
                                        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();
                                }
index e0ff7858950ac85fa3537639444dbfff9bad87fa..4546ee9d8bfff05c00f30ef821c7e75c5d9e25cc 100644 (file)
@@ -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<String, String> properties = new HashMap<String, String>();
-                       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) {
index 4e2cf8015b37c3d42c81be47dbc06bff66118571..696b39b722791fb67dd7f38c3231b6b4e42ab559 100644 (file)
@@ -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<Event> 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<Node> nodes = new ArrayList<Node>();
-                               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) {
index 56b97d02e7aa550a98e63126efb6a959195f9bd5..d87649d6ac6834e678d93de69a82d424f2e59b45 100644 (file)
@@ -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<RealizedFlow> realizedFlows = getProcess()
-                                               .getRealizedFlows();
+                               List<RealizedFlow> 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();
        }
index e8f0145f0481dea3792ec846c6e3bcba479652b5..b7444d44cef9d055a4d6137583b000857b4bbf5c 100644 (file)
@@ -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<String, ExecutionSpecAttribute> attrs = readExecutionSpecAttributes(realizedFlowNode);
-                       executionSpec.setAttributes(attrs);
+                               // retrieve execution spec
+                               DefaultExecutionSpec executionSpec = new DefaultExecutionSpec();
+                               Map<String, ExecutionSpecAttribute> 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<String, Object> values = new HashMap<String, Object>();
-                       for (String attrName : attrs.keySet()) {
-                               ExecutionSpecAttribute attr = attrs.get(attrName);
-                               Object value = attr.getValue();
-                               values.put(attrName, value);
-                       }
+                               // explicitly retrieve values
+                               Map<String, Object> values = new HashMap<String, Object>();
+                               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);
                }
index 43b20ebc27bb0393c768d088ac944e3f0246ea58..07af6b4f50e4cd14a13826f1104e8c739776896a 100644 (file)
@@ -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,\
index 2b27e378d6b745dae1051d629706dfd9d2c4ccdf..7d7a35cfd94907a8fa85b0de8c54f3b07087e628 100644 (file)
@@ -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,\