001 /**
002 * Copyright 2005-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.kew.impl.action;
017
018 import org.apache.commons.lang.StringUtils;
019 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
020 import org.kuali.rice.kew.api.action.RolePokerQueue;
021 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
022 import org.kuali.rice.kew.service.KEWServiceLocator;
023
024 /**
025 * Reference implementation of the {@code RokePokerQueue} which handle re-resolution of action requests which use roles.
026 *
027 * @author Kuali Rice Team (rice.collab@kuali.org)
028 */
029 public class RolePokerQueueImpl implements RolePokerQueue {
030
031 @Override
032 public void reResolveQualifiedRole(String documentId, String roleName, String qualifiedRoleNameLabel) {
033 if (StringUtils.isBlank(documentId)) {
034 throw new RiceIllegalArgumentException("documentId is null or blank");
035 }
036 if (StringUtils.isBlank(roleName)) {
037 throw new RiceIllegalArgumentException("roleName is null or blank");
038 }
039
040 KEWServiceLocator.getRouteHeaderService().lockRouteHeader(documentId, true);
041 DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);
042 if (qualifiedRoleNameLabel == null) {
043 KEWServiceLocator.getRoleService().reResolveRole(document, roleName);
044 } else {
045 KEWServiceLocator.getRoleService().reResolveQualifiedRole(document, roleName, qualifiedRoleNameLabel);
046 }
047 }
048
049 @Override
050 public void reResolveRole(String documentId, String roleName) {
051 reResolveQualifiedRole(documentId, roleName, null);
052 }
053 }