Package org.apache.jackrabbit.spi

Examples of org.apache.jackrabbit.spi.Event


        List<Event> events = new ArrayList<Event>();
        int batchSize = 1024;
        boolean distinctDates = true;
        long lastDate = Long.MIN_VALUE;
        while (journal.hasNext() && (batchSize > 0 || !distinctDates)) {
            Event e = factory.fromJCREvent(journal.nextEvent());
            if (filter.accept(e, false)) {
                distinctDates = lastDate != e.getDate();
                lastDate = e.getDate();
                events.add(e);
                batchSize--;
            }
        }
        return new EventBundleImpl(events, false);
View Full Code Here


        if (log.isDebugEnabled()) {
            log.debug("received {} event bundles.", eventBundles.length);
            for (EventBundle eventBundle : eventBundles) {
                log.debug("IsLocal:  {}", eventBundle.isLocal());
                for (Iterator<Event> it = eventBundle.getEvents(); it.hasNext();) {
                    Event e = it.next();
                    String type;
                    switch (e.getType()) {
                        case Event.NODE_ADDED:
                            type = "NodeAdded";
                            break;
                        case Event.NODE_REMOVED:
                            type = "NodeRemoved";
                            break;
                        case Event.PROPERTY_ADDED:
                            type = "PropertyAdded";
                            break;
                        case Event.PROPERTY_CHANGED:
                            type = "PropertyChanged";
                            break;
                        case Event.PROPERTY_REMOVED:
                            type = "PropertyRemoved";
                            break;
                        case Event.NODE_MOVED:
                            type = "NodeMoved";
                            break;
                        case Event.PERSIST:
                            type = "Persist";
                            break;
                        default:
                            type = "Unknown";
                    }
                    log.debug("  {}; {}", e.getPath(), type);
                }
            }
        }

        // do not deliver events while an operation executes
View Full Code Here

        if (log.isDebugEnabled()) {
            log.debug("received {} event bundles.", new Integer(eventBundles.length));
            for (int i = 0; i < eventBundles.length; i++) {
                log.debug("IsLocal:  {}", Boolean.valueOf(eventBundles[i].isLocal()));
                for (Iterator<Event> it = eventBundles[i].getEvents(); it.hasNext(); ) {
                    Event e = it.next();
                    String type;
                    switch (e.getType()) {
                        case Event.NODE_ADDED:
                            type = "NodeAdded";
                            break;
                        case Event.NODE_REMOVED:
                            type = "NodeRemoved";
                            break;
                        case Event.PROPERTY_ADDED:
                            type = "PropertyAdded";
                            break;
                        case Event.PROPERTY_CHANGED:
                            type = "PropertyChanged";
                            break;
                        case Event.PROPERTY_REMOVED:
                            type = "PropertyRemoved";
                            break;
                        case Event.NODE_MOVED:
                            type = "NodeMoved";
                            break;
                        case Event.PERSIST:
                            type = "Persist";
                            break;
                        default:
                            type = "Unknown";
                    }
                    log.debug("  {}; {}", e.getPath(), type);
                }
            }
        }

        // do not deliver events while an operation executes
