01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.routetemplate;
18:
19: import java.util.ArrayList;
20: import java.util.List;
21:
22: import edu.iu.uis.eden.KEWServiceLocator;
23: import edu.iu.uis.eden.exception.WorkflowException;
24: import edu.iu.uis.eden.exception.WorkflowRuntimeException;
25: import edu.iu.uis.eden.routeheader.DocumentRouteHeaderValue;
26: import edu.iu.uis.eden.util.Utilities;
27:
28: /**
29: * RolePoker implementation which handles initiating refresh of the "poked" role.
30: *
31: * @author ewestfal
32: */
33: public class RolePokerProcessor implements RolePoker {
34:
35: public void reResolveRole(Long documentId, String roleName,
36: String qualifiedRoleNameLabel) {
37: KEWServiceLocator.getRouteHeaderService().lockRouteHeader(
38: documentId, true);
39: if (Utilities.isEmpty(roleName)) {
40: throw new IllegalArgumentException(
41: "Can't poke a role without a role name!");
42: }
43: DocumentRouteHeaderValue document = KEWServiceLocator
44: .getRouteHeaderService().getRouteHeader(documentId);
45: try {
46: if (qualifiedRoleNameLabel == null) {
47: KEWServiceLocator.getRoleService().reResolveRole(
48: document, roleName);
49: } else {
50: KEWServiceLocator.getRoleService()
51: .reResolveQualifiedRole(document, roleName,
52: qualifiedRoleNameLabel);
53: }
54: } catch (WorkflowException e) {
55: throw new WorkflowRuntimeException(e);
56: }
57: }
58:
59: public void reResolveRole(Long documentId, String roleName) {
60: reResolveRole(documentId, roleName, null);
61: }
62:
63: private String[] parseParameters(String parameters) {
64: List strings = new ArrayList();
65: boolean isEscaped = false;
66: StringBuffer buffer = new StringBuffer();
67: for (int index = 0; index < parameters.length(); index++) {
68: char character = parameters.charAt(index);
69: if (isEscaped) {
70: isEscaped = false;
71: buffer.append(character);
72: } else {
73: if (character == '\\') {
74: isEscaped = true;
75: } else if (character == ',') {
76: strings.add(buffer.toString());
77: buffer = new StringBuffer();
78: } else {
79: buffer.append(character);
80: }
81: }
82: }
83: return (String[]) strings.toArray(new String[0]);
84: }
85:
86: }
|