Package javax.jcr.observation

Examples of javax.jcr.observation.Event


        }

        public Element toXml(Document document) {
            Element bundle = DomUtil.createElement(document, XML_EVENTBUNDLE, NAMESPACE);
            while (events.hasNext()) {
                Event event = events.nextEvent();
                Element eventElem = DomUtil.addChildElement(bundle, XML_EVENT, NAMESPACE);
                // href
                String eHref = "";
                try {
                    boolean isCollection = (event.getType() == Event.NODE_ADDED || event.getType() == Event.NODE_REMOVED);
                    eHref = locator.getFactory().createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), event.getPath(), false).getHref(isCollection);
                } catch (RepositoryException e) {
                    // should not occur....
                    log.error(e.getMessage());
                }
                eventElem.appendChild(DomUtil.hrefToXml(eHref, document));
                // eventtype
                Element eType = DomUtil.addChildElement(eventElem, XML_EVENTTYPE, NAMESPACE);
                eType.appendChild(getEventType(event.getType()).toXml(document));
                // user id
                DomUtil.addChildElement(eventElem, XML_EVENTUSERID, NAMESPACE, event.getUserID());
            }
            return bundle;
        }
View Full Code Here


         * @see EventListener#onEvent(javax.jcr.observation.EventIterator)
         */
        public void onEvent(EventIterator events) {
            while (events.hasNext()) {
                try {
                    Event e = events.nextEvent();
                    DavResourceLocator loc = getLocatorFromItemPath(e.getPath());
                    DavResource res = createResourceFromLocator(loc);
                    ms.addResponse(new MultiStatusResponse(res, propNameSet));

                } catch (DavException e) {
                    // should not occur
                    log.error("Error while building MultiStatusResponse from Event: " + e.getMessage());
                } catch (RepositoryException e) {
                    // should not occur
                    log.error("Error while building MultiStatusResponse from Event: " + e.getMessage());
                }
            }
        }
