Coverage Report - org.kuali.rice.kew.impl.document.DocumentProcessingQueueImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentProcessingQueueImpl
0%
0/26
0%
0/8
2.333
 
 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.document;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.apache.log4j.Logger;
 20  
 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
 21  
 import org.kuali.rice.kew.api.WorkflowRuntimeException;
 22  
 import org.kuali.rice.kew.api.document.DocumentProcessingOptions;
 23  
 import org.kuali.rice.kew.api.document.DocumentProcessingQueue;
 24  
 import org.kuali.rice.kew.api.document.attribute.DocumentAttributeIndexingQueue;
 25  
 import org.kuali.rice.kew.engine.OrchestrationConfig;
 26  
 import org.kuali.rice.kew.engine.WorkflowEngine;
 27  
 import org.kuali.rice.kew.engine.WorkflowEngineFactory;
 28  
 
 29  
 import javax.jws.WebParam;
 30  
 import java.util.Collections;
 31  
 
 32  
 /**
 33  
  * Reference implementation of the {@code DocumentProcessingQueue}.
 34  
  *
 35  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 36  
  */
 37  0
 public class DocumentProcessingQueueImpl implements DocumentProcessingQueue {
 38  
 
 39  0
     private static final Logger LOG = Logger.getLogger(DocumentProcessingQueueImpl.class);
 40  
 
 41  
     private WorkflowEngineFactory workflowEngineFactory;
 42  
     private DocumentAttributeIndexingQueue documentAttributeIndexingQueue;
 43  
 
 44  
     @Override
 45  
     public void process(@WebParam(name = "documentId") String documentId) {
 46  0
         processWithOptions(documentId, null);
 47  0
     }
 48  
 
 49  
     @Override
 50  
     public void processWithOptions(@WebParam(name = "documentId") String documentId,
 51  
             @WebParam(name = "options") DocumentProcessingOptions options) {
 52  0
         if (StringUtils.isBlank(documentId)) {
 53  0
             throw new RiceIllegalArgumentException("documentId was a null or blank value");
 54  
         }
 55  0
         if (options == null) {
 56  0
             options = DocumentProcessingOptions.createDefault();
 57  
         }
 58  0
         OrchestrationConfig config = new OrchestrationConfig(OrchestrationConfig.EngineCapability.STANDARD,
 59  
                 Collections.<String>emptySet(), null, options.isSendNotifications(), options.isRunPostProcessor());
 60  0
         WorkflowEngine engine = getWorkflowEngineFactory().newEngine(config);
 61  
         try {
 62  0
                         engine.process(documentId, null);
 63  0
                 } catch (Exception e) {
 64  0
                         LOG.error("Failed to process document through the workflow engine", e);
 65  0
             if (e instanceof RuntimeException) {
 66  0
                 throw (RuntimeException)e;
 67  
             }
 68  0
                         throw new WorkflowRuntimeException(e);
 69  0
                 }
 70  0
         if (options.isIndexSearchAttributes()) {
 71  0
             getDocumentAttributeIndexingQueue().indexDocument(documentId);
 72  
         }
 73  0
     }
 74  
 
 75  
     public WorkflowEngineFactory getWorkflowEngineFactory() {
 76  0
         return workflowEngineFactory;
 77  
     }
 78  
 
 79  
     public void setWorkflowEngineFactory(WorkflowEngineFactory workflowEngineFactory) {
 80  0
         this.workflowEngineFactory = workflowEngineFactory;
 81  0
     }
 82  
 
 83  
     public DocumentAttributeIndexingQueue getDocumentAttributeIndexingQueue() {
 84  0
         return documentAttributeIndexingQueue;
 85  
     }
 86  
 
 87  
     public void setDocumentAttributeIndexingQueue(DocumentAttributeIndexingQueue documentAttributeIndexingQueue) {
 88  0
         this.documentAttributeIndexingQueue = documentAttributeIndexingQueue;
 89  0
     }
 90  
 
 91  
 }