1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.messaging; |
17 | |
|
18 | |
import javax.xml.namespace.QName; |
19 | |
|
20 | |
import org.apache.commons.lang.StringUtils; |
21 | |
import org.kuali.rice.kew.api.action.RolePokerQueue; |
22 | |
import org.kuali.rice.kew.api.document.DocumentOrchestrationQueue; |
23 | |
import org.kuali.rice.kew.api.document.DocumentRefreshQueue; |
24 | |
import org.kuali.rice.kew.api.action.ActionInvocationQueue; |
25 | |
import org.kuali.rice.kew.api.KewApiConstants; |
26 | |
import org.kuali.rice.kew.api.document.DocumentProcessingQueue; |
27 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
28 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
29 | |
import org.kuali.rice.ksb.api.KsbApiServiceLocator; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | 0 | public class MessageServiceNames { |
37 | |
|
38 | 0 | private static final QName DOCUMENT_PROCESSING_QUEUE = new QName(KewApiConstants.Namespaces.KEW_NAMESPACE_2_0, "documentProcessingQueue"); |
39 | |
|
40 | 0 | private static final QName DOCUMENT_ORCHESTRATION_QUEUE = new QName(KewApiConstants.Namespaces.KEW_NAMESPACE_2_0, "documentOrchestrationQueue"); |
41 | |
|
42 | 0 | private static final QName DOCUMENT_REFRESH_QUEUE = new QName(KewApiConstants.Namespaces.KEW_NAMESPACE_2_0, "documentRefreshQueue"); |
43 | |
|
44 | 0 | private static final QName ROLE_POKER_QUEUE = new QName(KewApiConstants.Namespaces.KEW_NAMESPACE_2_0, "rolePokerQueue"); |
45 | |
|
46 | 0 | private static final QName ACTION_INVOCATION_QUEUE = new QName(KewApiConstants.Namespaces.KEW_NAMESPACE_2_0, "actionInvocationQueue"); |
47 | |
|
48 | |
private static QName getQName(String baseServiceName, DocumentRouteHeaderValue document) { |
49 | 0 | if (document != null) { |
50 | 0 | return new QName(document.getDocumentType().getApplicationId(), baseServiceName); |
51 | |
} |
52 | 0 | return new QName(baseServiceName); |
53 | |
} |
54 | |
|
55 | |
public static DocumentProcessingQueue getDocumentProcessingQueue(DocumentRouteHeaderValue document) { |
56 | 0 | return (DocumentProcessingQueue)getServiceAsynchronously(DOCUMENT_PROCESSING_QUEUE, document); |
57 | |
} |
58 | |
|
59 | |
public static ActionInvocationQueue getActionInvocationProcessorService(DocumentRouteHeaderValue document) { |
60 | 0 | return (ActionInvocationQueue) getServiceAsynchronously(ACTION_INVOCATION_QUEUE, document); |
61 | |
} |
62 | |
|
63 | |
public static DocumentOrchestrationQueue getDocumentOrchestrationQueue(DocumentRouteHeaderValue document) { |
64 | 0 | return (DocumentOrchestrationQueue) getServiceAsynchronously(DOCUMENT_ORCHESTRATION_QUEUE, document); |
65 | |
} |
66 | |
|
67 | |
public static RolePokerQueue getRolePokerQueue(String documentId) { |
68 | 0 | return (RolePokerQueue) getServiceAsynchronously(ROLE_POKER_QUEUE, documentId); |
69 | |
} |
70 | |
|
71 | |
public static DocumentRefreshQueue getDocumentRequeuerService(String applicationId, String documentId, long waitTime) { |
72 | 0 | if (waitTime > 0) { |
73 | 0 | return (DocumentRefreshQueue) getDelayedServiceAsynchronously(DOCUMENT_REFRESH_QUEUE, documentId, waitTime); |
74 | |
} |
75 | 0 | return (DocumentRefreshQueue) getServiceAsynchronously(DOCUMENT_REFRESH_QUEUE, documentId, applicationId); |
76 | |
} |
77 | |
|
78 | |
public static Object getServiceAsynchronously(QName serviceName, DocumentRouteHeaderValue document) { |
79 | 0 | String applicationId = document.getDocumentType().getApplicationId(); |
80 | 0 | return getServiceAsynchronously(serviceName, getDocId(document), applicationId); |
81 | |
} |
82 | |
|
83 | |
public static Object getServiceAsynchronously(QName serviceName, String documentId) { |
84 | 0 | String applicationId = null; |
85 | 0 | if (StringUtils.isNotBlank(documentId)) { |
86 | 0 | applicationId = KEWServiceLocator.getRouteHeaderService().getApplicationIdByDocumentId(documentId); |
87 | |
} |
88 | 0 | return getServiceAsynchronously(serviceName, documentId, applicationId); |
89 | |
} |
90 | |
|
91 | |
public static Object getServiceAsynchronously(QName serviceName, String documentId, String applicationId) { |
92 | 0 | return KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName, applicationId, null, null, (documentId == null ? null : documentId.toString()), null); |
93 | |
} |
94 | |
|
95 | |
public static Object getDelayedServiceAsynchronously(QName serviceName, DocumentRouteHeaderValue document, long waitTime) { |
96 | 0 | return getDelayedServiceAsynchronously(serviceName, getDocId(document), waitTime); |
97 | |
} |
98 | |
|
99 | |
public static Object getDelayedServiceAsynchronously(QName serviceName, String documentId, long waitTime) { |
100 | 0 | return KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName, null, (documentId == null ? null : documentId.toString()), null, waitTime); |
101 | |
} |
102 | |
|
103 | |
private static String getDocId(DocumentRouteHeaderValue document) { |
104 | 0 | return (document == null ? null : document.getDocumentId()); |
105 | |
} |
106 | |
|
107 | |
} |