View Javadoc

1   /*
2    * Copyright 2005-2007 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.actions.asyncservices;
18  
19  import java.util.Set;
20  
21  import org.kuali.rice.kew.actions.BlanketApproveAction;
22  import org.kuali.rice.kew.actiontaken.ActionTakenValue;
23  import org.kuali.rice.kew.api.KewApiServiceLocator;
24  import org.kuali.rice.kew.api.WorkflowRuntimeException;
25  import org.kuali.rice.kew.api.document.attribute.DocumentAttributeIndexingQueue;
26  import org.kuali.rice.kew.messaging.MessageServiceNames;
27  import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
28  import org.kuali.rice.kew.service.KEWServiceLocator;
29  import org.kuali.rice.kim.api.identity.principal.Principal;
30  
31  
32  
33  /**
34   * Responsible for invoking the async piece of BlanketApprove
35   *
36   * @author Kuali Rice Team (rice.collab@kuali.org)
37   */
38  public class BlanketApproveProcessor implements BlanketApproveProcessorService {
39  	
40  	private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(BlanketApproveProcessor.class);
41  	
42  	public void doBlanketApproveWork(String documentId, String principalId, String actionTakenId, Set<String> nodeNames) {
43  		doBlanketApproveWork(documentId, principalId, actionTakenId, nodeNames, false);
44  	}
45  
46  	public void doBlanketApproveWork(String documentId, String principalId, String actionTakenId, Set<String> nodeNames, boolean shouldSearchIndex) {
47  		KEWServiceLocator.getRouteHeaderService().lockRouteHeader(documentId, true);
48  		DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);
49  		ActionTakenValue actionTaken = KEWServiceLocator.getActionTakenService().findByActionTakenId(actionTakenId);
50  		Principal principal = KEWServiceLocator.getIdentityHelperService().getPrincipal(principalId);
51  		BlanketApproveAction blanketApprove = new BlanketApproveAction(document, principal, "", nodeNames);
52  		LOG.debug("Doing blanket approve work document " + document.getDocumentId());
53  		try {
54  			blanketApprove.performDeferredBlanketApproveWork(actionTaken);
55  		} catch (Exception e) {
56  			throw new WorkflowRuntimeException(e);
57  		}
58  		if (shouldSearchIndex) {
59              DocumentAttributeIndexingQueue queue = KewApiServiceLocator.getDocumentAttributeIndexingQueue(document.getDocumentType().getApplicationId());
60              queue.indexDocument(documentId);
61  		}
62  		LOG.debug("Work done and document requeued, document " + document.getDocumentId());
63  	}
64  }