Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 package org.kuali.rice.kew.actions;
 import java.util.List;
The RevokeAdHocApprove revokes the specified AdHoc requests.

Kuali Rice Team (
 public class RevokeAdHocAction extends ActionTakenEvent {
     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(RevokeAdHocAction.class);
     private String actionRequestId;
     private AdHocRevoke revoke;
     public RevokeAdHocAction(DocumentRouteHeaderValue routeHeaderPrincipalContract principal) {
     public RevokeAdHocAction(DocumentRouteHeaderValue routeHeaderPrincipalContract principalString actionRequestIdString annotation) {
         this. = actionRequestId;
     public RevokeAdHocAction(DocumentRouteHeaderValue routeHeaderPrincipalContract principalAdHocRevoke revokeString annotation) {
         this. = revoke;
     /* (non-Javadoc)
      * @see org.kuali.rice.kew.actions.ActionTakenEvent#isActionCompatibleRequest(java.util.List)
     public String validateActionRules() {
             return "Revoke adhoc request is not valid on this document";
         return "";
     public String validateActionRules(List<ActionRequestValueactionRequests) {
     	return validateActionRules();

Records the approve action. - Checks to make sure the document status allows the action. - Checks that the user has not taken a previous action. - Deactivates the pending requests for this user - Records the action

     public void recordAction() throws InvalidActionTakenException {
         String errorMessage = validateActionRules();
         if (!org.apache.commons.lang.StringUtils.isEmpty(errorMessage)) {
             throw new InvalidActionTakenException(errorMessage);
         .debug("Revoking adhoc request : " + );
         List<ActionRequestValuerequestsToRevoke = new ArrayList<ActionRequestValue>();
         for (ActionRequestValue actionRequest : actionRequests)
             if (matchesActionRequest(actionRequest))
        if (requestsToRevoke.isEmpty() &&  != null) {
        	throw new InvalidActionTakenException("Failed to revoke action request with id " +  +
        			".  ID does not represent a valid ad hoc request!");
        Recipient delegator = findDelegatorForActionRequests(actionRequests);
        .debug("Record the revoke action");
        ActionTakenValue actionTaken = saveActionTaken(delegator);
        .debug("Revoke all matching action requests, number of matching requests: " + requestsToRevoke.size());
Determines if the given action request is an ad hoc request which matches this set of criteria.
	protected boolean matchesActionRequest(AdHocRevoke adHocRevokeCommandActionRequestValue actionRequest) {
		if (!actionRequest.isAdHocRequest()) {
			return false;
		if ( != null) {
			return .equals(actionRequest.getActionRequestId());
else if (adHocRevokeCommand != null) {
			boolean principalOrGroupId = !CollectionUtils.isEmpty(adHocRevokeCommand.getPrincipalIds()) || !CollectionUtils.isEmpty(adHocRevokeCommand.getGroupIds());
			if (!CollectionUtils.isEmpty(adHocRevokeCommand.getNodeNames()) && !adHocRevokeCommand.getNodeNames().contains(actionRequest.getNodeInstance().getName())) {
				return false;
			if (actionRequest.isUserRequest() && !CollectionUtils.isEmpty(adHocRevokeCommand.getPrincipalIds())) {
				return adHocRevokeCommand.getPrincipalIds().contains(actionRequest.getPrincipalId());
			if (actionRequest.isGroupRequest() && !CollectionUtils.isEmpty(adHocRevokeCommand.getGroupIds())) {
				return adHocRevokeCommand.getGroupIds().contains(actionRequest.getGroupId());
			return !principalOrGroupId;
		return true;
New to GrepCode? Check out our FAQ X