</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
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,\
<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
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
<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
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;
try {
if (nodeSession != null)
dispose();
- nodeSession = nodeRepository.login();
+ nodeSession = nodeRepository.login(NodeConstants.HOME);
String reposPath = NodeUtils.getUserHome(nodeSession).getPath() + RepoConstants.REPOSITORIES_BASE_PATH;
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));
}
}
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();
\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
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,\
*
</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>
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;
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;
final static String NONE = "<none>";
private Node processNode;
+ private Session agentSession;
private TreeViewer flowsViewer;
private TableViewer valuesViewer;
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
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();
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();
/** 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);
}
}
/**
* 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
// 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());
}
}
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();
@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 {
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);
}
}
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);
}
@Override
public void dispose() {
JcrUtils.unregisterQuietly(processNode, statusObserver);
+ JcrUtils.logoutQuietly(agentSession);
super.dispose();
}
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);
}
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);
}
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) {
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;
valuesViewer.setInput(getEditorSite());
return;
}
- Node realizedFlowNode = (Node) ((IStructuredSelection) evt
- .getSelection()).getFirstElement();
+ Node realizedFlowNode = (Node) ((IStructuredSelection) evt.getSelection()).getFirstElement();
valuesViewer.setInput(realizedFlowNode);
}
}
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) {
}
@Override
- public boolean validateDrop(Object target, int operation,
- TransferData transferType) {
+ public boolean validateDrop(Object target, int operation, TransferData transferType) {
return isEditable(getProcessStatus());
}
}
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);
}
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) {
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);
}
}
* 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);
}
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);
}
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();
}
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;
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;
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");
}
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);
}
}
- 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);
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();
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);
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);
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
// 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();
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) {
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;
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);
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);
}
}
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;
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();
}
- 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;
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:
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) {
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;
/** 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);
}
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 {
//
execute(realizedFlow, true);
- setFlowStatus(realizedFlowNode,
- ExecutionProcess.COMPLETED);
+ setFlowStatus(realizedFlowNode, ExecutionProcess.COMPLETED);
} catch (RepositoryException e) {
throw e;
} catch (InterruptedException e) {
}
}
} catch (RepositoryException e) {
- throw new SlcException("Cannot process "
- + getJcrExecutionProcess().getNodePath(), e);
+ throw new SlcException("Cannot process " + getJcrExecutionProcess().getNodePath(), e);
} finally {
JcrUtils.logoutQuietly(session);
}
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();
}
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;
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);
}
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,\
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,\