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