public static void notifyAuditEvent(CoreSession session, String eventName, DocumentModel document, String comment) throws ClientException { NuxeoPrincipal principal = (NuxeoPrincipal) session.getPrincipal(); DocumentEventContext ctx = new DocumentEventContext(session, principal, document); ctx.setComment(comment); Logs auditProducer = getAuditEventProducer(); Event entry = new EventImpl(eventName, ctx); auditProducer.logEvent(entry); }
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); } }