class PublishDelegate {

    public int publishEvent(PublishEventTO publishEventTO) {
        Publisher publisher = getPublisher(publishEventTO);
        if (publisher == null) {
            // if there are no subscriptions, no publisher was created, that is OK
            log.info("found no publisher for context-type=" + publishEventTO.getContextType() + " context-id=" + publishEventTO.getContextId() + " source-type="
                    + publishEventTO.getSourceType() + " source-id=" + publishEventTO.getSourceId());
        } else {
            log.debug("publishEvent: create NotificationEvents for ContextTitle=" + publishEventTO.getContextTitle() + " SourceTitle=" + publishEventTO.getSourceTitle());
            List<NotificationEvent> notificationEvents = notificationEventDao.createAndSaveNotificationEvents(publisher, createAttributesFrom(publishEventTO));
            return notificationEvents.size();
        }
        return 0;
    }

}