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