Search in sources :

Example 1 with ConflictType

use of org.apache.jackrabbit.oak.spi.state.ConflictType in project jackrabbit-oak by apache.

the class ConflictValidator method getConflictMessage.

private String getConflictMessage() {
    StringBuilder sb = new StringBuilder("Commit failed due to unresolved conflicts in ");
    sb.append(path);
    sb.append(" = {");
    for (ChildNodeEntry conflict : after.getChildNode(NodeTypeConstants.REP_OURS).getChildNodeEntries()) {
        ConflictType ct = ConflictType.fromName(conflict.getName());
        NodeState node = conflict.getNodeState();
        sb.append(ct.getName()).append(" = {");
        if (ct.effectsNode()) {
            sb.append(getChildNodeNamesAsString(node));
        } else {
            for (PropertyState ps : node.getProperties()) {
                PropertyState ours = null, theirs = null;
                switch(ct) {
                    case DELETE_CHANGED_PROPERTY:
                        ours = null;
                        theirs = ps;
                        break;
                    case ADD_EXISTING_PROPERTY:
                    case CHANGE_CHANGED_PROPERTY:
                        ours = ps;
                        theirs = after.getProperty(ps.getName());
                        break;
                    case CHANGE_DELETED_PROPERTY:
                        ours = ps;
                        theirs = null;
                        break;
                }
                sb.append(ps.getName()).append(" = {").append(toString(ours)).append(',').append(toString(theirs)).append('}');
                sb.append(',');
            }
            sb.deleteCharAt(sb.length() - 1);
        }
        sb.append("},");
    }
    sb.deleteCharAt(sb.length() - 1);
    sb.append('}');
    return sb.toString();
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry) ConflictType(org.apache.jackrabbit.oak.spi.state.ConflictType) PropertyState(org.apache.jackrabbit.oak.api.PropertyState)

Aggregations

PropertyState (org.apache.jackrabbit.oak.api.PropertyState)1 ChildNodeEntry (org.apache.jackrabbit.oak.spi.state.ChildNodeEntry)1 ConflictType (org.apache.jackrabbit.oak.spi.state.ConflictType)1 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)1