Coverage Report - org.kuali.rice.ken.postprocessor.kew.NotificationSenderFormPostProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
NotificationSenderFormPostProcessor
0%
0/31
0%
0/2
1.333
 
 1  
 /*
 2  
  * Copyright 2006-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  
 
 17  
 package org.kuali.rice.ken.postprocessor.kew;
 18  
 
 19  
 import java.rmi.RemoteException;
 20  
 
 21  
 import org.apache.log4j.Logger;
 22  
 import org.kuali.rice.core.framework.persistence.dao.GenericDao;
 23  
 import org.kuali.rice.ken.bo.Notification;
 24  
 import org.kuali.rice.ken.core.GlobalNotificationServiceLocator;
 25  
 import org.kuali.rice.ken.document.kew.NotificationWorkflowDocument;
 26  
 import org.kuali.rice.ken.service.NotificationMessageContentService;
 27  
 import org.kuali.rice.ken.service.NotificationService;
 28  
 import org.kuali.rice.ken.util.Util;
 29  
 import org.kuali.rice.kew.dto.ActionTakenEventDTO;
 30  
 import org.kuali.rice.kew.dto.AfterProcessEventDTO;
 31  
 import org.kuali.rice.kew.dto.BeforeProcessEventDTO;
 32  
 import org.kuali.rice.kew.dto.DeleteEventDTO;
 33  
 import org.kuali.rice.kew.dto.DocumentLockingEventDTO;
 34  
 import org.kuali.rice.kew.dto.DocumentRouteLevelChangeDTO;
 35  
 import org.kuali.rice.kew.dto.DocumentRouteStatusChangeDTO;
 36  
 import org.kuali.rice.kew.postprocessor.PostProcessorRemote;
 37  
 import org.kuali.rice.kew.util.KEWConstants;
 38  
 
 39  
 
 40  
 /**
 41  
  * This class is the post processor that gets run when the general notification 
 42  
  * message sending form is approved by its reviewers.
 43  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 44  
  */
 45  
 public class NotificationSenderFormPostProcessor implements PostProcessorRemote {
 46  0
     private static final Logger LOG = Logger.getLogger(NotificationSenderFormPostProcessor.class);
 47  
     
 48  
     NotificationService notificationService;
 49  
     GenericDao businessObjectDao;
 50  
     NotificationMessageContentService messageContentService;
 51  
     
 52  
     /**
 53  
      * Constructs a NotificationSenderFormPostProcessor instance.
 54  
      */
 55  0
     public NotificationSenderFormPostProcessor() {
 56  0
         this.notificationService = GlobalNotificationServiceLocator.getInstance().getNotificationService();
 57  0
         this.businessObjectDao = GlobalNotificationServiceLocator.getInstance().getGenericDao();
 58  0
         this.messageContentService = GlobalNotificationServiceLocator.getInstance().getNotificationMessageContentService();
 59  0
     }
 60  
 
 61  
     /**
 62  
      * Constructs a NotificationSenderFormPostProcessor instance.
 63  
      * @param notificationService
 64  
      * @param businessObjectDao
 65  
      */
 66  0
     public NotificationSenderFormPostProcessor(NotificationService notificationService, GenericDao businessObjectDao) {
 67  0
         this.notificationService = notificationService;
 68  0
         this.businessObjectDao = businessObjectDao;
 69  0
     }
 70  
     
 71  
     /**
 72  
      * @see org.kuali.rice.kew.postprocessor.PostProcessorRemote#doActionTaken(org.kuali.rice.kew.dto.ActionTakenEventDTO)
 73  
      */
 74  
     public boolean doActionTaken(ActionTakenEventDTO arg0) throws RemoteException {
 75  0
         return true;
 76  
     }
 77  
 
 78  
     /**
 79  
      * @see org.kuali.rice.kew.postprocessor.PostProcessorRemote#doDeleteRouteHeader(org.kuali.rice.kew.dto.DeleteEventDTO)
 80  
      */
 81  
     public boolean doDeleteRouteHeader(DeleteEventDTO arg0) throws RemoteException {
 82  0
         return true;
 83  
     }
 84  
 
 85  
     /**
 86  
      * @see org.kuali.rice.kew.postprocessor.PostProcessorRemote#doRouteLevelChange(org.kuali.rice.kew.dto.DocumentRouteLevelChangeDTO)
 87  
      */
 88  
     public boolean doRouteLevelChange(DocumentRouteLevelChangeDTO arg0) throws RemoteException {
 89  0
         return true;
 90  
     }
 91  
 
 92  
     /**
 93  
      * When the EDL simple message sending form is submitted, it is routed straight to FINAL and at that time (when RESOLVED), we 
 94  
      * actually send the notification.
 95  
      * @see org.kuali.rice.kew.postprocessor.PostProcessorRemote#doRouteStatusChange(org.kuali.rice.kew.dto.DocumentRouteStatusChangeDTO)
 96  
      */
 97  
     public boolean doRouteStatusChange(DocumentRouteStatusChangeDTO arg0) throws RemoteException {
 98  0
         LOG.debug("ENTERING NotificationSenderFormPostProcessor.doRouteStatusChange() for Notification Sender Form with document ID: " + arg0.getDocumentId());
 99  
         
 100  0
         if(arg0.getNewRouteStatus().equals(KEWConstants.ROUTE_HEADER_PROCESSED_CD)) {
 101  0
             LOG.debug("Workflow status has changed to RESOLVED for Notification Sender Form with document ID: " + arg0.getDocumentId() + 
 102  
                     ".  We are now calling the NotificationService.sendNotification() service.");
 103  
             
 104  
             // obtain a workflow user object first
 105  
             //NetworkIdDTO proxyUser = new NetworkIdDTO(Util.getNotificationSystemUser());
 106  0
         String proxyUserId = Util.getNotificationSystemUser();
 107  
                 
 108  
             // now construct the workflow document, which will interact with workflow
 109  
             NotificationWorkflowDocument document;
 110  
             try {        
 111  0
                 document = NotificationWorkflowDocument.loadNotificationDocument(proxyUserId, arg0.getDocumentId());
 112  
                 
 113  0
                 LOG.debug("XML:" + document.getApplicationContent());
 114  
                 
 115  
                 //parse out the application content into a Notification BO
 116  0
                 Notification notification = messageContentService.parseSerializedNotificationXml(document.getApplicationContent().getBytes());
 117  
                 
 118  0
                 LOG.debug("Notification Content: " + notification.getContent());
 119  
                 
 120  
                 // send the notification
 121  0
                 notificationService.sendNotification(notification);
 122  
                 
 123  0
                 LOG.debug("NotificationService.sendNotification() was successfully called for Notification Sender Form with document ID: " + arg0.getDocumentId());
 124  0
             } catch(Exception e) {
 125  0
                 throw new RuntimeException(e);
 126  0
             }
 127  
         }
 128  
         
 129  0
         LOG.debug("LEAVING NotificationSenderFormPostProcessor.doRouteStatusChange() for Notification Sender Form with document ID: " + arg0.getDocumentId());
 130  0
         return true;
 131  
     }
 132  
 
 133  
     /**
 134  
      * @see org.kuali.rice.kew.postprocessor.PostProcessorRemote#beforeProcess(org.kuali.rice.kew.dto.BeforeProcessEventDTO)
 135  
      */
 136  
     public boolean beforeProcess(BeforeProcessEventDTO beforeProcessEvent) throws Exception {
 137  0
         return true;
 138  
     }
 139  
 
 140  
     /**
 141  
      * @see org.kuali.rice.kew.postprocessor.PostProcessorRemote#afterProcess(org.kuali.rice.kew.dto.AfterProcessEventDTO)
 142  
      */
 143  
     public boolean afterProcess(AfterProcessEventDTO afterProcessEvent) throws Exception {
 144  0
         return true;
 145  
     }
 146  
     
 147  
     /**
 148  
      * @see org.kuali.rice.kew.postprocessor.PostProcessorRemote#getDocumentIdsToLock(org.kuali.rice.kew.dto.DocumentLockingEventDTO)
 149  
      */
 150  
         public String[] getDocumentIdsToLock(DocumentLockingEventDTO documentLockingEvent) throws Exception {
 151  0
                 return null;
 152  
         }
 153  
         
 154  
 }