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