View Javadoc

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.ken.service.impl;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
20  import org.kuali.rice.ken.api.service.KENServiceConstants;
21  import org.kuali.rice.ken.api.service.SendNotificationService;
22  import org.kuali.rice.ken.bo.NotificationResponse;
23  import org.kuali.rice.ken.service.NotificationService;
24  import org.kuali.rice.ken.util.NotificationConstants;
25  import org.kuali.rice.kew.api.WorkflowRuntimeException;
26  import org.kuali.rice.kim.api.KimApiConstants;
27  import org.kuali.rice.ksb.messaging.service.KSBXMLService;
28  
29  import javax.jws.WebMethod;
30  import javax.jws.WebParam;
31  import javax.jws.WebService;
32  import javax.jws.soap.SOAPBinding;
33  
34  /**
35   * This class allows the NotificationService.sendNotification(XML) service 
36   * to be invoked as a web service generically from the bus.
37   * @author Kuali Rice Team (rice.collab@kuali.org)
38   */
39  public class SendNotificationServiceKewXmlImpl implements SendNotificationService {
40      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
41      .getLogger(SendNotificationServiceKewXmlImpl.class);
42  
43      private final NotificationService notificationService;
44  
45      /**
46       * Constructs a SendNotificationServiceKewXmlImpl instance.
47       * @param notificationService
48       */
49      public SendNotificationServiceKewXmlImpl(NotificationService notificationService) {
50          this.notificationService = notificationService;
51      }
52  
53      /**
54       * Actually invokes the sendNotification() service method.  The KSB calls 
55       * this.
56       * @see org.kuali.rice.ksb.messaging.service.KSBXMLService#invoke(java.lang.String)
57       */
58      @Override
59      public void invoke(String message) {
60          if (StringUtils.isBlank(message)) {
61              throw new RiceIllegalArgumentException("xml is null or blank");
62          }
63  
64          try {
65             NotificationResponse response = notificationService.sendNotification(message);
66             LOG.info(response.getMessage());
67          } catch (Exception e) {
68              throw new WorkflowRuntimeException(e);
69          }
70      }
71  }