]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.jcr/src/main/java/org/argeo/slc/jcr/execution/JcrExecutionProcess.java
ce08b8f38136d432617b8b7e8abcb2d145c82143
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.jcr / src / main / java / org / argeo / slc / jcr / execution / JcrExecutionProcess.java
1 package org.argeo.slc.jcr.execution;
2
3 import javax.jcr.Node;
4 import javax.jcr.RepositoryException;
5
6 import org.argeo.jcr.JcrUtils;
7 import org.argeo.slc.SlcException;
8 import org.argeo.slc.execution.ExecutionProcess;
9 import org.argeo.slc.jcr.SlcNames;
10
11 /** Execution process implementation based on a JCR node. */
12 public class JcrExecutionProcess implements ExecutionProcess {
13 private final Node node;
14
15 public JcrExecutionProcess(Node node) {
16 this.node = node;
17 }
18
19 public String getUuid() {
20 try {
21 return node.getProperty(SlcNames.SLC_UUID).getString();
22 } catch (RepositoryException e) {
23 throw new SlcException("Cannot get uuid for " + node, e);
24 }
25 }
26
27 public String getStatus() {
28 try {
29 return node.getProperty(SlcNames.SLC_STATUS).getString();
30 } catch (RepositoryException e) {
31 throw new SlcException("Cannot get uuid for " + node, e);
32 }
33 }
34
35 public void setStatus(String status) {
36 try {
37 node.setProperty(SlcNames.SLC_STATUS, status);
38 // last modified properties needs to be manually updated
39 // see https://issues.apache.org/jira/browse/JCR-2233
40 JcrUtils.updateLastModified(node);
41 node.getSession().save();
42 } catch (RepositoryException e) {
43 try {
44 JcrUtils.discardQuietly(node.getSession());
45 } catch (RepositoryException e1) {
46 // silent
47 }
48 throw new SlcException("Cannot get uuid for " + node, e);
49 }
50 }
51
52 public Node getNode() {
53 return node;
54 }
55
56 }