Coverage Report - org.kuali.rice.kew.messaging.exceptionhandling.DocumentMessageExceptionHandler
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentMessageExceptionHandler
0%
0/11
0%
0/2
1.75
 
 1  
 /*
 2  
  * Copyright 2005-2007 The Kuali Foundation
 3  
  * 
 4  
  * 
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in
 6  
  * compliance with the License. You may obtain a copy of the License at
 7  
  * 
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  * 
 10  
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS
 11  
  * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
 12  
  * language governing permissions and limitations under the License.
 13  
  */
 14  
 package org.kuali.rice.kew.messaging.exceptionhandling;
 15  
 
 16  
 import org.apache.commons.lang.StringUtils;
 17  
 import org.kuali.rice.kew.exception.WorkflowRuntimeException;
 18  
 import org.kuali.rice.kew.service.KEWServiceLocator;
 19  
 import org.kuali.rice.ksb.messaging.PersistedMessageBO;
 20  
 import org.kuali.rice.ksb.messaging.exceptionhandling.DefaultMessageExceptionHandler;
 21  
 import org.kuali.rice.ksb.messaging.exceptionhandling.MessageExceptionHandler;
 22  
 import org.kuali.rice.ksb.service.KSBServiceLocator;
 23  
 
 24  
 /**
 25  
  * A {@link MessageExceptionHandler} which handles putting documents into
 26  
  * exception routing.
 27  
  * 
 28  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 29  
  */
 30  0
 public class DocumentMessageExceptionHandler extends DefaultMessageExceptionHandler {
 31  
 
 32  
         @Override
 33  
         protected void placeInException(Throwable throwable, PersistedMessageBO message) throws Exception {
 34  0
                 KEWServiceLocator.getExceptionRoutingService().placeInExceptionRouting(throwable, message, getDocumentId(message));
 35  0
         }
 36  
         
 37  
         
 38  
 
 39  
         @Override
 40  
         public void handleExceptionLastDitchEffort(Throwable throwable, PersistedMessageBO message, Object service) throws Exception {
 41  0
                 KEWServiceLocator.getExceptionRoutingService().placeInExceptionRoutingLastDitchEffort(throwable, message, getDocumentId(message));
 42  0
         }
 43  
 
 44  
 
 45  
 
 46  
         @Override
 47  
         protected void scheduleExecution(Throwable throwable, PersistedMessageBO message) throws Exception {
 48  0
                 String description = "DocumentId: " + getDocumentId(message);
 49  0
                 KSBServiceLocator.getExceptionRoutingService().scheduleExecution(throwable, message, description);
 50  0
         }
 51  
 
 52  
         protected String getDocumentId(PersistedMessageBO message) {
 53  0
                 if (!StringUtils.isEmpty(message.getValue1())) {
 54  0
                         return message.getValue1();
 55  
                 }
 56  0
                 throw new WorkflowRuntimeException("Unable to put this message in exception routing service name " + message.getServiceName());
 57  
         }
 58  
 }