]> git.argeo.org Git - gpl/argeo-slc.git/blob - SlcJcrUtils.java
0cda5a86d68e3d6149163633c907cab67bc3474b
[gpl/argeo-slc.git] / SlcJcrUtils.java
1 package org.argeo.slc.jcr;
2
3 /** Utilities around the SLC JCR model. Note that it relies on fixed base paths. */
4 public class SlcJcrUtils {
5 public final static Integer AGENT_FACTORY_DEPTH = 3;
6 public final static Integer EXECUTION_MODULES_DEPTH = AGENT_FACTORY_DEPTH + 2;
7 public final static Integer EXECUTION_FLOWS_DEPTH = EXECUTION_MODULES_DEPTH + 3;
8
9 /** Extracts the path of a flow relative to its execution module */
10 public static String flowRelativePath(String fullFlowPath) {
11 String[] tokens = fullFlowPath.split("/");
12 StringBuffer buf = new StringBuffer(fullFlowPath.length());
13 for (int i = EXECUTION_FLOWS_DEPTH; i < tokens.length; i++) {
14 buf.append('/').append(tokens[i]);
15 }
16 return buf.toString();
17 }
18
19 /** Extracts the execution module name of a flow */
20 public static String flowExecutionModuleName(String fullFlowPath) {
21 String[] tokens = fullFlowPath.split("/");
22 return tokens[EXECUTION_MODULES_DEPTH + 1];
23 }
24
25 /** Extracts the execution module version of a flow */
26 public static String flowExecutionModuleVersion(String fullFlowPath) {
27 String[] tokens = fullFlowPath.split("/");
28 return tokens[EXECUTION_MODULES_DEPTH + 2];
29 }
30
31 /** Extracts the agent factory of a flow */
32 public static String flowAgentFactoryPath(String fullFlowPath) {
33 String[] tokens = fullFlowPath.split("/");
34 StringBuffer buf = new StringBuffer(fullFlowPath.length());
35 // first token is always empty
36 for (int i = 1; i < AGENT_FACTORY_DEPTH + 1; i++) {
37 buf.append('/').append(tokens[i]);
38 }
39 return buf.toString();
40 }
41
42 /** Prevents instantiation */
43 private SlcJcrUtils() {
44
45 }
46
47 // public static void main(String[] args) {
48 // String path =
49 // "/slc/agents/vm/54654654654/executionModules/org.argeo/1.2.3/myFlow";
50 // System.out.println(flowRelativePath(path));
51 // System.out.println(flowExecutionModuleName(path));
52 // System.out.println(flowAgentFactoryPath(path));
53 // }
54 }