public static void notifyEvent(CoreSession coreSession, DocumentModel document, NuxeoPrincipal principal, Task task, String eventId, Map<String, Serializable> properties, String comment, String category) { // Default category if (category == null) { category = DocumentEventCategories.EVENT_DOCUMENT_CATEGORY; } if (properties == null) { properties = new HashMap<>(); } EventContext eventContext; if (document != null) { properties.put(CoreEventConstants.REPOSITORY_NAME, document.getRepositoryName()); properties.put(CoreEventConstants.SESSION_ID, coreSession.getSessionId()); properties.put(CoreEventConstants.DOC_LIFE_CYCLE, document.getCurrentLifeCycleState()); eventContext = new DocumentEventContext(coreSession, principal, document); } else { eventContext = new EventContextImpl(coreSession, principal); } properties.put(DocumentEventContext.COMMENT_PROPERTY_KEY, comment); properties.put(DocumentEventContext.CATEGORY_PROPERTY_KEY, category); properties.put(TaskService.TASK_INSTANCE_EVENT_PROPERTIES_KEY, task); String disableNotif = task.getVariable(TaskEventNames.DISABLE_NOTIFICATION_SERVICE); if (disableNotif != null && Boolean.TRUE.equals(Boolean.valueOf(disableNotif))) { properties.put(TaskEventNames.DISABLE_NOTIFICATION_SERVICE, Boolean.TRUE); } eventContext.setProperties(properties); Event event = eventContext.newEvent(eventId); getEventProducer().fireEvent(event); }
/** * @since 7.1 */ private void doCleanAndReschedule(int batchSize, DocumentRoutingService routing, String repositoryName) { int cleanedUpWf = routing.doCleanupDoneAndCanceledRouteInstances(repositoryName, batchSize); if (cleanedUpWf == batchSize) { EventContextImpl eCtx = new EventContextImpl(); eCtx.setProperty(CLEANUP_WORKFLOW_REPO_NAME_PROPERTY, repositoryName); Event event = eCtx.newEvent(CLEANUP_WORKFLOW_EVENT_NAME); EventProducer eventProducer = Framework.getService(EventProducer.class); eventProducer.fireEvent(event); } }
protected void sendUnknownEvent(Object input) { CoreSession session = ctx.getCoreSession(); EventContextImpl evctx = new EventContextImpl(session, session.getPrincipal(), input); Event event = evctx.newEvent(name); service.fireEvent(event); }
(DocumentRef) newArgs.get(1)); } else { newCtx = new EventContextImpl(null, ctx.getPrincipal()); ((EventContextImpl) newCtx).setArgs(newArgs.toArray());
protected void sendDocumentEvent(DocumentModel input) { CoreSession session = ctx.getCoreSession(); EventContextImpl evctx = new DocumentEventContext(session, session.getPrincipal(), input); Event event = evctx.newEvent(name); service.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); } }
(DocumentRef) newArgs.get(1)); } else { newCtx = new EventContextImpl(session, ctx.getPrincipal()); ((EventContextImpl) newCtx).setArgs(newArgs.toArray());
protected void notifyEvent(CoreSession coreSession, DocumentModel document, NuxeoPrincipal principal, String eventId, Map<String, Serializable> properties) { if (properties == null) { properties = new HashMap<>(); } EventContext eventContext; if (document != null) { properties.put(CoreEventConstants.REPOSITORY_NAME, document.getRepositoryName()); properties.put(CoreEventConstants.SESSION_ID, coreSession.getSessionId()); properties.put(CoreEventConstants.DOC_LIFE_CYCLE, document.getCurrentLifeCycleState()); eventContext = new DocumentEventContext(coreSession, principal, document); } else { eventContext = new EventContextImpl(coreSession, principal); } eventContext.setProperties(properties); Event event = eventContext.newEvent(eventId); Framework.getService(EventProducer.class).fireEvent(event); }
protected void fireACEStatusUpdatedEvent(Map<DocumentRef, List<ACE>> refToACEs) { EventContext eventContext = new EventContextImpl(session, session.getPrincipal()); eventContext.setProperty(DOCUMENT_REFS, (Serializable) refToACEs); eventContext.setProperty(REPOSITORY_NAME, session.getRepositoryName()); Framework.getService(EventService.class).fireEvent(ACE_STATUS_UPDATED, eventContext); }
ctx.setProperty(CoreEventConstants.SESSION_ID, doc.getSessionId()); } else { ctx = new EventContextImpl(null, getPrincipal());
EventContext evtctx = new EventContextImpl(coreSession, coreSession.getPrincipal(), new ShallowDocumentModel(docModel), versionsIds); Event evt = evtctx.newEvent(ORPHAN_VERSION_REMOVE);
/** * Called when the worker failed to run successfully even after retrying. * @since 10.1 * @param exception the exception that occurred */ public void workFailed(RuntimeException exception) { EventService service = Framework.getService(EventService.class); EventContext eventContext = new EventContextImpl(null, session != null ? session.getPrincipal() : null); eventContext.setProperties(buildWorkFailureEventProps(exception)); Event event = new EventImpl(WORK_FAILED_EVENT, eventContext); event.setIsCommitEvent(true); service.fireEvent(event); if (exception != null) { String msg = "Work failed after " + getRetryCount() + " " + (getRetryCount() == 1 ? "retry" : "retries") + ", class=" + getClass() + " id=" + getId() + " category=" + getCategory() + " title=" + getTitle(); SequenceTracer.destroy("Work failure " + (completionTime - startTime) + " ms"); // all retries have been done, throw the exception throw new NuxeoException(msg, exception); } }
EventContext ctx = new EventContextImpl(documentManager, documentManager.getPrincipal(), listToModify); ctx.setProperties(propertiesToModify); ctx.setProperty(MassValidationListener.WITH_VALIDATION, withValidation);
EventContext eventContext = new EventContextImpl(null, principal); eventContext.setProperty("category", eventCategory); eventContext.setProperties(getWrappedMap(dataMap));