コード例 #1
0
 @Test
 public void testBean() {
   ExpressionContext context = new ExpressionContext();
   DocumentModel source = doCreateDocument();
   EventContext eventContext = new DocumentEventContext(session, session.getPrincipal(), source);
   Map<String, Serializable> properties = new HashMap<String, Serializable>();
   properties.put("test", "test");
   eventContext.setProperties(properties);
   evaluatorUnderTest.bindValue(context, "context", eventContext);
   DocumentModel value =
       evaluatorUnderTest.evaluateExpression(
           context, "${context.arguments[0]}", DocumentModel.class);
   assertNotNull(value);
   assertEquals(source, value);
   String test =
       evaluatorUnderTest.evaluateExpression(context, "${context.properties.test}", String.class);
   assertNotNull(value);
   assertEquals("test", test);
 }
コード例 #2
0
  public static void notifyEvent(
      CoreSession coreSession,
      DocumentModel document,
      NuxeoPrincipal principal,
      Task task,
      String eventId,
      Map<String, Serializable> properties,
      String comment,
      String category)
      throws ClientException {
    // Default category
    if (category == null) {
      category = DocumentEventCategories.EVENT_DOCUMENT_CATEGORY;
    }
    if (properties == null) {
      properties = new HashMap<String, Serializable>();
    }

    EventContext eventContext = null;
    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);
  }