Coverage Report - org.kuali.rice.kew.messaging.RouteDocumentMessageService
 
Classes in this File Line Coverage Branch Coverage Complexity
RouteDocumentMessageService
0%
0/15
0%
0/2
2.167
RouteDocumentMessageService$RouteMessageXmlElement
0%
0/18
0%
0/4
2.167
 
 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.messaging;
 18  
 
 19  
 import org.apache.log4j.Logger;
 20  
 import org.kuali.rice.kew.api.KewApiServiceLocator;
 21  
 import org.kuali.rice.kew.api.WorkflowRuntimeException;
 22  
 import org.kuali.rice.kew.api.document.attribute.DocumentAttributeIndexingQueue;
 23  
 import org.kuali.rice.kew.engine.OrchestrationConfig;
 24  
 import org.kuali.rice.kew.engine.OrchestrationConfig.EngineCapability;
 25  
 import org.kuali.rice.kew.engine.WorkflowEngine;
 26  
 import org.kuali.rice.kew.service.KEWServiceLocator;
 27  
 import org.kuali.rice.ksb.messaging.service.KSBXMLService;
 28  
 
 29  
 
 30  
 /**
 31  
  * An XML services which is used to submit documents to the engine.
 32  
  *
 33  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 34  
  */
 35  0
 public class RouteDocumentMessageService implements KSBXMLService {
 36  
 
 37  0
         private static final Logger LOG = Logger.getLogger(RouteDocumentMessageService.class);
 38  
         
 39  
         public void invoke(String xml) {
 40  
                 try {
 41  0
                         RouteMessageXmlElement newElement = RouteMessageXmlElement.construct(xml);
 42  0
                         OrchestrationConfig config = new OrchestrationConfig(EngineCapability.STANDARD, newElement.runPostProcessor);
 43  0
                         WorkflowEngine engine = KEWServiceLocator.getWorkflowEngineFactory().newEngine(config);
 44  0
                         engine.process(newElement.documentId, null);
 45  0
                         if (newElement.shouldSearchAttributeIndex) {
 46  0
                 DocumentAttributeIndexingQueue queue = KewApiServiceLocator.getDocumentAttributeIndexingQueue(KEWServiceLocator.getRouteHeaderService().getRouteHeader(newElement.documentId).getDocumentType().getApplicationId());
 47  0
                 queue.indexDocument(newElement.documentId);
 48  
                         }
 49  0
                 } catch (Exception e) {
 50  0
                         LOG.error(e);
 51  0
                         throw new WorkflowRuntimeException(e);
 52  0
                 }
 53  0
         }
 54  
         
 55  0
         public static class RouteMessageXmlElement {
 56  
                 public String documentId;
 57  0
                 public boolean runPostProcessor = true;
 58  0
                 public boolean shouldSearchAttributeIndex = false;
 59  0
                 public RouteMessageXmlElement(String documentId) {
 60  0
                         this.documentId = documentId;
 61  0
                 }
 62  
                 public RouteMessageXmlElement(String documentId, boolean runPostProcessor) {
 63  0
                         this(documentId);
 64  0
                         this.runPostProcessor = runPostProcessor;
 65  0
                 }
 66  
                 public RouteMessageXmlElement(String documentId, boolean runPostProcessor, boolean shouldIndex) {
 67  0
                         this(documentId, runPostProcessor);
 68  0
                         this.shouldSearchAttributeIndex = shouldIndex;
 69  0
                 }
 70  
                 private static final String SPLIT = "::~~::";
 71  
                 public static RouteMessageXmlElement construct(String content) {
 72  0
                         if (content.contains(SPLIT)) {
 73  0
                                 String[] values = content.split(SPLIT);
 74  0
                                 if (values.length == 3) {
 75  0
                                         return new RouteMessageXmlElement(values[0], Boolean.valueOf(values[1]), Boolean.valueOf(values[2]));
 76  
                                 } else {
 77  0
                                         return new RouteMessageXmlElement(values[0],Boolean.valueOf(values[1]));
 78  
                                 }
 79  
                         } else {
 80  0
                                 return new RouteMessageXmlElement(content);
 81  
                         }
 82  
                 }
 83  
                 public String translate() {
 84  0
                         return documentId + SPLIT + String.valueOf(runPostProcessor) + SPLIT + String.valueOf(shouldSearchAttributeIndex);
 85  
                 }
 86  
         }
 87  
 
 88  
 }