class SubscriptionDelegate {

    synchronized Publisher getPublisher(NotificationSubscriptionContext subscriptionContext) {
        Publisher publisher = publisherDao.findPublisher(subscriptionContext.getContextId(), subscriptionContext.getContextType(), subscriptionContext.getSourceId(),
                subscriptionContext.getSourceType());
        if (publisher == null) {
            publisher = publisherDao.createAndSavePublisher(subscriptionContext.getContextId(), subscriptionContext.getContextType(), subscriptionContext.getSourceId(),
                    subscriptionContext.getSourceType(), subscriptionContext.getSubcontextId());
        }
        return publisher;
    }

}