Coverage Report - org.kuali.rice.kew.rule.RolePokerProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
RolePokerProcessor
0%
0/29
0%
0/12
4
 
 1  
 /*
 2  
  * Copyright 2005-2008 The Kuali Foundation
 3  
  * 
 4  
  * 
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  * 
 9  
  * http://www.opensource.org/licenses/ecl2.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 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  
  * RolePoker implementation which handles initiating refresh of the "poked" role.
 31  
  *
 32  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 33  
  */
 34  0
 public class RolePokerProcessor implements RolePoker {
 35  
 
 36  
         public void reResolveRole(Long documentId, String roleName, String qualifiedRoleNameLabel) {
 37  0
                 KEWServiceLocator.getRouteHeaderService().lockRouteHeader(documentId, true);
 38  0
                 if (Utilities.isEmpty(roleName)) {
 39  0
                         throw new IllegalArgumentException("Can't poke a role without a role name!");
 40  
                 }
 41  0
                 DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);
 42  
                 try {
 43  0
                 if (qualifiedRoleNameLabel == null) {
 44  0
                         KEWServiceLocator.getRoleService().reResolveRole(document, roleName);
 45  
                 } else {
 46  0
                         KEWServiceLocator.getRoleService().reResolveQualifiedRole(document, roleName, qualifiedRoleNameLabel);
 47  
                 }
 48  0
                 } catch (WorkflowException e) {
 49  0
                         throw new WorkflowRuntimeException(e);
 50  0
                 }
 51  0
         }
 52  
 
 53  
         public void reResolveRole(Long documentId, String roleName) {
 54  0
                 reResolveRole(documentId, roleName, null);
 55  0
         }
 56  
                 
 57  
         private String[] parseParameters(String parameters) {
 58  0
                 List strings = new ArrayList();
 59  0
                 boolean isEscaped = false;
 60  0
                 StringBuffer buffer = new StringBuffer();
 61  0
                 for (int index = 0; index < parameters.length(); index++) {
 62  0
                         char character = parameters.charAt(index);
 63  0
                         if (isEscaped) {
 64  0
                                 isEscaped = false;
 65  0
                                 buffer.append(character);
 66  
                         } else {
 67  0
                                 if (character == '\\') {
 68  0
                                         isEscaped = true;
 69  0
                                 } else if (character == ',') {
 70  0
                                         strings.add(buffer.toString());
 71  0
                                         buffer = new StringBuffer();
 72  
                                 } else {
 73  0
                                         buffer.append(character);
 74  
                                 }
 75  
                         }
 76  
                 }
 77  0
                 return (String[])strings.toArray(new String[0]);
 78  
         }
 79  
 
 80  
 
 81  
 
 82  
 }