| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package org.kuali.rice.kew.messaging; |
| 18 | |
|
| 19 | |
import org.apache.log4j.Logger; |
| 20 | |
import org.kuali.rice.kew.api.WorkflowRuntimeException; |
| 21 | |
import org.kuali.rice.kew.docsearch.service.SearchableAttributeProcessingService; |
| 22 | |
import org.kuali.rice.kew.engine.WorkflowEngine; |
| 23 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
| 24 | |
import org.kuali.rice.ksb.messaging.service.KSBXMLService; |
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | 0 | public class RouteDocumentMessageService implements KSBXMLService { |
| 33 | |
|
| 34 | 0 | private static final Logger LOG = Logger.getLogger(RouteDocumentMessageService.class); |
| 35 | |
|
| 36 | |
public void invoke(String xml) { |
| 37 | |
try { |
| 38 | 0 | RouteMessageXmlElement newElement = RouteMessageXmlElement.construct(xml); |
| 39 | 0 | WorkflowEngine engine = KEWServiceLocator.getWorkflowEngine(); |
| 40 | 0 | engine.setRunPostProcessorLogic(newElement.runPostProcessor); |
| 41 | 0 | engine.process(newElement.documentId, null); |
| 42 | 0 | if (newElement.shouldSearchAttributeIndex) { |
| 43 | 0 | SearchableAttributeProcessingService searchableAttService = (SearchableAttributeProcessingService) MessageServiceNames.getSearchableAttributeService(KEWServiceLocator.getRouteHeaderService().getRouteHeader(newElement.documentId)); |
| 44 | 0 | searchableAttService.indexDocument(newElement.documentId); |
| 45 | |
} |
| 46 | 0 | } catch (Exception e) { |
| 47 | 0 | LOG.error(e); |
| 48 | 0 | throw new WorkflowRuntimeException(e); |
| 49 | 0 | } |
| 50 | 0 | } |
| 51 | |
|
| 52 | 0 | public static class RouteMessageXmlElement { |
| 53 | |
public String documentId; |
| 54 | 0 | public boolean runPostProcessor = true; |
| 55 | 0 | public boolean shouldSearchAttributeIndex = false; |
| 56 | 0 | public RouteMessageXmlElement(String documentId) { |
| 57 | 0 | this.documentId = documentId; |
| 58 | 0 | } |
| 59 | |
public RouteMessageXmlElement(String documentId, boolean runPostProcessor) { |
| 60 | 0 | this(documentId); |
| 61 | 0 | this.runPostProcessor = runPostProcessor; |
| 62 | 0 | } |
| 63 | |
public RouteMessageXmlElement(String documentId, boolean runPostProcessor, boolean shouldIndex) { |
| 64 | 0 | this(documentId, runPostProcessor); |
| 65 | 0 | this.shouldSearchAttributeIndex = shouldIndex; |
| 66 | 0 | } |
| 67 | |
private static final String SPLIT = "::~~::"; |
| 68 | |
public static RouteMessageXmlElement construct(String content) { |
| 69 | 0 | if (content.contains(SPLIT)) { |
| 70 | 0 | String[] values = content.split(SPLIT); |
| 71 | 0 | if (values.length == 3) { |
| 72 | 0 | return new RouteMessageXmlElement(values[0], Boolean.valueOf(values[1]), Boolean.valueOf(values[2])); |
| 73 | |
} else { |
| 74 | 0 | return new RouteMessageXmlElement(values[0],Boolean.valueOf(values[1])); |
| 75 | |
} |
| 76 | |
} else { |
| 77 | 0 | return new RouteMessageXmlElement(content); |
| 78 | |
} |
| 79 | |
} |
| 80 | |
public String translate() { |
| 81 | 0 | return documentId + SPLIT + String.valueOf(runPostProcessor) + SPLIT + String.valueOf(shouldSearchAttributeIndex); |
| 82 | |
} |
| 83 | |
} |
| 84 | |
|
| 85 | |
} |