Coverage Report - org.kuali.rice.kew.messaging.MessageServiceNames
 
Classes in this File Line Coverage Branch Coverage Complexity
MessageServiceNames
0%
0/23
0%
0/12
1.6
 
 1  
 /*
 2  
  * Copyright 2005-2008 The Kuali Foundation
 3  
  *
 4  
  *
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 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.docsearch.service.SearchableAttributeProcessingService;
 27  
 import org.kuali.rice.kew.mail.service.ActionListImmediateEmailReminderService;
 28  
 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
 29  
 import org.kuali.rice.kew.rule.service.RuleCacheProcessor;
 30  
 import org.kuali.rice.ksb.api.KsbApiServiceLocator;
 31  
 import org.kuali.rice.ksb.messaging.service.KSBXMLService;
 32  
 
 33  
 
 34  
 /**
 35  
  * Utility class for accessing names of common asynchronous services.
 36  
  *
 37  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 38  
  */
 39  0
 public class MessageServiceNames {
 40  
 
 41  
         public static final String DOCUMENT_ROUTING_SERVICE = "DocumentRoutingService";
 42  
 
 43  
         public static final String ACTION_LIST_IMMEDIATE_REMINDER_SERVICE = "ImmediateEmailService";
 44  
 
 45  
         public static final String BLANKET_APPROVE_PROCESSING_SERVICE = "BlanketApproveProcessorService";
 46  
 
 47  
         public static final String SEARCHABLE_ATTRIBUTE_PROCESSING_SERVICE = "SearchableAttributeProcessorService";
 48  
 
 49  
         public static final String DOCUMENT_REQUEUE_PROCESSING_SERVICE = "DocumentRequeueProcessorService";
 50  
 
 51  
         public static final String WORKGROUP_MEMBERSHIP_CHANGE_SERVICE = "WorkgroupMembershipChangeService";
 52  
 
 53  
         public static final String SERVICE_REMOVER_SERVICE = "RemoteClassRemoverService";
 54  
 
 55  
         public static final String RULE_CACHE_PROCESSOR_SERVICE = "RuleCacheProcessorService";
 56  
 
 57  
         public static final String ROLE_POKER = "RolePokerProcessorService";
 58  
 
 59  
         public static final String MOVE_DOCUMENT_PROCESSOR = "MoveDocumentProcessor";
 60  
 
 61  
         public static final String ACTION_INVOCATION_PROCESSOR = "ActionInvocationProcessor";
 62  
 
 63  
         public static final String RESPONSIBILITY_CHANGE_SERVICE = "ResponsibilityChangeService";
 64  
 
 65  
         private static QName getQName(String baseServiceName, DocumentRouteHeaderValue document) {
 66  0
                 if (document != null) {
 67  0
                         return new QName(document.getDocumentType().getApplicationId(), baseServiceName);
 68  
                 }
 69  0
                 return new QName(baseServiceName);
 70  
         }
 71  
 
 72  
         private static QName getQName(String baseServiceName, String applicationId) {
 73  0
                 if (!StringUtils.isEmpty(applicationId)) {
 74  0
                         return new QName(applicationId, baseServiceName);
 75  
                 }
 76  0
                 return new QName(baseServiceName);
 77  
         }
 78  
 
 79  
         public static KSBXMLService getRouteDocumentMessageService(DocumentRouteHeaderValue document) {
 80  0
                 return (KSBXMLService) getServiceAsynchronously(getQName(DOCUMENT_ROUTING_SERVICE, document), document);
 81  
         }
 82  
 
 83  
         public static MoveDocumentService getMoveDocumentProcessorService(DocumentRouteHeaderValue document) {
 84  0
                 return (MoveDocumentService) getServiceAsynchronously(getQName(MOVE_DOCUMENT_PROCESSOR, document), document);
 85  
         }
 86  
 
 87  
         public static ActionInvocationService getActionInvocationProcessorService(DocumentRouteHeaderValue document) {
 88  0
                 return (ActionInvocationService) getServiceAsynchronously(getQName(ACTION_INVOCATION_PROCESSOR, document), document);
 89  
         }
 90  
 
 91  
         public static BlanketApproveProcessorService getBlanketApproveProcessorService(DocumentRouteHeaderValue document) {
 92  0
                 return (BlanketApproveProcessorService) getServiceAsynchronously(getQName(BLANKET_APPROVE_PROCESSING_SERVICE, document), document);
 93  
         }
 94  
 
 95  
         public static ActionListImmediateEmailReminderService getImmediateEmailService() {
 96  0
                 return (ActionListImmediateEmailReminderService) getServiceAsynchronously(getQName(ACTION_LIST_IMMEDIATE_REMINDER_SERVICE, (DocumentRouteHeaderValue) null), (String)null);
 97  
         }
 98  
 
 99  
         public static SearchableAttributeProcessingService getSearchableAttributeService(DocumentRouteHeaderValue document) {
 100  0
                 return (SearchableAttributeProcessingService) getServiceAsynchronously(getQName(SEARCHABLE_ATTRIBUTE_PROCESSING_SERVICE, document), document);
 101  
         }
 102  
 
 103  
         public static RuleCacheProcessor getRuleCacheProcessor() {
 104  0
                 return (RuleCacheProcessor) getServiceAsynchronously(new QName(MessageServiceNames.RULE_CACHE_PROCESSOR_SERVICE), (String)null);
 105  
         }
 106  
 
 107  
         public static DocumentRequeuerService getDocumentRequeuerService(String applicationId, String documentId, long waitTime) {
 108  0
                 QName serviceName = getQName(DOCUMENT_REQUEUE_PROCESSING_SERVICE, applicationId);
 109  0
                 if (waitTime > 0) {
 110  0
                         return (DocumentRequeuerService) getDelayedServiceAsynchronously(serviceName, documentId, waitTime);
 111  
                 }
 112  0
                 return (DocumentRequeuerService) getServiceAsynchronously(serviceName, documentId);
 113  
         }
 114  
 
 115  
         public static Object getServiceAsynchronously(QName serviceName, DocumentRouteHeaderValue document) {
 116  0
                 return getServiceAsynchronously(serviceName, getDocId(document));
 117  
         }
 118  
 
 119  
         public static Object getServiceAsynchronously(QName serviceName, String documentId) {
 120  0
                 return KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName, null, null, (documentId == null ? null : documentId.toString()), null);
 121  
         }
 122  
 
 123  
         public static Object getDelayedServiceAsynchronously(QName serviceName, DocumentRouteHeaderValue document, long waitTime) {
 124  0
                 return getDelayedServiceAsynchronously(serviceName, getDocId(document), waitTime);
 125  
         }
 126  
 
 127  
         public static Object getDelayedServiceAsynchronously(QName serviceName, String documentId, long waitTime) {
 128  0
                 return KsbApiServiceLocator.getMessageHelper().getServiceAsynchronously(serviceName, null, (documentId == null ? null : documentId.toString()), null, waitTime);
 129  
         }
 130  
 
 131  
         private static String getDocId(DocumentRouteHeaderValue document) {
 132  0
                 return (document == null ? null : document.getDocumentId());
 133  
         }
 134  
 
 135  
 }