Search in sources :

Example 11 with PropertyState

use of org.apache.jackrabbit.jcr2spi.state.PropertyState in project jackrabbit by apache.

the class VersionManagerImpl method getVersionableNodeEntry.

public NodeEntry getVersionableNodeEntry(NodeState versionState) throws RepositoryException {
    NodeState ns = versionState.getChildNodeState(NameConstants.JCR_FROZENNODE, Path.INDEX_DEFAULT);
    PropertyState ps = ns.getPropertyState(NameConstants.JCR_FROZENUUID);
    String uniqueID = ps.getValue().getString();
    NodeId versionableId = workspaceManager.getIdFactory().createNodeId(uniqueID);
    return workspaceManager.getHierarchyManager().getNodeEntry(versionableId);
}
Also used : NodeState(org.apache.jackrabbit.jcr2spi.state.NodeState) NodeId(org.apache.jackrabbit.spi.NodeId) PropertyState(org.apache.jackrabbit.jcr2spi.state.PropertyState)

Example 12 with PropertyState

use of org.apache.jackrabbit.jcr2spi.state.PropertyState in project jackrabbit by apache.

the class VersionManagerImpl method resolveMergeConflict.

public void resolveMergeConflict(NodeState nodeState, NodeState versionState, boolean done) throws RepositoryException {
    NodeId vId = versionState.getNodeId();
    PropertyState mergeFailedState = nodeState.getPropertyState(NameConstants.JCR_MERGEFAILED);
    QValue[] vs = mergeFailedState.getValues();
    NodeId[] mergeFailedIds = new NodeId[vs.length - 1];
    for (int i = 0, j = 0; i < vs.length; i++) {
        NodeId id = workspaceManager.getIdFactory().createNodeId(vs[i].getString());
        if (!id.equals(vId)) {
            mergeFailedIds[j] = id;
            j++;
        }
    // else: the version id is being solved by this call and not
    // part of 'jcr:mergefailed' any more
    }
    PropertyState predecessorState = nodeState.getPropertyState(NameConstants.JCR_PREDECESSORS);
    vs = predecessorState.getValues();
    int noOfPredecessors = (done) ? vs.length + 1 : vs.length;
    NodeId[] predecessorIds = new NodeId[noOfPredecessors];
    int i = 0;
    while (i < vs.length) {
        predecessorIds[i] = workspaceManager.getIdFactory().createNodeId(vs[i].getString());
        i++;
    }
    if (done) {
        predecessorIds[i] = vId;
    }
    Operation op = ResolveMergeConflict.create(nodeState, mergeFailedIds, predecessorIds, done);
    workspaceManager.execute(op);
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) NodeId(org.apache.jackrabbit.spi.NodeId) Operation(org.apache.jackrabbit.jcr2spi.operation.Operation) Checkpoint(org.apache.jackrabbit.jcr2spi.operation.Checkpoint) PropertyState(org.apache.jackrabbit.jcr2spi.state.PropertyState)

Aggregations

PropertyState (org.apache.jackrabbit.jcr2spi.state.PropertyState)12 ItemNotFoundException (javax.jcr.ItemNotFoundException)5 NodeState (org.apache.jackrabbit.jcr2spi.state.NodeState)5 Operation (org.apache.jackrabbit.jcr2spi.operation.Operation)3 Name (org.apache.jackrabbit.spi.Name)3 NodeId (org.apache.jackrabbit.spi.NodeId)3 QPropertyDefinition (org.apache.jackrabbit.spi.QPropertyDefinition)3 ItemExistsException (javax.jcr.ItemExistsException)2 RepositoryException (javax.jcr.RepositoryException)2 NodeEntry (org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry)2 QValue (org.apache.jackrabbit.spi.QValue)2 Item (javax.jcr.Item)1 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)1 PropertyEntry (org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry)1 AddNode (org.apache.jackrabbit.jcr2spi.operation.AddNode)1 Checkpoint (org.apache.jackrabbit.jcr2spi.operation.Checkpoint)1 ItemState (org.apache.jackrabbit.jcr2spi.state.ItemState)1 Path (org.apache.jackrabbit.spi.Path)1 QNodeDefinition (org.apache.jackrabbit.spi.QNodeDefinition)1