import org.kuali.rice.kcb.bo.Message; //导入方法依赖的package包/类
/**
* @see org.kuali.rice.kcb.service.MessagingService#deliver(org.kuali.rice.kcb.dto.MessageDTO)
*/
@Override
public Long deliver(MessageDTO message) throws MessageDeliveryException {
if (message == null) {
throw new RiceIllegalArgumentException("message is null");
}
Collection delivererTypes = getDelivererTypesForUserAndChannel(message.getRecipient(), message.getChannel());
LOG.debug("Deliverer types for " + message.getRecipient() + "/" + message.getChannel() + ": " + delivererTypes.size());
if (delivererTypes.isEmpty()) {
// no deliverers configured? just skipp it
LOG.debug("No deliverers are configured for " + message.getRecipient() + "/" + message.getChannel());
return null;
}
final Message m = new Message();
m.setTitle(message.getTitle());
m.setDeliveryType(message.getDeliveryType());
m.setChannel(message.getChannel());
m.setRecipient(message.getRecipient());
m.setContentType(message.getContentType());
m.setUrl(message.getUrl());
m.setContent(message.getContent());
m.setOriginId(message.getOriginId());
LOG.debug("saving message: " +m);
messageService.saveMessage(m);
for (String type: delivererTypes) {
MessageDelivery delivery = new MessageDelivery();
delivery.setDelivererTypeName(type);
delivery.setMessage(m);
// MessageDeliverer deliverer = delivererRegistry.getDeliverer(delivery);
// if (deliverer != null) {
// deliverer.deliverMessage(delivery);
// }
LOG.debug("saving messagedelivery: " +delivery);
messageDeliveryService.saveMessageDelivery(delivery);
}
LOG.debug("queuing job");
queueJob(MessageProcessingJob.Mode.DELIVER, m.getId(), null, null);
LOG.debug("returning");
return m.getId();
}