Search in sources :

Example 11 with NodeInfo

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

the class CopyTest method testCopyAcrossWorkspaces.

public void testCopyAcrossWorkspaces() throws RepositoryException {
    // todo: retrieve second wsp-name from config
    sInfo = rs.obtain(si, "test");
    NodeId srcId = getNodeId(testPath);
    NodeId destParentId = getNodeId("/");
    rs.copy(sInfo, si.getWorkspaceName(), srcId, destParentId, resolver.getQName("destname"));
    copiedId = getNodeId("/destname");
    NodeInfo nInfo = rs.getNodeInfo(sInfo, copiedId);
    Iterator<? extends ItemInfo> it = rs.getItemInfos(sInfo, copiedId);
    assertTrue(it.hasNext());
    NodeInfo nInfo2 = (NodeInfo) it.next();
    assertEquals(nInfo.getId(), nInfo2.getId());
    assertEquals(nInfo.getNodetype(), nInfo2.getNodetype());
}
Also used : NodeInfo(org.apache.jackrabbit.spi.NodeInfo) NodeId(org.apache.jackrabbit.spi.NodeId)

Example 12 with NodeInfo

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

the class BatchTest method testSetReferenceValue.

public void testSetReferenceValue() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    NodeInfo nInfo = rs.getNodeInfo(si, nid);
    if (!Arrays.asList(nInfo.getMixins()).contains(NameConstants.MIX_REFERENCEABLE)) {
        Batch b = rs.createBatch(si, nid);
        b.setMixins(nid, new Name[] { NameConstants.MIX_REFERENCEABLE });
        rs.submit(b);
    }
    String ref = rs.getNodeInfo(si, nid).getId().getUniqueID();
    Name propName = resolver.getQName("refProp");
    QValue v = rs.getQValueFactory().create(ref, PropertyType.REFERENCE);
    Batch b = rs.createBatch(si, nid);
    b.addProperty(nid, propName, v);
    rs.submit(b);
    PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
    assertFalse(pi.isMultiValued());
    assertEquals(v, pi.getValues()[0]);
    assertEquals(PropertyType.REFERENCE, pi.getType());
    pi = getPropertyInfo(nid, propName);
    assertEquals(v, pi.getValues()[0]);
    assertEquals(PropertyType.REFERENCE, pi.getType());
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) Batch(org.apache.jackrabbit.spi.Batch) NodeInfo(org.apache.jackrabbit.spi.NodeInfo) NodeId(org.apache.jackrabbit.spi.NodeId) PropertyInfo(org.apache.jackrabbit.spi.PropertyInfo) Name(org.apache.jackrabbit.spi.Name)

Example 13 with NodeInfo

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

the class ExtensionTest method testIndex.

public void testIndex() throws RepositoryException {
    Name testName = resolver.getQName("test");
    testPath = "/test";
    createTestNode("/test");
    createTestNode("/test");
    NodeInfo nInfo = rs.getNodeInfo(si, getNodeId("/test[2]"));
    //System.out.println("NodeInfo: " + nInfo.getPath().getNameElement().getName());
    assertEquals(testName, nInfo.getPath().getName());
    Iterator<? extends ItemInfo> it = rs.getItemInfos(si, getNodeId("/test[2]"));
    assertTrue(it.hasNext());
    nInfo = (NodeInfo) it.next();
    //System.out.println("ItemInfo: " + nInfo.getPath().getNameElement().getName());
    assertEquals(testName, nInfo.getPath().getName());
    removeTestNode("/test[2]");
}
Also used : NodeInfo(org.apache.jackrabbit.spi.NodeInfo) Name(org.apache.jackrabbit.spi.Name)

Example 14 with NodeInfo

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

the class BatchTest method testSetMixin.

public void testSetMixin() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    Batch b = rs.createBatch(si, nid);
    b.addNode(nid, resolver.getQName("anyNode"), NameConstants.NT_UNSTRUCTURED, null);
    NodeId id = getNodeId(testPath + "/anyNode");
    b.setMixins(id, new Name[] { NameConstants.MIX_LOCKABLE });
    rs.submit(b);
    b = rs.createBatch(si, id);
    b.setMixins(id, new Name[0]);
    rs.submit(b);
    NodeInfo nInfo = rs.getNodeInfo(si, id);
    assertEquals(0, nInfo.getMixins().length);
}
Also used : Batch(org.apache.jackrabbit.spi.Batch) NodeInfo(org.apache.jackrabbit.spi.NodeInfo) NodeId(org.apache.jackrabbit.spi.NodeId)

Example 15 with NodeInfo

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

the class BatchTest method testSetWeakReferenceValue.

public void testSetWeakReferenceValue() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    NodeInfo nInfo = rs.getNodeInfo(si, nid);
    if (!Arrays.asList(nInfo.getMixins()).contains(NameConstants.MIX_REFERENCEABLE)) {
        Batch b = rs.createBatch(si, nid);
        b.setMixins(nid, new Name[] { NameConstants.MIX_REFERENCEABLE });
        rs.submit(b);
    }
    String ref = rs.getNodeInfo(si, nid).getId().getUniqueID();
    Name propName = resolver.getQName("weakRefProp");
    QValue v = rs.getQValueFactory().create(ref, PropertyType.WEAKREFERENCE);
    Batch b = rs.createBatch(si, nid);
    b.addProperty(nid, propName, v);
    rs.submit(b);
    PropertyInfo pi = rs.getPropertyInfo(si, getPropertyId(nid, propName));
    assertFalse(pi.isMultiValued());
    assertEquals(v, pi.getValues()[0]);
    assertEquals(PropertyType.WEAKREFERENCE, pi.getType());
    pi = getPropertyInfo(nid, propName);
    assertEquals(v, pi.getValues()[0]);
    assertEquals(PropertyType.WEAKREFERENCE, pi.getType());
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) Batch(org.apache.jackrabbit.spi.Batch) NodeInfo(org.apache.jackrabbit.spi.NodeInfo) NodeId(org.apache.jackrabbit.spi.NodeId) PropertyInfo(org.apache.jackrabbit.spi.PropertyInfo) Name(org.apache.jackrabbit.spi.Name)

Aggregations

NodeInfo (org.apache.jackrabbit.spi.NodeInfo)17 NodeId (org.apache.jackrabbit.spi.NodeId)10 Batch (org.apache.jackrabbit.spi.Batch)6 Name (org.apache.jackrabbit.spi.Name)6 ItemInfo (org.apache.jackrabbit.spi.ItemInfo)5 PropertyInfo (org.apache.jackrabbit.spi.PropertyInfo)5 RepositoryException (javax.jcr.RepositoryException)4 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ItemNotFoundException (javax.jcr.ItemNotFoundException)2 PathNotFoundException (javax.jcr.PathNotFoundException)2 ChildInfo (org.apache.jackrabbit.spi.ChildInfo)2 QValue (org.apache.jackrabbit.spi.QValue)2 ItemVisitor (javax.jcr.ItemVisitor)1 Node (javax.jcr.Node)1 Property (javax.jcr.Property)1 TraversingItemVisitor (javax.jcr.util.TraversingItemVisitor)1 HierarchyEntry (org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry)1 ItemId (org.apache.jackrabbit.spi.ItemId)1 Path (org.apache.jackrabbit.spi.Path)1