private void raiseConfirmationEvent(NuxeoPrincipal principal, DocumentModel doc, String username, String notification) { Map<String, Serializable> options = new HashMap<>(); // Name of the current repository options.put(CoreEventConstants.REPOSITORY_NAME, doc.getRepositoryName()); // Add the session ID options.put(CoreEventConstants.SESSION_ID, doc.getSessionId()); // options for confirmation email options.put("recipients", username); options.put("notifName", notification); CoreSession session = doc.getCoreSession(); DocumentEventContext ctx = new DocumentEventContext(session, principal, doc); ctx.setCategory(DocumentEventCategories.EVENT_CLIENT_NOTIF_CATEGORY); ctx.setProperties(options); Event event = ctx.newEvent(DocumentEventTypes.SUBSCRIPTION_ASSIGNED); doFireEvent(event); }
/** * @since 10.3 */ protected void notifyPublishedEvent(DocumentModel doc) { Map<String, Serializable> properties = new HashMap<>(); properties.put(CoreEventConstants.REPOSITORY_NAME, doc.getRepositoryName()); properties.put(CoreEventConstants.SESSION_ID, session.getSessionId()); properties.put(CoreEventConstants.DOC_LIFE_CYCLE, doc.getCurrentLifeCycleState()); DocumentEventContext ctx = new DocumentEventContext(session, session.getPrincipal(), doc); ctx.setProperties(properties); ctx.setCategory(DocumentEventCategories.EVENT_DOCUMENT_CATEGORY); Event event = ctx.newEvent(DocumentEventTypes.DOCUMENT_PUBLISHED); Framework.getService(EventProducer.class).fireEvent(event); }
protected void notifyEvent(String eventId, Map<String, Serializable> properties, String comment, String category, DocumentModel dm, CoreSession coreSession) { // Default category if (category == null) { category = DocumentEventCategories.EVENT_DOCUMENT_CATEGORY; } if (properties == null) { properties = new HashMap<String, Serializable>(); } properties.put(CoreEventConstants.REPOSITORY_NAME, dm.getRepositoryName()); properties.put(CoreEventConstants.SESSION_ID, coreSession.getSessionId()); properties.put(CoreEventConstants.DOC_LIFE_CYCLE, dm.getCurrentLifeCycleState()); DocumentEventContext ctx = new DocumentEventContext(coreSession, coreSession.getPrincipal(), dm); ctx.setProperties(properties); ctx.setComment(comment); ctx.setCategory(category); Event event = ctx.newEvent(eventId); getEventProducer().fireEvent(event); }
public static 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<>(); } 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); }
@Override public void setProperties(Map<String, Serializable> properties) { // preserve Category/Comment from transparent override String comment = getComment(); String category = getCategory(); super.setProperties(properties); if (getComment() == null) { setComment(comment); } if (getCategory() == null) { setCategory(category); } }
protected void notifyEvent(CoreSession session, String eventId, DocumentModel doc, boolean immediate) { DocumentEventContext ctx = new DocumentEventContext(session, session.getPrincipal(), doc); ctx.setProperties(new HashMap<>(doc.getContextData())); ctx.setCategory(DocumentEventCategories.EVENT_DOCUMENT_CATEGORY); ctx.setProperty(CoreEventConstants.REPOSITORY_NAME, session.getRepositoryName()); ctx.setProperty(CoreEventConstants.SESSION_ID, session.getSessionId()); Event event = ctx.newEvent(eventId); event.setInline(false); event.setImmediate(immediate); EventService eventService = Framework.getService(EventService.class); eventService.fireEvent(event); }
protected void fireEvent(CoreSession session, String eventId, Collection<DocumentRef> refs) { EventService eventService = Framework.getService(EventService.class); DocumentModelList docs = session.getDocuments(refs.toArray(new DocumentRef[0])); docs.forEach(d -> { DocumentEventContext ctx = new DocumentEventContext(session, session.getPrincipal(), d); ctx.setProperty(REPOSITORY_NAME, session.getRepositoryName()); ctx.setProperty(SESSION_ID, session.getSessionId()); ctx.setCategory(EVENT_DOCUMENT_CATEGORY); Event event = ctx.newEvent(eventId); event.setImmediate(false); event.setInline(false); eventService.fireEvent(event); }); } }