1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.rule; |
18 | |
|
19 | |
import org.kuali.rice.kew.api.WorkflowRuntimeException; |
20 | |
import org.kuali.rice.kew.exception.WorkflowException; |
21 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
22 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
23 | |
|
24 | |
import java.util.ArrayList; |
25 | |
import java.util.List; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | 0 | public class RolePokerProcessor implements RolePoker { |
34 | |
|
35 | |
public void reResolveRole(String documentId, String roleName, String qualifiedRoleNameLabel) { |
36 | 0 | KEWServiceLocator.getRouteHeaderService().lockRouteHeader(documentId, true); |
37 | 0 | if (org.apache.commons.lang.StringUtils.isEmpty(roleName)) { |
38 | 0 | throw new IllegalArgumentException("Can't poke a role without a role name!"); |
39 | |
} |
40 | 0 | DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId); |
41 | |
try { |
42 | 0 | if (qualifiedRoleNameLabel == null) { |
43 | 0 | KEWServiceLocator.getRoleService().reResolveRole(document, roleName); |
44 | |
} else { |
45 | 0 | KEWServiceLocator.getRoleService().reResolveQualifiedRole(document, roleName, qualifiedRoleNameLabel); |
46 | |
} |
47 | 0 | } catch (WorkflowException e) { |
48 | 0 | throw new WorkflowRuntimeException(e); |
49 | 0 | } |
50 | 0 | } |
51 | |
|
52 | |
public void reResolveRole(String documentId, String roleName) { |
53 | 0 | reResolveRole(documentId, roleName, null); |
54 | 0 | } |
55 | |
|
56 | |
private String[] parseParameters(String parameters) { |
57 | 0 | List strings = new ArrayList(); |
58 | 0 | boolean isEscaped = false; |
59 | 0 | StringBuffer buffer = new StringBuffer(); |
60 | 0 | for (int index = 0; index < parameters.length(); index++) { |
61 | 0 | char character = parameters.charAt(index); |
62 | 0 | if (isEscaped) { |
63 | 0 | isEscaped = false; |
64 | 0 | buffer.append(character); |
65 | |
} else { |
66 | 0 | if (character == '\\') { |
67 | 0 | isEscaped = true; |
68 | 0 | } else if (character == ',') { |
69 | 0 | strings.add(buffer.toString()); |
70 | 0 | buffer = new StringBuffer(); |
71 | |
} else { |
72 | 0 | buffer.append(character); |
73 | |
} |
74 | |
} |
75 | |
} |
76 | 0 | return (String[])strings.toArray(new String[0]); |
77 | |
} |
78 | |
|
79 | |
|
80 | |
|
81 | |
} |