Coverage Report - org.kuali.rice.ken.service.ws.impl.NotificationWebServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
NotificationWebServiceImpl
0%
0/19
N/A
3
 
 1  
 /*
 2  
  * Copyright 2007 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.ken.service.ws.impl;
 17  
 
 18  
 import java.io.IOException;
 19  
 import java.rmi.RemoteException;
 20  
 
 21  
 import org.apache.log4j.Logger;
 22  
 import org.kuali.rice.ken.bo.NotificationResponse;
 23  
 import org.kuali.rice.ken.exception.InvalidXMLException;
 24  
 import org.kuali.rice.ken.service.NotificationMessageContentService;
 25  
 import org.kuali.rice.ken.service.NotificationService;
 26  
 import org.kuali.rice.ken.service.ws.NotificationWebService;
 27  
 import org.kuali.rice.ken.util.NotificationConstants;
 28  
 import org.kuali.rice.ken.util.PerformanceLog;
 29  
 import org.kuali.rice.ken.util.PerformanceLog.PerformanceStopWatch;
 30  
 
 31  
 /**
 32  
  * Web service interface implementation that delegates directly to Spring service
 33  
  * Spring integration strategy taken from:
 34  
  * http://javaboutique.internet.com/tutorials/axisspring/
 35  
  * This class extends ServletEndpointSupport so that it can obtain the Notification System Spring context
 36  
  * from the ServletContext via getWebApplicationContext().  It then delegates to the NotificationService.
 37  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 38  
  */
 39  0
 public class NotificationWebServiceImpl /*extends ServletEndpointSupport*/ implements NotificationWebService {
 40  0
     private static final Logger LOG = Logger.getLogger(NotificationWebServiceImpl.class);
 41  
 
 42  
     private NotificationService notificationService;
 43  
     private NotificationMessageContentService notificationMessageContentService;
 44  
 
 45  
     /**
 46  
      * Callback for custom initialization after the context has been set up.
 47  
      * @throws ServiceException if initialization failed
 48  
      */
 49  
     /*protected void onInit() throws ServiceException {
 50  
         // grab the spring application context from the webapp context so that we can look up our service in spring 
 51  
         NotificationServiceLocator locator = new SpringNotificationServiceLocator(getWebApplicationContext());
 52  
         this.notificationService = locator.getNotificationService();
 53  
         this.notificationMessageContentService = locator.getNotificationMessageContentService();
 54  
     }*/
 55  
 
 56  
     /**
 57  
      * Invokes the underlying Java API calls via Spring service invocation.
 58  
      * @see org.kuali.rice.ken.service.ws.NotificationWebService#sendNotification(java.lang.String)
 59  
      */
 60  
     public String sendNotification(String notificationMessageAsXml) throws RemoteException {
 61  0
         PerformanceStopWatch watch = PerformanceLog.startTimer("Time to send notification from web service");
 62  
         
 63  
         NotificationResponse response;
 64  
         try {
 65  0
             response = notificationService.sendNotification(notificationMessageAsXml);
 66  
 
 67  0
         } catch(IOException ioe) {
 68  0
             response = new NotificationResponse();
 69  0
             response.setStatus(NotificationConstants.RESPONSE_STATUSES.FAILURE);
 70  0
             response.setMessage("Failed to process the message content: " + ioe.getMessage());
 71  0
             LOG.error("Failed to process the message content", ioe);
 72  0
         } catch(InvalidXMLException ixe) {
 73  0
             response = new NotificationResponse();
 74  0
             response.setStatus(NotificationConstants.RESPONSE_STATUSES.FAILURE);
 75  0
             response.setMessage("Failed to process the message content because the XML message provided to the system was invalid: " + ixe.getMessage());
 76  0
             LOG.error("Failed to process the message content because the XML message provided to the system was invalid", ixe);
 77  0
         }
 78  
 
 79  0
         String responseAsXml = notificationMessageContentService.generateNotificationResponseMessage(response);
 80  
 
 81  0
         watch.recordDuration();
 82  
         
 83  0
         LOG.info("Notification response: " + response);
 84  
         
 85  0
         return responseAsXml;
 86  
     }
 87  
 }