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-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * 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
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.kew.messaging.exceptionhandling;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.kew.api.WorkflowRuntimeException;
 20  
 import org.kuali.rice.kew.service.KEWServiceLocator;
 21  
 import org.kuali.rice.ksb.messaging.PersistedMessageBO;
 22  
 import org.kuali.rice.ksb.messaging.exceptionhandling.DefaultMessageExceptionHandler;
 23  
 import org.kuali.rice.ksb.messaging.exceptionhandling.MessageExceptionHandler;
 24  
 import org.kuali.rice.ksb.service.KSBServiceLocator;
 25  
 
 26  
 /**
 27  
  * A {@link MessageExceptionHandler} which handles putting documents into
 28  
  * exception routing.
 29  
  * 
 30  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 31  
  */
 32  0
 public class DocumentMessageExceptionHandler extends DefaultMessageExceptionHandler {
 33  
 
 34  
         @Override
 35  
         protected void placeInException(Throwable throwable, PersistedMessageBO message) throws Exception {
 36  0
                 KEWServiceLocator.getExceptionRoutingService().placeInExceptionRouting(throwable, message, getDocumentId(message));
 37  0
         }
 38  
         
 39  
         
 40  
 
 41  
         @Override
 42  
         public void handleExceptionLastDitchEffort(Throwable throwable, PersistedMessageBO message, Object service) throws Exception {
 43  0
                 KEWServiceLocator.getExceptionRoutingService().placeInExceptionRoutingLastDitchEffort(throwable, message, getDocumentId(message));
 44  0
         }
 45  
 
 46  
 
 47  
 
 48  
         @Override
 49  
         protected void scheduleExecution(Throwable throwable, PersistedMessageBO message) throws Exception {
 50  0
                 String description = "DocumentId: " + getDocumentId(message);
 51  0
                 KSBServiceLocator.getExceptionRoutingService().scheduleExecution(throwable, message, description);
 52  0
         }
 53  
 
 54  
         protected String getDocumentId(PersistedMessageBO message) {
 55  0
                 if (!StringUtils.isEmpty(message.getValue1())) {
 56  0
                         return message.getValue1();
 57  
                 }
 58  0
                 throw new WorkflowRuntimeException("Unable to put this message in exception routing service name " + message.getServiceName());
 59  
         }
 60  
 }