Search in sources :

Example 1 with Resolution

use of org.apache.jackrabbit.oak.spi.commit.PartialConflictHandler.Resolution in project jackrabbit-oak by apache.

the class MergingNodeStateDiff method resolveConflict.

//------------------------------------------------------------< private >---
private void resolveConflict(ConflictType conflictType, NodeState conflictInfo) {
    PropertyConflictHandler propertyConflictHandler = propertyConflictHandlers.get(conflictType);
    if (propertyConflictHandler != null) {
        for (PropertyState ours : conflictInfo.getProperties()) {
            PropertyState theirs = parent.getProperty(ours.getName());
            Resolution resolution = propertyConflictHandler.resolve(ours, theirs);
            applyResolution(resolution, conflictType, ours);
        }
    } else {
        NodeConflictHandler nodeConflictHandler = nodeConflictHandlers.get(conflictType);
        if (nodeConflictHandler != null) {
            for (ChildNodeEntry oursCNE : conflictInfo.getChildNodeEntries()) {
                String name = oursCNE.getName();
                NodeState ours = oursCNE.getNodeState();
                NodeState theirs = parent.getChildNode(name);
                Resolution resolution = nodeConflictHandler.resolve(name, ours, theirs);
                applyResolution(resolution, conflictType, name, ours);
                if (LOG.isDebugEnabled()) {
                    String diff = JsopDiff.diffToJsop(ours, theirs);
                    LOG.debug("{} resolved conflict of type {} with resolution {} on node {}, conflict trace {}", nodeConflictHandler, conflictType, resolution, name, diff);
                }
            }
        } else {
            LOG.warn("Ignoring unknown conflict '" + conflictType + '\'');
        }
    }
    NodeBuilder conflictMarker = getConflictMarker(conflictType);
    if (conflictMarker != null) {
        assert conflictMarker.getChildNodeCount(1) == 0;
    }
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Resolution(org.apache.jackrabbit.oak.spi.commit.PartialConflictHandler.Resolution)

Aggregations

PropertyState (org.apache.jackrabbit.oak.api.PropertyState)1 Resolution (org.apache.jackrabbit.oak.spi.commit.PartialConflictHandler.Resolution)1 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)1 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)1