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 javax.xml.namespace.QName;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.kuali.rice.kew.actionrequest.service.DocumentRequeuerService;
23 import org.kuali.rice.kew.actions.asyncservices.ActionInvocationService;
24 import org.kuali.rice.kew.actions.asyncservices.BlanketApproveProcessorService;
25 import org.kuali.rice.kew.actions.asyncservices.MoveDocumentService;
26 import org.kuali.rice.kew.api.KewApiConstants;
27 import org.kuali.rice.kew.api.KewApiServiceLocator;
28 import org.kuali.rice.kew.api.document.DocumentProcessingQueue;
29 import org.kuali.rice.kew.api.mail.ImmediateEmailReminderService;
30 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
31 import org.kuali.rice.ksb.api.KsbApiServiceLocator;
32 import org.kuali.rice.ksb.messaging.service.KSBXMLService;
33
34
35
36
37
38
39
40 public class MessageServiceNames {
41
42 public static final QName DOCUMENT_PROCESSING_QUEUE = new QName(KewApiConstants.Namespaces.KEW_NAMESPACE_2_0, "documentProcessingQueueSoap");
43
44 public static final String ACTION_LIST_IMMEDIATE_REMINDER_SERVICE = "ImmediateEmailService";
45
46 public static final QName BLANKET_APPROVE_PROCESSING_SERVICE = new QName(KewApiConstants.Namespaces.KEW_NAMESPACE_2_0, "BlanketApproveProcessorService");
47
48 public static final QName DOCUMENT_REQUEUE_PROCESSING_SERVICE = new QName(KewApiConstants.Namespaces.KEW_NAMESPACE_2_0, "DocumentRequeueProcessorService");
49
50 public static final QName ROLE_POKER = new QName(KewApiConstants.Namespaces.KEW_NAMESPACE_2_0, "RolePokerProcessorService");
51
52 public static final String MOVE_DOCUMENT_PROCESSOR = "MoveDocumentProcessor";
53
54 public static final String ACTION_INVOCATION_PROCESSOR = "ActionInvocationProcessor";
55
56 private static QName getQName(String baseServiceName, DocumentRouteHeaderValue document) {
57 if (document != null) {
58 return new QName(document.getDocumentType().getApplicationId(), baseServiceName);
59 }
60 return new QName(baseServiceName);
61 }
62
63 private static QName getQName(String baseServiceName, String applicationId) {
64 if (!StringUtils.isEmpty(applicationId)) {
65 return new QName(applicationId, baseServiceName);
66 }
67 return new QName(baseServiceName);
68 }
69
70 public static DocumentProcessingQueue getDocumentProcessingQueue(DocumentRouteHeaderValue document) {
71 return (DocumentProcessingQueue)getServiceAsynchronously(DOCUMENT_PROCESSING_QUEUE, document);
72 }
73
74 public static MoveDocumentService getMoveDocumentProcessorService(DocumentRouteHeaderValue document) {
75 return (MoveDocumentService) getServiceAsynchronously(getQName(MOVE_DOCUMENT_PROCESSOR, document), document);
76 }
77
78 public static ActionInvocationService getActionInvocationProcessorService(DocumentRouteHeaderValue document) {
79 return (ActionInvocationService) getServiceAsynchronously(getQName(ACTION_INVOCATION_PROCESSOR, document), document);
80 }
81
82 public static BlanketApproveProcessorService getBlanketApproveProcessorService(DocumentRouteHeaderValue document) {
83 return (BlanketApproveProcessorService) getServiceAsynchronously(BLANKET_APPROVE_PROCESSING_SERVICE, document);
84 }
85
86 public static DocumentRequeuerService getDocumentRequeuerService(String applicationId, String documentId, long waitTime) {
87 if (waitTime > 0) {
88 return (DocumentRequeuerService) getDelayedServiceAsynchronously(DOCUMENT_REQUEUE_PROCESSING_SERVICE, documentId, waitTime);
89 }
90 return (DocumentRequeuerService) getServiceAsynchronously(DOCUMENT_REQUEUE_PROCESSING_SERVICE, documentId, applicationId);
91 }
92
93 public static Object getServiceAsynchronously(QName serviceName, DocumentRouteHeaderValue document) {
94 String applicationId = document.getDocumentType().getApplicationId();
95 return getServiceAsynchronously(serviceName, getDocId(document), applicationId);
96 }
97
98 public static Object getServiceAsynchronously(QName serviceName, String documentId, String applicationId) {
99 return KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName, applicationId, null, null, (documentId == null ? null : documentId.toString()), null);
100 }
101
102 public static Object getDelayedServiceAsynchronously(QName serviceName, DocumentRouteHeaderValue document, long waitTime) {
103 return getDelayedServiceAsynchronously(serviceName, getDocId(document), waitTime);
104 }
105
106 public static Object getDelayedServiceAsynchronously(QName serviceName, String documentId, long waitTime) {
107 return KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName, null, (documentId == null ? null : documentId.toString()), null, waitTime);
108 }
109
110 private static String getDocId(DocumentRouteHeaderValue document) {
111 return (document == null ? null : document.getDocumentId());
112 }
113
114 }