Package javax.jcr.observation

Examples of javax.jcr.observation.Event


        @Override
        public void onEvent(EventIterator events) {
            try {
                while (events.hasNext()) {
                    Event event = events.nextEvent();
                    if (event.getType() == Event.NODE_ADDED) {
                        numAdded++;
                        if (!observingSession.nodeExists(event.getPath())) {
                            error = "node missing: " + event.getPath();
                        }
                    }
                    if (event.getType() == Event.NODE_REMOVED) {
                        numRemoved++;
                        if (observingSession.nodeExists(event.getPath())) {
                            error = "node not missing: " + event.getPath();
                        }
                    }
                    if (event.getType() == Event.PROPERTY_ADDED) {
                        Node node = observingSession.getNode(Text.getRelativeParent(event.getPath(), 1));
                        PropertyIterator iter = node.getProperties();
                        boolean ok = false;
                        while (iter.hasNext()) {
                            Property p = iter.nextProperty();
                            if (p.getPath().equals(event.getPath())) {
                                ok = true;
                            }
                        }
                        if (!ok) {
                            error = "property missing: " + event.getPath();
                        }
                        String name = Text.getName(event.getPath());
                        if ("test100".equals(name)) {
                            test100Exists = true;
                        } else {
                            numPropsAdded++;
                            if (!observingSession.propertyExists(event.getPath())) {
                                error = "property missing: " + event.getPath();
                            }
                        }
                    }
                    if (event.getType() == Event.PROPERTY_REMOVED) {
                        String name = Text.getName(event.getPath());
                        if ("test100".equals(name)) {
                            test100Exists = false;
                        } else {
                            numPropsRemoved++;
                            if (observingSession.propertyExists(event.getPath())) {
                                error = "property not missing: " + event.getPath();
                            }
                        }
                    }
                    if (event.getType() == Event.PROPERTY_CHANGED) {
                        String name = Text.getName(event.getPath());
                        if ("test100".equals(name)) {

                        } else {
                            numPropsModified++;
                            long v = observingSession.getProperty(event.getPath()).getLong();
                            if (v != Long.valueOf(Text.getName(name).substring(4))) {
                                error = "property has wrong content: " + event.getPath();
                            }
                        }
                    }
                }
            } catch (Exception e) {
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

            // only invalidate cache if any of the events affects the
            // nodes defining permissions for principals compiled here.
            boolean clearCache = false;
            while (events.hasNext() && !clearCache) {
                try {
                    Event ev = events.nextEvent();
                    String path = ev.getPath();
                    switch (ev.getType()) {
                        case Event.NODE_ADDED:
                            // test if the new node is an ACE node that affects
                            // the permission of any of the principals listed in
                            // principalNames.
                            NodeImpl n = (NodeImpl) session.getNode(path);
View Full Code Here

         *
         * @see javax.jcr.observation.EventListener#onEvent(EventIterator)
         */
        public void onEvent(EventIterator events) {
            while (events.hasNext()) {
                Event ev = events.nextEvent();
                try {
                    String evPath = ev.getPath();
                    String repMembers = session.getJCRName(UserConstants.P_MEMBERS);
                    if (repMembers.equals(Text.getName(evPath))) {
                        // recalculate the is...Admin flages
                        Node userNode = session.getNode(userNodePath);
                        String nodePath = Text.getRelativeParent(evPath, 1);
                        if (userAdminGroupPath.equals(nodePath)) {
                            isUserAdmin = false;
                            if (ev.getType() != Event.PROPERTY_REMOVED) {
                                Value[] vs = session.getProperty(evPath).getValues();
                                for (int i = 0; i < vs.length && !isUserAdmin; i++) {
                                    isUserAdmin = userNode.getIdentifier().equals(vs[i].getString());
                                }
                            }
                        } else if (groupAdminGroupPath.equals(nodePath)) {
                            isGroupAdmin = false;
                            if (ev.getType() != Event.PROPERTY_REMOVED) {
                                Value[] vs = session.getProperty(evPath).getValues();
                                for (int i = 0; i < vs.length && !isGroupAdmin; i++) {
                                    isGroupAdmin = userNode.getIdentifier().equals(vs[i].getString());
                                }
                            }
View Full Code Here

         */
        public synchronized void onEvent(EventIterator events) {
            try {
                boolean reload = false;
                while (events.hasNext() && !reload) {
                    Event ev = events.nextEvent();
                    String path = ev.getPath();
                    // only invalidate cache if any of the events affects the
                    // nodes defining permissions for the principals.
                    switch (ev.getType()) {
                        case Event.NODE_ADDED:
                        case Event.NODE_REMOVED:
                        case Event.NODE_MOVED:
                            reload = acPaths.contains(Text.getRelativeParent(path, 2));
                            break;
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

        }

        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);
                DomUtil.addChildElement(eType, getEventName(event.getType()), NAMESPACE);
                // user id
                DomUtil.addChildElement(eventElem, XML_EVENTUSERID, NAMESPACE, event.getUserID());
            }
            return bundle;
        }
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

        // 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

         *
         * @see javax.jcr.observation.EventListener#onEvent(EventIterator)
         */
        public void onEvent(EventIterator events) {
            while (events.hasNext()) {
                Event ev = events.nextEvent();
                try {
                    String evPath = ev.getPath();
                    String repMembers = session.getJCRName(UserConstants.P_MEMBERS);
                    if (repMembers.equals(Text.getName(evPath))) {
                        // recalculate the is...Admin flags
                        Node userNode = session.getNode(userNodePath);
                        String nodePath = Text.getRelativeParent(evPath, 1);
                        if (userAdminGroupPath.equals(nodePath)) {
                            isUserAdmin = false;
                            if (ev.getType() != Event.PROPERTY_REMOVED) {
                                Value[] vs = session.getProperty(evPath).getValues();
                                for (int i = 0; i < vs.length && !isUserAdmin; i++) {
                                    isUserAdmin = userNode.getIdentifier().equals(vs[i].getString());
                                }
                            }
                        } else if (groupAdminGroupPath.equals(nodePath)) {
                            isGroupAdmin = false;
                            if (ev.getType() != Event.PROPERTY_REMOVED) {
                                Value[] vs = session.getProperty(evPath).getValues();
                                for (int i = 0; i < vs.length && !isGroupAdmin; i++) {
                                    isGroupAdmin = userNode.getIdentifier().equals(vs[i].getString());
                                }
                            }
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.