| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
package org.kuali.rice.kew.notification.service.impl; |
| 18 |
|
|
| 19 |
|
import org.apache.commons.lang.StringUtils; |
| 20 |
|
import org.kuali.rice.core.api.config.property.ConfigContext; |
| 21 |
|
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
| 22 |
|
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
| 23 |
|
import org.kuali.rice.kcb.dto.MessageDTO; |
| 24 |
|
import org.kuali.rice.kcb.service.KCBServiceNames; |
| 25 |
|
import org.kuali.rice.kcb.service.MessagingService; |
| 26 |
|
import org.kuali.rice.kcb.util.KCBConstants; |
| 27 |
|
import org.kuali.rice.kew.actionitem.ActionItem; |
| 28 |
|
import org.kuali.rice.kew.exception.WorkflowRuntimeException; |
| 29 |
|
import org.kuali.rice.kew.util.KEWConstants; |
| 30 |
|
|
| 31 |
|
import javax.xml.namespace.QName; |
| 32 |
|
import java.util.List; |
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
@author |
| 39 |
|
|
|
|
|
| 0% |
Uncovered Elements: 44 (44) |
Complexity: 9 |
Complexity Density: 0.26 |
|
| 40 |
|
public class KCBNotificationService extends DefaultNotificationService { |
|
|
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 6 |
Complexity Density: 0.25 |
|
| 41 |
0
|
@Override... |
| 42 |
|
protected void sendNotification(ActionItem actionItem) { |
| 43 |
0
|
super.sendNotification(actionItem); |
| 44 |
|
|
| 45 |
0
|
String enableKENNotificationValue = ConfigContext.getCurrentContextConfig().getProperty(KEWConstants.ENABLE_KEN_NOTIFICATION); |
| 46 |
0
|
boolean enableKENNotification = Boolean.parseBoolean(enableKENNotificationValue); |
| 47 |
|
|
| 48 |
0
|
if (!enableKENNotification || !KEWConstants.ACTION_REQUEST_USER_RECIPIENT_CD.equals(actionItem.getRecipientTypeCode())) |
| 49 |
0
|
return; |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
0
|
MessagingService ms = (MessagingService) GlobalResourceLoader.getService(new QName(KCBConstants.SERVICE_NAMESPACE, KCBServiceNames.KCB_MESSAGING)); |
| 54 |
0
|
if (ms == null) { |
| 55 |
0
|
LOG.info("Could not locate KCB MessagingService. Message will not be forwarded to the KCB."); |
| 56 |
0
|
return; |
| 57 |
|
} |
| 58 |
0
|
MessageDTO mvo = new MessageDTO(); |
| 59 |
0
|
mvo.setChannel("KEW"); |
| 60 |
0
|
mvo.setContent("i'm a kew notification"); |
| 61 |
0
|
mvo.setContentType("KEW notification"); |
| 62 |
0
|
mvo.setDeliveryType(actionItem.getActionRequestCd()); |
| 63 |
0
|
mvo.setProducer("kew@localhost"); |
| 64 |
0
|
mvo.setTitle(actionItem.getDocLabel() + " - " + actionItem.getDocName() + " - " + actionItem.getDocTitle()); |
| 65 |
0
|
if (StringUtils.isNotBlank(actionItem.getDocHandlerURL())) { |
| 66 |
0
|
mvo.setUrl(actionItem.getDocHandlerURL() + "?docId=" + actionItem.getRouteHeaderId()); |
| 67 |
|
} |
| 68 |
0
|
mvo.setOriginId(String.valueOf(actionItem.getActionItemId())); |
| 69 |
0
|
try { |
| 70 |
|
|
| 71 |
0
|
mvo.setRecipient(actionItem.getPrincipalId()); |
| 72 |
0
|
LOG.debug("Sending message to KCB: " + mvo); |
| 73 |
0
|
ms.deliver(mvo); |
| 74 |
|
} catch (Exception e) { |
| 75 |
0
|
throw new WorkflowRuntimeException("could not deliver message to KCB", e); |
| 76 |
|
} |
| 77 |
|
} |
| 78 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.3 |
|
| 79 |
0
|
@Override... |
| 80 |
|
public void removeNotification(List<ActionItem> actionItems) { |
| 81 |
0
|
String enableKENNotificationValue = ConfigContext.getCurrentContextConfig().getProperty(KEWConstants.ENABLE_KEN_NOTIFICATION); |
| 82 |
0
|
boolean enableKENNotification = Boolean.parseBoolean(enableKENNotificationValue); |
| 83 |
0
|
if (!enableKENNotification) { |
| 84 |
0
|
return; |
| 85 |
|
} |
| 86 |
0
|
MessagingService ms = (MessagingService) GlobalResourceLoader.getService(new QName(KCBConstants.SERVICE_NAMESPACE, KCBServiceNames.KCB_MESSAGING)); |
| 87 |
|
|
| 88 |
0
|
for (ActionItem actionItem: actionItems) { |
| 89 |
0
|
LOG.debug("Removing KCB messages for action item: " + actionItem.getActionItemId() + " " + actionItem.getActionRequestCd() + " " + actionItem.getPerson()); |
| 90 |
0
|
try { |
| 91 |
|
|
| 92 |
0
|
ms.removeByOriginId(String.valueOf(actionItem.getActionItemId()), null, null); |
| 93 |
|
} catch (Exception e) { |
| 94 |
0
|
throw new RuntimeException("could not remove message from KCB", e); |
| 95 |
|
} |
| 96 |
|
} |
| 97 |
|
} |
| 98 |
|
} |