Package org.apache.jackrabbit.oak.api.ConflictHandler

Examples of org.apache.jackrabbit.oak.api.ConflictHandler.Resolution


        assert target != null;

        store.compare(fromState, toState, new NodeStateDiff() {
            @Override
            public void propertyAdded(PropertyState after) {
                Resolution resolution;
                PropertyState p = target.getProperty(after.getName());

                if (p == null) {
                    resolution = OURS;
                }
                else {
                    resolution = conflictHandler.addExistingProperty(target, after, p);
                }

                switch (resolution) {
                    case OURS:
                        setProperty(target, after);
                        break;
                    case THEIRS:
                    case MERGED:
                        break;
                }
            }

            @Override
            public void propertyChanged(PropertyState before, PropertyState after) {
                assert before.getName().equals(after.getName());

                Resolution resolution;
                PropertyState p = target.getProperty(after.getName());

                if (p == null) {
                    resolution = conflictHandler.changeDeletedProperty(target, after);
                }
                else if (before.equals(p)) {
                    resolution = OURS;
                }
                else {
                    resolution = conflictHandler.changeChangedProperty(target, after, p);
                }

                switch (resolution) {
                    case OURS:
                        setProperty(target, after);
                        break;
                    case THEIRS:
                    case MERGED:
                        break;
                }
            }

            @Override
            public void propertyDeleted(PropertyState before) {
                Resolution resolution;
                PropertyState p = target.getProperty(before.getName());

                if (before.equals(p)) {
                    resolution = OURS;
                }
                else if (p == null) {
                    resolution = conflictHandler.deleteDeletedProperty(target, before);
                }
                else {
                    resolution = conflictHandler.deleteChangedProperty(target, p);
                }

                switch (resolution) {
                    case OURS:
                        target.removeProperty(before.getName());
                        break;
                    case THEIRS:
                    case MERGED:
                        break;
                }
            }

            @Override
            public void childNodeAdded(String name, NodeState after) {
                Resolution resolution;
                TreeImpl n = target.getChild(name);

                if (n == null) {
                    resolution = OURS;
                }
                else {
                    resolution = conflictHandler.addExistingNode(target, name, after, n.getNodeState());
                }

                switch (resolution) {
                    case OURS:
                        addChild(target, name, after);
                        break;
                    case THEIRS:
                    case MERGED:
                        break;
                }
            }

            @Override
            public void childNodeChanged(String name, NodeState before, NodeState after) {
                Resolution resolution;
                TreeImpl n = target.getChild(name);

                if (n == null) {
                    resolution = conflictHandler.changeDeletedNode(target, name, after);
                }
                else {
                    merge(before, after, n, conflictHandler);
                    resolution = MERGED;
                }

                switch (resolution) {
                    case OURS:
                        addChild(target, name, after);
                        break;
                    case THEIRS:
                    case MERGED:
                        break;
                }
            }

            @Override
            public void childNodeDeleted(String name, NodeState before) {
                Resolution resolution;
                TreeImpl n = target.getChild(name);

                if (n == null) {
                    resolution = conflictHandler.deleteDeletedNode(target, name);
                }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.api.ConflictHandler.Resolution

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.