1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.module.workflow.commands;
35
36 import java.util.ArrayList;
37 import java.util.Collection;
38 import java.util.Iterator;
39
40 import org.apache.commons.lang.StringUtils;
41
42
43
44
45
46
47
48 public class PathMappedFlowCommand extends FlowCommand {
49
50 private Collection<Mapping> mappings = new ArrayList<Mapping>();
51
52 private String repository;
53
54 private String path;
55
56
57
58
59 public String getWorkflowName() {
60 for (Iterator<Mapping> iter = getMappings().iterator(); iter.hasNext();) {
61 Mapping mapping = iter.next();
62 if(path.startsWith(mapping.getPath())){
63 return mapping.getWorkflowName();
64 }
65 }
66 return super.getWorkflowName();
67 }
68 public String getDialogName() {
69 for (Iterator<Mapping> iter = getMappings().iterator(); iter.hasNext();) {
70 Mapping mapping = iter.next();
71 if(path.startsWith(mapping.getPath()) && StringUtils.isNotEmpty(mapping.getDialogName())){
72 return mapping.getDialogName();
73 }
74 }
75 return super.getDialogName();
76 }
77
78 public Collection<Mapping> getMappings() {
79 return this.mappings;
80 }
81
82 public void setMappings(Collection<Mapping> mappings) {
83 this.mappings = mappings;
84 }
85
86 public void addMapping(Mapping mapping) {
87 if (mapping.isEnabled()) {
88 this.mappings.add(mapping);
89 }
90 }
91
92 public String getPath() {
93 return this.path;
94 }
95
96 public void setPath(String path) {
97 this.path = path;
98 }
99
100 public String getRepository() {
101 return this.repository;
102 }
103
104 public void setRepository(String repository) {
105 this.repository = repository;
106 }
107
108 @Override
109 public void release() {
110 super.release();
111 mappings = new ArrayList<Mapping>();
112 repository = null;
113 path = null;
114 }
115
116
117
118
119 public static class Mapping {
120
121 private String path;
122
123 private String workflowName;
124
125 private String dialogName;
126
127 private boolean enabled = true;
128
129 public String getPath() {
130 return this.path;
131 }
132
133 public void setPath(String path) {
134 this.path = path;
135 }
136
137 public String getWorkflowName() {
138 return this.workflowName;
139 }
140
141 public void setWorkflowName(String workflowName) {
142 this.workflowName = workflowName;
143 }
144
145 public boolean isEnabled() {
146 return this.enabled;
147 }
148
149 public void setEnabled(boolean enabled) {
150 this.enabled = enabled;
151 }
152
153
154 public String getDialogName() {
155 return this.dialogName;
156 }
157
158
159 public void setDialogName(String dialogName) {
160 this.dialogName = dialogName;
161 }
162 }
163
164
165 }