protected void notifyEvent( String eventId, DocumentModel source, Map<String, Serializable> options, String comment, CoreSession session) { EventProducer evtProducer = null; try { evtProducer = Framework.getService(EventProducer.class); } catch (Exception e) { log.error("Unable to get EventProducer to send event notification", e); } DocumentEventContext docCtx = new DocumentEventContext(session, session.getPrincipal(), source); options.put("category", RelationEvents.CATEGORY); options.put("comment", comment); try { evtProducer.fireEvent(docCtx.newEvent(eventId)); } catch (ClientException e) { log.error("Error while trying to send notification message", e); } }
protected void notifyEvent( CoreSession session, String eventId, Map<String, Serializable> properties, String comment, String category, DocumentModel dm) { // Default category if (category == null) { category = DocumentEventCategories.EVENT_DOCUMENT_CATEGORY; } if (properties == null) { properties = new HashMap<String, Serializable>(); } properties.put(CoreEventConstants.REPOSITORY_NAME, session.getRepositoryName()); properties.put(CoreEventConstants.SESSION_ID, session.getSessionId()); properties.put(CoreEventConstants.DOC_LIFE_CYCLE, dm.getCurrentLifeCycleState()); DocumentEventContext ctx = new DocumentEventContext(session, session.getPrincipal(), dm); ctx.setProperties(properties); ctx.setComment(comment); ctx.setCategory(category); EventProducer evtProducer = Framework.getService(EventProducer.class); Event event = ctx.newEvent(eventId); evtProducer.fireEvent(event); }