View Full Code Here

        Set<ItemId> removedEvents = new HashSet<ItemId>();
        // separately collect the add events
        Set<Event> addEvents = new HashSet<Event>();

        for (Iterator<Event> it = events.iterator(); it.hasNext();) {
            Event event = it.next();
            int type = event.getType();
            if (type == Event.NODE_REMOVED) {
                // remember removed nodes separately for proper handling later on.
                removedEvents.add(event.getItemId());
            } else if (type == Event.NODE_ADDED || type == Event.PROPERTY_ADDED) {
                addEvents.add(event);
                it.remove();
            }
        }

        /* Process ADD-events.
           In case of persisting transients modifications, the event-set may
           still contain events that are not covered by the changeLog such as
           new version-history or other autocreated properties and nodes.

           Add events need to be processed hierarchically, since its not possible
           to add a new child reference to a state that is not yet present in
           the state manager.
           The 'progress' flag is used to make sure, that during each loop at
           least one event has been processed and removed from the iterator.
           If this is not the case, there are not parent states present in the
           state manager that need to be updated and the remaining events may
           be ignored.
         */
        boolean progress = true;
        while (!addEvents.isEmpty() && progress) {
            progress = false;
            for (Iterator<Event> it = addEvents.iterator(); it.hasNext();) {
                Event ev = it.next();
                NodeId parentId = ev.getParentId();
                HierarchyEntry parent = null;
                if (parentId != null) {
                    parent = hierarchyMgr.lookup(parentId);
                    if (parent == null && ev.getPath() != null && parentId.getUniqueID() != null) {
                        // parentID contains a uniqueID part -> try to lookup
                        // the parent by path.
                        try {
                            Path parentPath = ev.getPath().getAncestor(1);
                            parent = hierarchyMgr.lookup(parentPath);
                        } catch (RepositoryException e) {
                            // should not occur
                            log.debug(e.getMessage());
                        }
View Full Code Here

        if (log.isDebugEnabled()) {
            log.debug("received {} event bundles.", new Integer(eventBundles.length));
            for (int i = 0; i < eventBundles.length; i++) {
                log.debug("IsLocal:  {}", Boolean.valueOf(eventBundles[i].isLocal()));
                for (Iterator it = eventBundles[i].getEvents(); it.hasNext(); ) {
                    Event e = (Event) it.next();
                    String type;
                    switch (e.getType()) {
                        case Event.NODE_ADDED:
                            type = "NodeAdded";
                            break;
                        case Event.NODE_REMOVED:
                            type = "NodeRemoved";
                            break;
                        case Event.PROPERTY_ADDED:
                            type = "PropertyAdded";
                            break;
                        case Event.PROPERTY_CHANGED:
                            type = "PropertyChanged";
                            break;
                        case Event.PROPERTY_REMOVED:
                            type = "PropertyRemoved";
                            break;
                        case Event.NODE_MOVED:
                            type = "NodeMoved";
                            break;
                        case Event.PERSIST:
                            type = "Persist";
                            break;
                        default:
                            type = "Unknown";
                    }
                    log.debug("  {}; {}", e.getPath(), type);
                }
            }
        }

        // do not deliver events while an operation executes
View Full Code Here

        List<Event> events = new ArrayList<Event>();
        int batchSize = 1024;
        boolean distinctDates = true;
        long lastDate = Long.MIN_VALUE;
        while (journal.hasNext() && (batchSize > 0 || !distinctDates)) {
            Event e = factory.fromJCREvent(journal.nextEvent());
            if (filter.accept(e, false)) {
                distinctDates = lastDate != e.getDate();
                lastDate = e.getDate();
                events.add(e);
                batchSize--;
            }
        }
        return new EventBundleImpl(events, false);
View Full Code Here

        List<Event> events = new ArrayList<Event>();
        int batchSize = 1024;
        boolean distinctDates = true;
        long lastDate = Long.MIN_VALUE;
        while (journal.hasNext() && (batchSize > 0 || !distinctDates)) {
            Event e = factory.fromJCREvent(journal.nextEvent());
            if (filter.accept(e, false)) {
                distinctDates = lastDate != e.getDate();
                lastDate = e.getDate();
                events.add(e);
                batchSize--;
            }
        }
        return new EventBundleImpl(events, false);
View Full Code Here

                new EventFilter[filters.size()]);
        // apply filters to bundles
        for (int i = 0; i < bundles.length; i++) {
            List filteredEvents = new ArrayList();
            for (Iterator it = bundles[i].getEvents(); it.hasNext(); ) {
                Event e = (Event) it.next();
                // TODO: this is actually not correct. if filters are empty no event should go out
                if (eventFilters == null || eventFilters.length == 0) {
                    filteredEvents.add(e);
                } else {
                    for (int j = 0; j < eventFilters.length; j++) {
View Full Code Here

                        info.put(name, v);
                    } else {
                        info.put(name, null);
                    }
                }
                Event spiEvent = new EventImpl(e.getType(), p, itemId, parentId,
                        nodeTypeName, mixinTypes, e.getUserID(), e.getUserData(), e.getDate(), info);
                spiEvents.add(spiEvent);
            } catch (Exception ex) {
                log.warn("Unable to create SPI Event: " + ex);
            }
View Full Code Here

        Set removedEvents = new HashSet();
        // separately collect the add events
        Set addEvents = new HashSet();

        for (Iterator it = events.iterator(); it.hasNext();) {
            Event event = (Event) it.next();
            int type = event.getType();
            if (type == Event.NODE_REMOVED) {
                // remember removed nodes separately for proper handling later on.
                removedEvents.add(event.getItemId());
            } else if (type == Event.NODE_ADDED || type == Event.PROPERTY_ADDED) {
                addEvents.add(event);
                it.remove();
            }
        }

        /* Process ADD-events.
           In case of persisting transients modifications, the event-set may
           still contain events that are not covered by the changeLog such as
           new version-history or other autocreated properties and nodes.

           Add events need to be processed hierarchically, since its not possible
           to add a new child reference to a state that is not yet present in
           the state manager.
           The 'progress' flag is used to make sure, that during each loop at
           least one event has been processed and removed from the iterator.
           If this is not the case, there are not parent states present in the
           state manager that need to be updated and the remaining events may
           be ignored.
         */
        boolean progress = true;
        while (!addEvents.isEmpty() && progress) {
            progress = false;
            for (Iterator it = addEvents.iterator(); it.hasNext();) {
                Event ev = (Event) it.next();
                NodeId parentId = ev.getParentId();
                HierarchyEntry parent = null;
                if (parentId != null) {
                    parent = hierarchyMgr.lookup(parentId);
                    if (parent == null && ev.getPath() != null && parentId.getUniqueID() != null) {
                        // parentID contains a uniqueID part -> try to lookup
                        // the parent by path.
                        try {
                            Path parentPath = ev.getPath().getAncestor(1);
                            parent = hierarchyMgr.lookup(parentPath);
                        } catch (RepositoryException e) {
                            // should not occur
                            log.debug(e.getMessage());
                        }
                    }
                }
                if (parent != null && parent.denotesNode()) {
                    ((NodeEntry) parent).refresh(ev);
                    it.remove();
                    progress = true;
                }
            }
        }

        /* process all other events (removal, property changed) */
        for (Iterator it = events.iterator(); it.hasNext(); ) {
            Event event = (Event) it.next();
            int type = event.getType();

            NodeId parentId = event.getParentId();
            NodeEntry parent = (parentId != null) ? (NodeEntry) hierarchyMgr.lookup(parentId) : null;
            switch (type) {
                case Event.NODE_REMOVED:
                case Event.PROPERTY_REMOVED:
                    // notify parent about removal if its child-entry.
                    // - if parent is 'null' (i.e. not yet loaded) the child-entry does
                    //   not exist either -> no need to inform child-entry
                    // - if parent got removed with the same event-bundle
                    //   only remove the parent an skip this event.
                    if (parent != null && !removedEvents.contains(parentId)) {
                        parent.refresh(event);
                    }
                    break;
                case Event.PROPERTY_CHANGED:
                    // notify parent in case jcr:mixintypes or jcr:uuid was changed.
                    // if parent is 'null' (i.e. not yet loaded) the prop-entry does
                    // not exist either -> no need to inform propEntry
                    if (parent != null) {
                        parent.refresh(event);
                    }
                    break;
                case Event.NODE_MOVED:
                    // TODO: implementation missing
                    throw new UnsupportedOperationException("Implementation missing");
                    //break;
                case Event.PERSIST:
                    // TODO: implementation missing
                    throw new UnsupportedOperationException("Implementation missing");
                    //break;
                default:
                    // should never occur
                    throw new IllegalArgumentException("Invalid event type: " + event.getType());
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.spi.Event

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.