Search in sources :

Example 76 with QValue

use of org.apache.jackrabbit.spi.QValue 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)

Example 77 with QValue

use of org.apache.jackrabbit.spi.QValue in project jackrabbit by apache.

the class BinaryTest method testBinaryTwiceNewProperty.

public void testBinaryTwiceNewProperty() throws Exception {
    Node test = testRootNode.addNode("test");
    Property p = test.setProperty("prop", generateValue());
    QValue qv1 = getQValue(p);
    test.setProperty("prop", generateValue());
    QValue qv2 = getQValue(p);
    assertFalse(qv1.equals(qv2));
    superuser.save();
    assertEquals(qv2, getQValue(p));
    assertDisposed(qv1);
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) Node(javax.jcr.Node) Property(javax.jcr.Property)

Example 78 with QValue

use of org.apache.jackrabbit.spi.QValue in project jackrabbit by apache.

the class BinaryTest method testRevertSettingExistingBinary.

public void testRevertSettingExistingBinary() throws Exception {
    Node test = testRootNode.addNode("test");
    Binary b = superuser.getValueFactory().createBinary(generateValue());
    Property p = test.setProperty("prop", b);
    QValue qv1 = getQValue(p);
    superuser.save();
    Binary b2 = superuser.getValueFactory().createBinary(generateValue());
    test.setProperty("prop", b2);
    QValue qv2 = getQValue(p);
    assertFalse(qv1.equals(qv2));
    superuser.refresh(false);
    assertEquals(qv1, getQValue(p));
    assertSame(qv1, getQValue(p));
    assertFalse(qv2.equals(getQValue(p)));
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) Node(javax.jcr.Node) Binary(javax.jcr.Binary) Property(javax.jcr.Property)

Example 79 with QValue

use of org.apache.jackrabbit.spi.QValue in project jackrabbit by apache.

the class QValueFactoryLogger method create.

public QValue create(final InputStream value) throws RepositoryException, IOException {
    final String methodName = "create(InputStream)";
    final Object[] args = new Object[] { value };
    final IOException[] ex = new IOException[1];
    QValue result = (QValue) execute(new Callable() {

        public Object call() throws RepositoryException {
            try {
                return qValueFactory.create(value);
            } catch (IOException e) {
                ex[0] = e;
                return null;
            }
        }
    }, methodName, args);
    if (ex[0] != null) {
        throw ex[0];
    }
    return result;
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) IOException(java.io.IOException)

Example 80 with QValue

use of org.apache.jackrabbit.spi.QValue in project jackrabbit by apache.

the class QValueFactoryLogger method create.

public QValue create(final File value) throws RepositoryException, IOException {
    final String methodName = "create(File)";
    final Object[] args = new Object[] { value };
    final IOException[] ex = new IOException[1];
    QValue result = (QValue) execute(new Callable() {

        public Object call() throws RepositoryException {
            try {
                return qValueFactory.create(value);
            } catch (IOException e) {
                ex[0] = e;
                return null;
            }
        }
    }, methodName, args);
    if (ex[0] != null) {
        throw ex[0];
    }
    return result;
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) IOException(java.io.IOException)

Aggregations

QValue (org.apache.jackrabbit.spi.QValue)125 Name (org.apache.jackrabbit.spi.Name)40 RepositoryException (javax.jcr.RepositoryException)23 Value (javax.jcr.Value)21 NodeId (org.apache.jackrabbit.spi.NodeId)21 Batch (org.apache.jackrabbit.spi.Batch)19 PropertyInfo (org.apache.jackrabbit.spi.PropertyInfo)18 QPropertyDefinition (org.apache.jackrabbit.spi.QPropertyDefinition)12 IOException (java.io.IOException)9 ArrayList (java.util.ArrayList)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)8 ValueFormatException (javax.jcr.ValueFormatException)8 Path (org.apache.jackrabbit.spi.Path)8 QValueConstraint (org.apache.jackrabbit.spi.QValueConstraint)8 HashMap (java.util.HashMap)7 ValueConstraint (org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint)7 InputStream (java.io.InputStream)5 Node (javax.jcr.Node)5 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)5 PropertyId (org.apache.jackrabbit.spi.PropertyId)5