/** {@inheritDoc} */
  public void onEvent(EventIterator eventIterator) {
    // waiting for Event.PROPERTY_ADDED, Event.PROPERTY_REMOVED,
    // Event.PROPERTY_CHANGED
    Session session = null;
    try {
      while (eventIterator.hasNext()) {
        Event event = eventIterator.nextEvent();
        String path = event.getPath();

        if (path.endsWith("/jcr:data")) {
          // jcr:data removed 'exo:groovyResourceContainer' then unbind resource
          if (event.getType() == Event.PROPERTY_REMOVED) {
            unloadScript(path.substring(0, path.lastIndexOf('/')));
          } else if (event.getType() == Event.PROPERTY_ADDED
              || event.getType() == Event.PROPERTY_CHANGED) {
            if (session == null) {
              session = repository.getSystemSession(workspaceName);
            }

            Node node = session.getItem(path).getParent();
            if (node.getProperty("exo:autoload").getBoolean()) loadScript(node);
          }
        }
      }
    } catch (Exception e) {
      LOG.error("Process event failed. ", e);
    } finally {
      if (session != null) {
        session.logout();
      }
    }
  }
Exemplo n.º 2
0
    @SuppressWarnings("synthetic-access")
    @Override
    public void onEvent(EventIterator events) {
      while (events.hasNext()) {
        try {
          Event event = (Event) events.nextEvent();
          smokeCheckSequencingEvent(
              event,
              NODE_SEQUENCING_FAILURE,
              SEQUENCED_NODE_ID,
              SEQUENCED_NODE_PATH,
              Event.Sequencing.SEQUENCING_FAILURE_CAUSE,
              OUTPUT_PATH,
              SELECTED_PATH,
              SEQUENCER_NAME,
              USER_ID);
          String nodePath = event.getPath();

          sequencingEvents.putIfAbsent(nodePath, event);
          createWaitingLatchIfNecessary(nodePath, sequencingFailureLatches);
          sequencingFailureLatches.get(nodePath).countDown();
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }
    }
  @Override
  public void onEvent(EventIterator eventIterator) {
    while (eventIterator.hasNext()) {
      try {
        Event currentEvent = eventIterator.nextEvent();

        if (currentEvent.getType() == Event.PROPERTY_ADDED
            || currentEvent.getType() == Event.PROPERTY_CHANGED
            || currentEvent.getType() == Event.PROPERTY_REMOVED) {
          clientLibraryCacheManager.invalidateCache(
              currentEvent.getPath().substring(0, currentEvent.getPath().lastIndexOf("/")));
        } else if (currentEvent.getType() == Event.NODE_REMOVED) {
          clientLibraryCacheManager.invalidateCache(currentEvent.getPath());
        } else if (currentEvent.getType() == Event.NODE_MOVED) {
          if (currentEvent.getInfo().containsKey("srcAbsPath")) {
            clientLibraryCacheManager.invalidateCache(
                (String) currentEvent.getInfo().get("srcAbsPath"));
          }
          clientLibraryCacheManager.invalidateCache(currentEvent.getPath());
        }
      } catch (RepositoryException e) {
        LOG.error("Repository Exception", e);
      } catch (ClientLibraryCachingException e) {
        LOG.error(
            "Client Library Caching Exception encountered while processing page content events", e);
      }
    }
  }
Exemplo n.º 4
0
    @SuppressWarnings("synthetic-access")
    @Override
    public void onEvent(EventIterator events) {
      while (events.hasNext()) {
        try {
          Event event = (Event) events.nextEvent();
          smokeCheckSequencingEvent(
              event,
              NODE_SEQUENCED,
              SEQUENCED_NODE_ID,
              SEQUENCED_NODE_PATH,
              OUTPUT_PATH,
              SELECTED_PATH,
              SEQUENCER_NAME,
              USER_ID);
          sequencingEvents.putIfAbsent((String) event.getInfo().get(SEQUENCED_NODE_PATH), event);

          String nodePath = event.getPath();
          logger.debug("New sequenced node at: " + nodePath);
          sequencedNodes.put(nodePath, session.getNode(nodePath));

          // signal the node is available
          createWaitingLatchIfNecessary(nodePath, nodeSequencedLatches);
          nodeSequencedLatches.get(nodePath).countDown();
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }
    }
 /** @see javax.jcr.observation.EventListener#onEvent(javax.jcr.observation.EventIterator) */
 public void onEvent(EventIterator iterator) {
   System.out.println("received events: ");
   for (; iterator.hasNext(); ) {
     try {
       System.out.println(toStringEvent(iterator.nextEvent()));
     } catch (RepositoryException e) {
       System.err.println(
           "exception while listnening " + SessionFactoryUtils.translateException(e));
     }
   }
 }