View Full Code Here

                } catch (InterruptedException e) {
                    // ignore
                }
            }
            while (events.hasNext()) {
                Event event = events.nextEvent();
                try {
                    String path = event.getPath();
                    try {
                        Item item = session.getItem(path);
                        if (item.isNode()) {
                            Node n = (Node) item;
                            recurse(n, testDelay);
View Full Code Here

     */
    public Object next() {
        if (next == null) {
            throw new NoSuchElementException();
        }
        Event e = next;
        fetchNext();
        pos++;
        return e;
    }
View Full Code Here

            return;
        }

        synchronized (repProps) {
            while (events.hasNext()) {
                Event event = events.nextEvent();
                long type = event.getType();
                if ((type & Event.NODE_ADDED) == Event.NODE_ADDED) {
                    nodesCount++;
                    repProps.setProperty(STATS_NODE_COUNT_PROPERTY, Long.toString(nodesCount));
                }
                if ((type & Event.NODE_REMOVED) == Event.NODE_REMOVED) {
View Full Code Here

     */
    public Object next() {
        if (next == null) {
            throw new NoSuchElementException();
        }
        Event e = next;
        fetchNext();
        pos++;
        return e;
    }
View Full Code Here

        }
        EventBundle bundle = getCurrentBundle();
        // above hasNext() call ensures that there is bundle with an event state
        assert bundle != null && bundle.events.hasNext();

        Event next = (Event) bundle.events.next();
        if (!bundle.events.hasNext()) {
            // done with this bundle -> remove from buffer
            eventBundleBuffer.remove(0);
        }
        position++;
View Full Code Here

            }

            boolean localFlagSet = false;

            while (events.hasNext()) {
                Event event = events.nextEvent();

                if (!localFlagSet) {
                    // obtain remote session identifier
                    localFlagSet = true;
                    String forSessionId = (String) session
                            .getAttribute(SessionProviderImpl.ATTRIBUTE_SESSION_ID);
                    // calculate "local" flags
                    if (forSessionId != null
                            && event instanceof AdditionalEventInfo) {
                        try {
                            String eventforSessionId = (String) ((AdditionalEventInfo) event)
                                    .getSessionAttribute(SessionProviderImpl.ATTRIBUTE_SESSION_ID);
                            boolean isLocal = forSessionId
                                    .equals(eventforSessionId);
                            DomUtil.setAttribute(bundle, XML_EVENT_LOCAL, null, Boolean.toString(isLocal));
                        } catch (UnsupportedRepositoryOperationException ex) {
                            // optional feature
                        }
                    }
                }

                Element eventElem = DomUtil.addChildElement(bundle, XML_EVENT, NAMESPACE);
                // href
                String eHref = "";
                try {
                    boolean isCollection = (event.getType() == Event.NODE_ADDED || event.getType() == Event.NODE_REMOVED);
                    eHref = locator.getFactory().createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), event.getPath(), false).getHref(isCollection);
                } catch (RepositoryException e) {
                    // should not occur....
                    log.error(e.getMessage());
                }
                eventElem.appendChild(DomUtil.hrefToXml(eHref, document));
                // event type
                Element eType = DomUtil.addChildElement(eventElem, XML_EVENTTYPE, NAMESPACE);
                eType.appendChild(getEventType(event.getType()).toXml(document));
                // user id
                DomUtil.addChildElement(eventElem, XML_EVENTUSERID, NAMESPACE, event.getUserID());

                // try to compute nodetype information
                if (event instanceof AdditionalEventInfo) {
                    try {
                        DomUtil.addChildElement(eventElem,
                                XML_EVENTPRIMARNODETYPE, NAMESPACE,
                                ((AdditionalEventInfo) event)
                                        .getPrimaryNodeTypeName().toString());
                        for (Name mixin : ((AdditionalEventInfo) event)
                                .getMixinTypeNames()) {
                            DomUtil.addChildElement(eventElem,
                                    XML_EVENTMIXINNODETYPE, NAMESPACE,
                                    mixin.toString());
                        }
                    } catch (UnsupportedRepositoryOperationException ex) {
                        // optional
                    }
                }

                // Additional JCR 2.0 event information
                // user data
                try {
                    DomUtil.addChildElement(eventElem, XML_EVENTUSERDATA, NAMESPACE, event.getUserData());
                } catch (RepositoryException e) {
                    log.error("Internal error while retrieving event user data.", e.getMessage());
                }
                // time stamp
                try {
                    DomUtil.addChildElement(eventElem, XML_EVENTDATE, NAMESPACE, String.valueOf(event.getDate()));
                } catch (RepositoryException e) {
                    log.error("Internal error while retrieving event date.", e.getMessage());
                }
                // identifier
                try {
                    DomUtil.addChildElement(eventElem, XML_EVENTIDENTIFIER, NAMESPACE, event.getIdentifier());
                } catch (RepositoryException e) {
                    log.error("Internal error while retrieving event identifier.", e.getMessage());
                }
                // info
                Element info = DomUtil.addChildElement(eventElem, XML_EVENTINFO, NAMESPACE);
                try {
                    Map<?, ?> m = event.getInfo();
                    for (Map.Entry<?, ?> entry : m.entrySet()) {
                        String key = entry.getKey().toString();
                        Object value = entry.getValue();
                        if (value != null) {
                            DomUtil.addChildElement(info, key, Namespace.EMPTY_NAMESPACE, value.toString());
View Full Code Here

        RemoteEventCollection.RemoteEvent[] remoteEvents;
        if (events != null) {
            List eventList = new ArrayList();
            while (events.hasNext()) {
                try {
                    Event event = events.nextEvent();
                    eventList.add(new ServerEventCollection.ServerEvent(
                            event.getType(), event.getPath(), event.getUserID()));
                } catch (RepositoryException re) {
                    throw new RemoteException(re.getMessage(), re);
                }
            }
            remoteEvents = (RemoteEventCollection.RemoteEvent[])
View Full Code Here

        // superclass: flush all cached
        clearCache();

        // membership cache:
        while (eventIterator.hasNext()) {
            Event ev = eventIterator.nextEvent();
            int type = ev.getType();
            if (type == Event.PROPERTY_ADDED || type == Event.PROPERTY_CHANGED
                    || type == Event.PROPERTY_REMOVED) {
                try {
                    if (pMembers.equals(Text.getName(ev.getPath()))) {
                        synchronized (membershipCache) {
                            membershipCache.clear();
                        }
                        break;
                    }
View Full Code Here

TOP

Related Classes of javax.jcr.observation.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.