import java.util.List;
import javax.jcr.Node;
+import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import org.apache.commons.logging.Log;
/** Execution process implementation based on a JCR node. */
public class JcrExecutionProcess implements ExecutionProcess, SlcNames {
- private Log log = LogFactory.getLog(JcrExecutionProcess.class);
+ private final static Log log = LogFactory.getLog(JcrExecutionProcess.class);
private final Node node;
private Long nextLogLine = 1l;
this.node = node;
}
- public String getUuid() {
+ public synchronized String getUuid() {
try {
return node.getProperty(SLC_UUID).getString();
} catch (RepositoryException e) {
}
}
- public String getStatus() {
+ public synchronized String getStatus() {
try {
return node.getProperty(SLC_STATUS).getString();
} catch (RepositoryException e) {
}
}
- public void setStatus(String status) {
+ public synchronized void setStatus(String status) {
try {
node.setProperty(SLC_STATUS, status);
// last modified properties needs to be manually updated
}
}
- public Node getNode() {
- return node;
+ // public Node getNode() {
+ // return node;
+ // }
+
+ public String getNodePath() {
+ try {
+ return node.getPath();
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot get process node path for " + node,
+ e);
+ }
}
+ public Repository getRepository() {
+ try {
+ return node.getSession().getRepository();
+ } catch (RepositoryException e) {
+ throw new SlcException("Cannot get process JCR repository for "
+ + node, e);
+ }
+ }
}
import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
+import javax.jcr.Session;
import org.argeo.ArgeoException;
+import org.argeo.jcr.JcrUtils;
import org.argeo.slc.SlcException;
import org.argeo.slc.core.execution.DefaultExecutionSpec;
import org.argeo.slc.core.execution.PrimitiveSpecAttribute;
@Override
protected void process() throws InterruptedException {
+ Session session = null;
try {
- Node rootRealizedFlowNode = getNode().getNode(SLC_FLOW);
+ session = getJcrExecutionProcess().getRepository().login();
+ Node rootRealizedFlowNode = session.getNode(
+ getJcrExecutionProcess().getNodePath()).getNode(SLC_FLOW);
// we just manage one level for the time being
NodeIterator nit = rootRealizedFlowNode.getNodes(SLC_FLOW);
while (nit.hasNext()) {
}
}
} catch (RepositoryException e) {
- throw new ArgeoException("Cannot process " + getNode(), e);
+ throw new ArgeoException("Cannot process "
+ + getJcrExecutionProcess().getNodePath(), e);
+ } finally {
+ JcrUtils.logoutQuietly(session);
}
}
}
}
- protected Node getNode() {
- return ((JcrExecutionProcess) getProcess()).getNode();
+ protected JcrExecutionProcess getJcrExecutionProcess() {
+ return (JcrExecutionProcess) getProcess();
}
}