Search in sources :

Example 6 with NodeId

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

the class DavPropertyTest method testReferenceableNode.

public void testReferenceableNode() throws Exception {
    NodeId nid = getNodeId("/test");
    Batch b = rs.createBatch(si, nid);
    b.setMixins(nid, new Name[] { NameConstants.MIX_REFERENCEABLE });
    rs.submit(b);
    String uri = rs.getItemUri(nid, si);
    DavPropertyNameSet set = doPropFindNames(uri);
    DavPropertyNameSet expected = new DavPropertyNameSet(BASE_SET);
    expected.addAll(EXISTING_ITEM_BASE_SET);
    expected.addAll(NODE_SET);
    expected.add(OrderingConstants.ORDERING_TYPE);
    expected.add(JCR_PARENT);
    expected.add(JCR_UUID);
    /*
         Expected property names

        {DAV:}getlastmodified
        {DAV:}ordering-type
        {http://www.day.com/jcr/webdav/1.0}definition
        {DAV:}comment
        {http://www.day.com/jcr/webdav/1.0}references
        {http://www.day.com/jcr/webdav/1.0}parent
        {DAV:}displayname
        {http://www.day.com/jcr/webdav/1.0}workspaceName
        {http://www.day.com/jcr/webdav/1.0}subscriptiondiscovery
        {http://www.day.com/jcr/webdav/1.0}uuid
        {http://www.day.com/jcr/webdav/1.0}name
        {DAV:}current-user-privilege-set
        {http://www.day.com/jcr/webdav/1.0}primarynodetype
        {DAV:}lockdiscovery
        {DAV:}resourcetype
        {DAV:}workspace
        {http://www.day.com/jcr/webdav/1.0}depth
        {http://www.day.com/jcr/webdav/1.0}index
        {DAV:}supportedlock
        {DAV:}supported-method-set
        {DAV:}iscollection
        {http://www.day.com/jcr/webdav/1.0}weakreferences
        {DAV:}creator-displayname
        {DAV:}getcontenttype
        {DAV:}creationdate
        {DAV:}supported-report-set
        {http://www.day.com/jcr/webdav/1.0}mixinnodetypes
        {http://www.day.com/jcr/webdav/1.0}path
        */
    assertPropertyNames(expected, set);
    DavPropertyNameSet all = doPropFindAll(uri);
    expected.remove(DeltaVConstants.COMMENT);
    expected.remove(DeltaVConstants.CREATOR_DISPLAYNAME);
    expected.remove(DeltaVConstants.SUPPORTED_METHOD_SET);
    expected.remove(DeltaVConstants.SUPPORTED_REPORT_SET);
    expected.remove(DeltaVConstants.WORKSPACE);
    expected.remove(SecurityConstants.CURRENT_USER_PRIVILEGE_SET);
    expected.remove(ObservationConstants.SUBSCRIPTIONDISCOVERY);
    expected.remove(OrderingConstants.ORDERING_TYPE);
    expected.remove(JCR_DEFINITION);
    expected.remove(JCR_INDEX);
    expected.remove(JCR_REFERENCES);
    expected.remove(JCR_WEAK_REFERENCES);
    expected.remove(JCR_UUID);
    /*
        Expected all-props

        {DAV:}getlastmodified
        {http://www.day.com/jcr/webdav/1.0}depth
        {http://www.day.com/jcr/webdav/1.0}workspaceName
        {DAV:}displayname
        {http://www.day.com/jcr/webdav/1.0}parent
        {DAV:}supportedlock
        {DAV:}iscollection
        {DAV:}getcontenttype
        {http://www.day.com/jcr/webdav/1.0}name
        {DAV:}creationdate
        {http://www.day.com/jcr/webdav/1.0}mixinnodetypes
        {http://www.day.com/jcr/webdav/1.0}path
        {http://www.day.com/jcr/webdav/1.0}primarynodetype
        {DAV:}lockdiscovery
        {DAV:}resourcetype
         */
    assertPropertyNames(expected, all);
    DavPropertyNameSet props = new DavPropertyNameSet();
    props.add(DeltaVConstants.COMMENT);
    props.add(DeltaVConstants.CREATOR_DISPLAYNAME);
    props.add(DeltaVConstants.SUPPORTED_METHOD_SET);
    props.add(DeltaVConstants.SUPPORTED_REPORT_SET);
    props.add(DeltaVConstants.WORKSPACE);
    props.add(SecurityConstants.CURRENT_USER_PRIVILEGE_SET);
    props.add(ObservationConstants.SUBSCRIPTIONDISCOVERY);
    props.add(OrderingConstants.ORDERING_TYPE);
    props.add(JCR_DEFINITION);
    props.add(JCR_INDEX);
    props.add(JCR_REFERENCES);
    props.add(JCR_WEAK_REFERENCES);
    props.add(JCR_UUID);
    DavPropertyNameSet result = doPropFindByProp(uri, props);
    assertPropertyNames(props, result);
}
Also used : Batch(org.apache.jackrabbit.spi.Batch) NodeId(org.apache.jackrabbit.spi.NodeId) DavPropertyNameSet(org.apache.jackrabbit.webdav.property.DavPropertyNameSet)

Example 7 with NodeId

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

the class BatchTest method testSetDateValue.

