public void onEvent()

in src/main/java/org/apache/sling/installer/provider/jcr/impl/RootFolderListener.java [77:114]


    public void onEvent(final EventIterator it) {
        // we only do the global scan for node changes
        boolean globalScan = false;
        // copy watched folders and remove all for other roots
        final List<WatchedFolder> checkFolders = cfg.cloneWatchedFolders();
        final Iterator<WatchedFolder> i = checkFolders.iterator();
        while ( i.hasNext() ) {
            final WatchedFolder wf = i.next();
            if ( !wf.getPathWithSlash().startsWith(this.pathWithSlash)) {
                i.remove();
            }
        }
        while(it.hasNext()) {
            final Event e = it.nextEvent();
            logger.debug("Got event {}", e);
            if ( e.getType() == Event.NODE_ADDED || e.getType() == Event.NODE_REMOVED ) {
                globalScan = true;
            }
            try {
                final String path = e.getPath();

                final Iterator<WatchedFolder> ii = checkFolders.iterator();
                while ( ii.hasNext() ) {
                    final WatchedFolder folder = ii.next();
                    if ( path.startsWith(folder.getPathWithSlash()) ) {
                        folder.markForScan();
                        ii.remove();
                        break;
                    }
                }
            } catch ( final RepositoryException re ) {
                logger.warn("Error while getting path from event", re);
            }
        }
        if ( globalScan ) {
            timer.scheduleScan();
        }
    }