View Javadoc

1   /**
2    * Copyright 2005-2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kew.impl.action;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
20  import org.kuali.rice.kew.api.action.RolePokerQueue;
21  import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
22  import org.kuali.rice.kew.service.KEWServiceLocator;
23  
24  /**
25   * Reference implementation of the {@code RokePokerQueue} which handle re-resolution of action requests which use roles.
26   * 
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   */
29  public class RolePokerQueueImpl implements RolePokerQueue {
30  
31      @Override
32  	public void reResolveQualifiedRole(String documentId, String roleName, String qualifiedRoleNameLabel) {
33          if (StringUtils.isBlank(documentId)) {
34  			throw new RiceIllegalArgumentException("documentId is null or blank");
35  		}
36          if (StringUtils.isBlank(roleName)) {
37  			throw new RiceIllegalArgumentException("roleName is null or blank");
38  		}
39  
40  		KEWServiceLocator.getRouteHeaderService().lockRouteHeader(documentId, true);
41  		DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);
42  		if (qualifiedRoleNameLabel == null) {
43  			KEWServiceLocator.getRoleService().reResolveRole(document, roleName);
44  		} else {
45  			KEWServiceLocator.getRoleService().reResolveQualifiedRole(document, roleName, qualifiedRoleNameLabel);
46  		}
47  	}
48  
49      @Override
50  	public void reResolveRole(String documentId, String roleName) {
51  		reResolveQualifiedRole(documentId, roleName, null);
52  	}
53  }