public void testSetDateValue() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    Name propName = resolver.getQName("dateProp");
    QValue v = rs.getQValueFactory().create(Calendar.getInstance());
    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(v.getString(), pi.getValues()[0].getString());
    assertEquals(PropertyType.DATE, pi.getType());
    pi = getPropertyInfo(nid, propName);
    assertEquals(v, pi.getValues()[0]);
    assertEquals(v.getString(), pi.getValues()[0].getString());
    assertEquals(PropertyType.DATE, pi.getType());
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) Batch(org.apache.jackrabbit.spi.Batch) NodeId(org.apache.jackrabbit.spi.NodeId) PropertyInfo(org.apache.jackrabbit.spi.PropertyInfo) Name(org.apache.jackrabbit.spi.Name)

Example 8 with NodeId

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

the class BatchTest method testMove.

public void testMove() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    Batch b = rs.createBatch(si, nid);
    b.addNode(nid, resolver.getQName("anyNode"), NameConstants.NT_UNSTRUCTURED, null);
    rs.submit(b);
    NodeId id = getNodeId(testPath + "/anyNode");
    b = rs.createBatch(si, nid);
    b.move(id, nid, resolver.getQName("moved"));
    rs.submit(b);
    try {
        rs.getItemInfos(si, id);
        fail();
    } catch (RepositoryException e) {
    // ok
    }
    rs.getNodeInfo(si, getNodeId(testPath + "/moved"));
}
Also used : Batch(org.apache.jackrabbit.spi.Batch) NodeId(org.apache.jackrabbit.spi.NodeId) RepositoryException(javax.jcr.RepositoryException)

Example 9 with NodeId

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

the class BatchTest method testSetLongValue.

public void testSetLongValue() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    Name propName = resolver.getQName("doubleProp");
    QValue v = rs.getQValueFactory().create(234567);
    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(v.getString(), pi.getValues()[0].getString());
    assertEquals(PropertyType.LONG, pi.getType());
    pi = getPropertyInfo(nid, propName);
    assertEquals(v, pi.getValues()[0]);
    assertEquals(v.getString(), pi.getValues()[0].getString());
    assertEquals(PropertyType.LONG, pi.getType());
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) Batch(org.apache.jackrabbit.spi.Batch) NodeId(org.apache.jackrabbit.spi.NodeId) PropertyInfo(org.apache.jackrabbit.spi.PropertyInfo) Name(org.apache.jackrabbit.spi.Name)

Example 10 with NodeId

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

the class BatchTest method testEmptyValueArray.

public void testEmptyValueArray() throws RepositoryException {
    NodeId nid = getNodeId(testPath);
    Name propName = resolver.getQName("mvProperty");
    Batch b = rs.createBatch(si, nid);
    b.addProperty(nid, propName, new QValue[0]);
    rs.submit(b);
    PropertyId pid = getPropertyId(nid, propName);
    PropertyInfo pi = rs.getPropertyInfo(si, pid);
    assertTrue(pi.isMultiValued());
    assertEquals(Arrays.asList(new QValue[0]), Arrays.asList(pi.getValues()));
    assertFalse(pi.getType() == PropertyType.UNDEFINED);
    Iterator<? extends ItemInfo> it = rs.getItemInfos(si, nid);
    while (it.hasNext()) {
        ItemInfo info = it.next();
        if (!info.denotesNode()) {
            PropertyInfo pInfo = (PropertyInfo) info;
            if (propName.equals((pInfo.getId().getName()))) {
                assertTrue(pi.isMultiValued());
                assertEquals(Arrays.asList(new QValue[0]), Arrays.asList(pi.getValues()));
                assertFalse(pi.getType() == PropertyType.UNDEFINED);
                break;
            }
        }
    }
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) Batch(org.apache.jackrabbit.spi.Batch) ItemInfo(org.apache.jackrabbit.spi.ItemInfo) NodeId(org.apache.jackrabbit.spi.NodeId) PropertyInfo(org.apache.jackrabbit.spi.PropertyInfo) Name(org.apache.jackrabbit.spi.Name) PropertyId(org.apache.jackrabbit.spi.PropertyId)

Aggregations

NodeId (org.apache.jackrabbit.spi.NodeId)80 Batch (org.apache.jackrabbit.spi.Batch)35 Name (org.apache.jackrabbit.spi.Name)32 PropertyInfo (org.apache.jackrabbit.spi.PropertyInfo)23 RepositoryException (javax.jcr.RepositoryException)21 QValue (org.apache.jackrabbit.spi.QValue)21 PropertyId (org.apache.jackrabbit.spi.PropertyId)13 Path (org.apache.jackrabbit.spi.Path)11 NodeInfo (org.apache.jackrabbit.spi.NodeInfo)10 ArrayList (java.util.ArrayList)9 ItemNotFoundException (javax.jcr.ItemNotFoundException)9 DavPropertyNameSet (org.apache.jackrabbit.webdav.property.DavPropertyNameSet)9 IOException (java.io.IOException)6 Node (javax.jcr.Node)5 HttpResponse (org.apache.http.HttpResponse)5 ItemId (org.apache.jackrabbit.spi.ItemId)5 DavException (org.apache.jackrabbit.webdav.DavException)5 InputStream (java.io.InputStream)4 ChildInfo (org.apache.jackrabbit.spi.ChildInfo)4 PathNotFoundException (javax.jcr.PathNotFoundException)3