1 package org
.argeo
.slc
.jcr
;
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;
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
]);
16 return buf
.toString();
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];
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];
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
]);
39 return buf
.toString();
42 /** Prevents instantiation */
43 private SlcJcrUtils() {
47 // public static void main(String[] args) {
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));