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