001: /*
002: * Copyright 2005-2006 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.opensource.org/licenses/ecl1.php
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package edu.iu.uis.eden.messaging;
018:
019: import javax.xml.namespace.QName;
020:
021: import org.apache.commons.lang.StringUtils;
022: import org.kuali.bus.services.KSBServiceLocator;
023:
024: import edu.iu.uis.eden.actionrequests.DocumentRequeuerService;
025: import edu.iu.uis.eden.actions.asyncservices.ActionInvocationService;
026: import edu.iu.uis.eden.actions.asyncservices.BlanketApproveProcessorService;
027: import edu.iu.uis.eden.actions.asyncservices.MoveDocumentService;
028: import edu.iu.uis.eden.docsearch.SearchableAttributeProcessingService;
029: import edu.iu.uis.eden.mail.ActionListImmediateEmailReminderService;
030: import edu.iu.uis.eden.routeheader.DocumentRouteHeaderValue;
031: import edu.iu.uis.eden.routetemplate.RuleCacheProcessor;
032:
033: /**
034: * Utility class for accessing names of common asynchronous services.
035: *
036: * @author rkirkend
037: */
038: public class MessageServiceNames {
039:
040: public static final String DOCUMENT_ROUTING_SERVICE = "DocumentRoutingService";
041:
042: public static final String ACTION_LIST_IMMEDIATE_REMINDER_SERVICE = "ImmediateEmailService";
043:
044: public static final String BLANKET_APPROVE_PROCESSING_SERVICE = "BlanketApproveProcessorService";
045:
046: public static final String SEARCHABLE_ATTRIBUTE_PROCESSING_SERVICE = "SearchableAttributeProcessorService";
047:
048: public static final String DOCUMENT_REQUEUE_PROCESSING_SERVICE = "DocumentRequeueProcessorService";
049:
050: public static final String WORKGROUP_MEMBERSHIP_CHANGE_SERVICE = "WorkgroupMembershipChangeService";
051:
052: public static final String SERVICE_REMOVER_SERVICE = "RemoteClassRemoverService";
053:
054: public static final String RULE_CACHE_PROCESSOR_SERVICE = "RuleCacheProcessorService";
055:
056: public static final String ROLE_POKER = "RolePokerProcessorService";
057:
058: public static final String MOVE_DOCUMENT_PROCESSOR = "MoveDocumentProcessor";
059:
060: public static final String ACTION_INVOCATION_PROCESSOR = "ActionInvocationProcessor";
061:
062: private static QName getQName(String baseServiceName,
063: DocumentRouteHeaderValue document) {
064: if (document != null) {
065: return new QName(document.getDocumentType()
066: .getMessageEntity(), baseServiceName);
067: }
068: return new QName(baseServiceName);
069: }
070:
071: private static QName getQName(String baseServiceName,
072: String messageEntity) {
073: if (!StringUtils.isEmpty(messageEntity)) {
074: return new QName(messageEntity, baseServiceName);
075: }
076: return new QName(baseServiceName);
077: }
078:
079: public static KEWXMLService getRouteDocumentMessageService(
080: DocumentRouteHeaderValue document) {
081: return (KEWXMLService) getServiceAsynchronously(getQName(
082: DOCUMENT_ROUTING_SERVICE, document), document);
083: }
084:
085: public static MoveDocumentService getMoveDocumentProcessorService(
086: DocumentRouteHeaderValue document) {
087: return (MoveDocumentService) getServiceAsynchronously(getQName(
088: MOVE_DOCUMENT_PROCESSOR, document), document);
089: }
090:
091: public static ActionInvocationService getActionInvocationProcessorService(
092: DocumentRouteHeaderValue document) {
093: return (ActionInvocationService) getServiceAsynchronously(
094: getQName(ACTION_INVOCATION_PROCESSOR, document),
095: document);
096: }
097:
098: public static BlanketApproveProcessorService getBlanketApproveProcessorService(
099: DocumentRouteHeaderValue document) {
100: return (BlanketApproveProcessorService) getServiceAsynchronously(
101: getQName(BLANKET_APPROVE_PROCESSING_SERVICE, document),
102: document);
103: }
104:
105: public static ActionListImmediateEmailReminderService getImmediateEmailService() {
106: return (ActionListImmediateEmailReminderService) getServiceAsynchronously(
107: getQName(ACTION_LIST_IMMEDIATE_REMINDER_SERVICE,
108: (DocumentRouteHeaderValue) null), (Long) null);
109: }
110:
111: public static SearchableAttributeProcessingService getSearchableAttributeService(
112: DocumentRouteHeaderValue document) {
113: return (SearchableAttributeProcessingService) getServiceAsynchronously(
114: getQName(SEARCHABLE_ATTRIBUTE_PROCESSING_SERVICE,
115: document), document);
116: }
117:
118: public static RuleCacheProcessor getRuleCacheProcessor() {
119: return (RuleCacheProcessor) getServiceAsynchronously(new QName(
120: MessageServiceNames.RULE_CACHE_PROCESSOR_SERVICE),
121: (Long) null);
122: }
123:
124: public static DocumentRequeuerService getDocumentRequeuerService(
125: String messageEntity, Long documentId, long waitTime) {
126: QName serviceName = getQName(
127: DOCUMENT_REQUEUE_PROCESSING_SERVICE, messageEntity);
128: if (waitTime > 0) {
129: return (DocumentRequeuerService) getDelayedServiceAsynchronously(
130: serviceName, documentId, waitTime);
131: }
132: return (DocumentRequeuerService) getServiceAsynchronously(
133: serviceName, documentId);
134: }
135:
136: public static Object getServiceAsynchronously(QName serviceName,
137: DocumentRouteHeaderValue document) {
138: return getServiceAsynchronously(serviceName, getDocId(document));
139: }
140:
141: public static Object getServiceAsynchronously(QName serviceName,
142: Long documentId) {
143: return KSBServiceLocator.getMessageHelper()
144: .getServiceAsynchronously(
145: serviceName,
146: null,
147: null,
148: (documentId == null ? null : documentId
149: .toString()), null);
150: }
151:
152: public static Object getDelayedServiceAsynchronously(
153: QName serviceName, DocumentRouteHeaderValue document,
154: long waitTime) {
155: return getDelayedServiceAsynchronously(serviceName,
156: getDocId(document), waitTime);
157: }
158:
159: public static Object getDelayedServiceAsynchronously(
160: QName serviceName, Long documentId, long waitTime) {
161: return KSBServiceLocator.getMessageHelper()
162: .getServiceAsynchronously(
163: serviceName,
164: null,
165: (documentId == null ? null : documentId
166: .toString()), null, waitTime);
167: }
168:
169: private static Long getDocId(DocumentRouteHeaderValue document) {
170: return (document == null ? null : document.getRouteHeaderId());
171: }
172:
173: }
|