import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
+import javax.jcr.Session;
import org.argeo.jcr.JcrUtils;
+import org.argeo.jcr.UserJcrUtils;
import org.argeo.slc.SlcException;
import org.argeo.slc.core.execution.PrimitiveAccessor;
import org.argeo.slc.core.execution.PrimitiveUtils;
return buf.toString();
}
- /** Module node name based on module name and version */
- public static String getModuleNodeName(ModuleDescriptor moduleDescriptor) {
- return moduleDescriptor.getName() + "_" + moduleDescriptor.getVersion();
- }
-
- /** Extracts the execution module name of a flow */
- public static String flowExecutionModuleName(String fullFlowPath) {
+ /** Extracts the path to the related execution module */
+ public static String modulePath(String fullFlowPath) {
String[] tokens = fullFlowPath.split("/");
- String moduleNodeName = tokens[AGENT_FACTORY_DEPTH + 2];
- return moduleNodeName.substring(0, moduleNodeName.lastIndexOf('_'));
+ StringBuffer buf = new StringBuffer(fullFlowPath.length());
+ for (int i = 0; i < AGENT_FACTORY_DEPTH + 3; i++) {
+ if (!tokens[i].equals(""))
+ buf.append('/').append(tokens[i]);
+ }
+ return buf.toString();
}
- /** Extracts the execution module version of a flow */
- public static String flowExecutionModuleVersion(String fullFlowPath) {
- String[] tokens = fullFlowPath.split("/");
- String moduleNodeName = tokens[AGENT_FACTORY_DEPTH + 2];
- return moduleNodeName.substring(moduleNodeName.lastIndexOf('_') + 1);
+ /** Module node name based on module name and version */
+ public static String getModuleNodeName(ModuleDescriptor moduleDescriptor) {
+ return moduleDescriptor.getName() + "_" + moduleDescriptor.getVersion();
}
/** Extracts the agent factory of a flow */
+ JcrUtils.dateAsPath(now, true) + uuid;
}
- /** Create a new execution result path based on the current time */
- public static String createResultPath(String uuid) {
+ /**
+ * Create a new execution result path in the user home based on the current
+ * time
+ */
+ public static String createResultPath(Session session, String uuid)
+ throws RepositoryException {
Calendar now = new GregorianCalendar();
- return SlcJcrConstants.RESULTS_BASE_PATH + '/'
- + JcrUtils.dateAsPath(now, true) + uuid;
+ return UserJcrUtils.getUserHome(session).getPath() + '/'
+ + SlcNames.SLC_RESULTS + '/' + JcrUtils.dateAsPath(now, true)
+ + uuid;
}
/**
+ node, e);
}
}
-
+
/** Prevents instantiation */
private SlcJcrUtils() {
}
-
- public static void main(String[] args) {
- String path = "/slc/agents/vm/default/org.argeo_1.2.3/myPath/myFlow";
- System.out.println("Flow relative path: " + flowRelativePath(path));
- System.out.println("Execution Module Name: "
- + flowExecutionModuleName(path));
- System.out.println("Execution Module Version: "
- + flowExecutionModuleVersion(path));
- System.out.println("Agent Factory path: " + flowAgentFactoryPath(path));
- }
-
}