Package org.apache.jackrabbit.oak.plugins.observation.filter

Examples of org.apache.jackrabbit.oak.plugins.observation.filter.FilterBuilder


    public void filterDisjunctPaths()
            throws ExecutionException, InterruptedException, RepositoryException {
        assumeTrue(observationManager instanceof ObservationManagerImpl);
        ObservationManagerImpl oManager = (ObservationManagerImpl) observationManager;
        ExpectationListener listener = new ExpectationListener();
        FilterBuilder builder = new FilterBuilder();
        builder.condition(builder.any(
                builder.path(TEST_PATH + "/a/b"),
                builder.path(TEST_PATH + "/x/y")));
        oManager.addEventListener(listener, builder.build());

        Node testNode = getNode(TEST_PATH);
        Node b = testNode.addNode("a").addNode("b");
        b.addNode("c");
        Node y = testNode.addNode("x").addNode("y");
View Full Code Here


    public void filterPropertyOfParent()
            throws RepositoryException, ExecutionException, InterruptedException {
        assumeTrue(observationManager instanceof ObservationManagerImpl);
        ObservationManagerImpl oManager = (ObservationManagerImpl) observationManager;
        ExpectationListener listener = new ExpectationListener();
        FilterBuilder builder = new FilterBuilder();

        // Events for all items whose parent has a property named "foo" with value "bar"
        builder.condition(builder.property(Selectors.PARENT, "foo",
                new Predicate<PropertyState>() {
                    @Override
                    public boolean apply(PropertyState property) {
                        return "bar".equals(property.getValue(STRING));
                    }
                }));
        oManager.addEventListener(listener, builder.build());

        Node testNode = getNode(TEST_PATH);
        Node a = testNode.addNode("a");
        Node x = testNode.addNode("x");
        a.setProperty("foo", "bar");
View Full Code Here

    public void filterPropertyOfChild()
            throws RepositoryException, ExecutionException, InterruptedException {
        assumeTrue(observationManager instanceof ObservationManagerImpl);
        ObservationManagerImpl oManager = (ObservationManagerImpl) observationManager;
        ExpectationListener listener = new ExpectationListener();
        FilterBuilder builder = new FilterBuilder();

        // Events for all items that have a property "b/c/foo" with value "bar"
        builder.condition(builder.property(Selectors.fromThis("b/c"), "foo",
                new Predicate<PropertyState>() {
            @Override
            public boolean apply(PropertyState property) {
                return "bar".equals(property.getValue(STRING));
            }
        }));
        oManager.addEventListener(listener, builder.build());

        Node testNode = getNode(TEST_PATH);
        Node a = testNode.addNode("a");
        a.addNode("b").addNode("c").setProperty("foo", "bar");
        a.addNode("d");
View Full Code Here

    @Override
    public void addEventListener(EventListener listener, int eventTypes, String absPath,
            boolean isDeep, String[] uuids, String[] nodeTypeName, boolean noLocal)
            throws RepositoryException {

        FilterBuilder filterBuilder = new FilterBuilder();
        filterBuilder
            .basePath(namePathMapper.getOakPath(absPath))
            .includeSessionLocal(!noLocal)
            .includeClusterExternal(!(listener instanceof ExcludeExternal))
            .condition(filterBuilder.all(
                filterBuilder.path(isDeep ? STAR_STAR : STAR),
                filterBuilder.eventType(eventTypes),
                filterBuilder.uuid(Selectors.PARENT, uuids),
                filterBuilder.nodeType(Selectors.PARENT, validateNodeTypeNames(nodeTypeName))));

        ListenerTracker tracker = new ListenerTracker(
                listener, eventTypes, absPath, isDeep, uuids, nodeTypeName, noLocal) {
            @Override
            protected void warn(String message) {
                LOG.warn(DEPRECATED, message, initStackTrace);
            }
            @Override
            protected void beforeEventDelivery() {
                sessionDelegate.refreshAtNextAccess();
            }
        };

        addEventListener(listener, tracker, filterBuilder.build());
    }
View Full Code Here

    @Override
    public void addEventListener(EventListener listener, int eventTypes, String absPath,
            boolean isDeep, String[] uuids, String[] nodeTypeName, boolean noLocal)
            throws RepositoryException {

        FilterBuilder filterBuilder = new FilterBuilder();
        filterBuilder
            .basePath(namePathMapper.getOakPath(absPath))
            .includeSessionLocal(!noLocal)
            .includeClusterExternal(!(listener instanceof ExcludeExternal))
            .condition(filterBuilder.all(
                filterBuilder.path(isDeep ? STAR_STAR : STAR),
                filterBuilder.eventType(eventTypes),
                filterBuilder.uuid(Selectors.PARENT, uuids),
                filterBuilder.nodeType(Selectors.PARENT, validateNodeTypeNames(nodeTypeName))));

        ListenerTracker tracker = new ListenerTracker(
                listener, eventTypes, absPath, isDeep, uuids, nodeTypeName, noLocal) {
            @Override
            protected void warn(String message) {
                LOG.warn(DEPRECATED, message, initStackTrace);
            }
            @Override
            protected void beforeEventDelivery() {
                sessionDelegate.refreshAtNextAccess();
            }
        };

        addEventListener(listener, tracker, filterBuilder.build());
    }
View Full Code Here

    @Override
    public void addEventListener(EventListener listener, int eventTypes, String absPath,
            boolean isDeep, String[] uuids, String[] nodeTypeName, boolean noLocal)
            throws RepositoryException {

        FilterBuilder filterBuilder = new FilterBuilder();
        filterBuilder
            .basePath(namePathMapper.getOakPath(absPath))
            .includeSessionLocal(!noLocal)
            .includeClusterExternal(!(listener instanceof ExcludeExternal))
            .condition(filterBuilder.all(
                filterBuilder.path(isDeep ? STAR_STAR : STAR),
                filterBuilder.eventType(eventTypes),
                filterBuilder.uuid(Selectors.PARENT, uuids),
                filterBuilder.nodeType(Selectors.PARENT, validateNodeTypeNames(nodeTypeName))));

        ListenerTracker tracker = new ListenerTracker(
                listener, eventTypes, absPath, isDeep, uuids, nodeTypeName, noLocal) {
            @Override
            protected void warn(String message) {
                LOG.warn(DEPRECATED, message, initStackTrace);
            }
            @Override
            protected void beforeEventDelivery() {
                sessionDelegate.refreshAtNextAccess();
            }
        };

        addEventListener(listener, tracker, filterBuilder.build());
    }
View Full Code Here

    public void filterDisjunctPaths()
            throws ExecutionException, InterruptedException, RepositoryException {
        assumeTrue(observationManager instanceof ObservationManagerImpl);
        ObservationManagerImpl oManager = (ObservationManagerImpl) observationManager;
        ExpectationListener listener = new ExpectationListener();
        FilterBuilder builder = new FilterBuilder();
        builder.condition(builder.any(
                builder.path(TEST_PATH + "/a/b"),
                builder.path(TEST_PATH + "/x/y")));
        oManager.addEventListener(listener, builder.build());

        Node testNode = getNode(TEST_PATH);
        Node b = testNode.addNode("a").addNode("b");
        b.addNode("c");
        Node y = testNode.addNode("x").addNode("y");
View Full Code Here

    public void filterPropertyOfParent()
            throws RepositoryException, ExecutionException, InterruptedException {
        assumeTrue(observationManager instanceof ObservationManagerImpl);
        ObservationManagerImpl oManager = (ObservationManagerImpl) observationManager;
        ExpectationListener listener = new ExpectationListener();
        FilterBuilder builder = new FilterBuilder();

        // Events for all items whose parent has a property named "foo" with value "bar"
        builder.condition(builder.property(Selectors.PARENT, "foo",
                new Predicate<PropertyState>() {
                    @Override
                    public boolean apply(PropertyState property) {
                        return "bar".equals(property.getValue(STRING));
                    }
                }));
        oManager.addEventListener(listener, builder.build());

        Node testNode = getNode(TEST_PATH);
        Node a = testNode.addNode("a");
        Node x = testNode.addNode("x");
        a.setProperty("foo", "bar");
View Full Code Here

    public void filterPropertyOfChild()
            throws RepositoryException, ExecutionException, InterruptedException {
        assumeTrue(observationManager instanceof ObservationManagerImpl);
        ObservationManagerImpl oManager = (ObservationManagerImpl) observationManager;
        ExpectationListener listener = new ExpectationListener();
        FilterBuilder builder = new FilterBuilder();

        // Events for all items that have a property "b/c/foo" with value "bar"
        builder.condition(builder.property(Selectors.fromThis("b/c"), "foo",
                new Predicate<PropertyState>() {
                    @Override
                    public boolean apply(PropertyState property) {
                        return "bar".equals(property.getValue(STRING));
                    }
                }));
        oManager.addEventListener(listener, builder.build());

        Node testNode = getNode(TEST_PATH);
        Node a = testNode.addNode("a");
        a.addNode("b").addNode("c").setProperty("foo", "bar");
        a.addNode("d");
View Full Code Here

    @Test
    public void addSubtreeFilter() throws RepositoryException, ExecutionException, InterruptedException {
        assumeTrue(observationManager instanceof ObservationManagerImpl);
        ObservationManagerImpl oManager = (ObservationManagerImpl) observationManager;
        ExpectationListener listener = new ExpectationListener();
        FilterBuilder builder = new FilterBuilder();

        // Only generate events for the root of added sub trees
        builder.condition(builder.addSubtree());
        oManager.addEventListener(listener, builder.build());

        Node testNode = getNode(TEST_PATH);
        Node a = listener.expectAdd(testNode.addNode("a"));
        a.addNode("c");
        testNode.getSession().save();
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.plugins.observation.filter.FilterBuilder

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.