1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
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 | |
|
34 | |
|
35 | |
|
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 | |
} |