Coverage Report - org.kuali.rice.kew.impl.action.DocumentOrchestrationQueueImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentOrchestrationQueueImpl
0%
0/27
0%
0/12
13
 
 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 java.util.HashSet;
 19  
 import java.util.Set;
 20  
 
 21  
 import org.apache.commons.lang.StringUtils;
 22  
 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
 23  
 import org.kuali.rice.kew.actions.BlanketApproveAction;
 24  
 import org.kuali.rice.kew.actions.MoveDocumentAction;
 25  
 import org.kuali.rice.kew.actiontaken.ActionTakenValue;
 26  
 import org.kuali.rice.kew.api.KewApiServiceLocator;
 27  
 import org.kuali.rice.kew.api.WorkflowRuntimeException;
 28  
 import org.kuali.rice.kew.api.document.DocumentOrchestrationQueue;
 29  
 import org.kuali.rice.kew.api.document.DocumentProcessingOptions;
 30  
 import org.kuali.rice.kew.api.document.OrchestrationConfig;
 31  
 import org.kuali.rice.kew.api.document.attribute.DocumentAttributeIndexingQueue;
 32  
 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
 33  
 import org.kuali.rice.kew.service.KEWServiceLocator;
 34  
 import org.kuali.rice.kim.api.identity.principal.Principal;
 35  
 
 36  
 import javax.jws.WebParam;
 37  
 
 38  
 /**
 39  
  * References implementation of the {@code DocumentOrchestrationQueue}.
 40  
  *
 41  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 42  
  */
 43  0
 public class DocumentOrchestrationQueueImpl implements DocumentOrchestrationQueue {
 44  
         
 45  0
         private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocumentOrchestrationQueueImpl.class);
 46  
 
 47  
     @Override
 48  
     public void orchestrateDocument(String documentId, String principalId, OrchestrationConfig orchestrationConfig,
 49  
             DocumentProcessingOptions documentProcessingOptions) {
 50  0
         if (StringUtils.isBlank(principalId)) {
 51  0
             throw new RiceIllegalArgumentException("principalId is null or blank");
 52  
         }
 53  
 
 54  0
         if (StringUtils.isBlank(documentId)) {
 55  0
             throw new RiceIllegalArgumentException("documentId is null");
 56  
         }
 57  
 
 58  0
         if (orchestrationConfig == null) {
 59  0
             throw new RiceIllegalArgumentException("orchestrationConfig is null");
 60  
         }
 61  0
         if (documentProcessingOptions == null) {
 62  0
             documentProcessingOptions = DocumentProcessingOptions.createDefault();
 63  
         }
 64  
 
 65  0
         LOG.info("Performing document orchestration on documentId=" + documentId);
 66  0
         KEWServiceLocator.getRouteHeaderService().lockRouteHeader(documentId, true);
 67  0
         DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);
 68  0
                 ActionTakenValue actionTaken = KEWServiceLocator.getActionTakenService().findByActionTakenId(orchestrationConfig.getActionTakenId());
 69  0
                 Principal principal = KEWServiceLocator.getIdentityHelperService().getPrincipal(principalId);
 70  0
                 BlanketApproveAction blanketApprove = new BlanketApproveAction(document, principal, "", orchestrationConfig.getNodeNames());
 71  
                 try {
 72  0
                         blanketApprove.performDeferredBlanketApproveWork(actionTaken, documentProcessingOptions);
 73  0
                 } catch (Exception e) {
 74  0
             if (e instanceof RuntimeException) {
 75  0
                 throw (RuntimeException)e;
 76  
             }
 77  0
                         throw new WorkflowRuntimeException(e);
 78  0
                 }
 79  0
                 if (documentProcessingOptions.isIndexSearchAttributes()) {
 80  0
             DocumentAttributeIndexingQueue queue = KewApiServiceLocator.getDocumentAttributeIndexingQueue(document.getDocumentType().getApplicationId());
 81  0
             queue.indexDocument(documentId);
 82  
                 }
 83  0
         LOG.info("Document orchestration complete against documentId=" + documentId);
 84  0
     }
 85  
 
 86  
 }