Search in sources :

Example 31 with DavPropertyNameSet

use of org.apache.jackrabbit.webdav.property.DavPropertyNameSet in project jackrabbit by apache.

the class DavPropertyTest method testNode.

public void testNode() throws Exception {
    String uri = rs.getItemUri(getNodeId("/test"), 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 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}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 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);
    DavPropertyNameSet result = doPropFindByProp(uri, props);
    assertPropertyNames(props, result);
}
Also used : DavPropertyNameSet(org.apache.jackrabbit.webdav.property.DavPropertyNameSet)

Example 32 with DavPropertyNameSet

use of org.apache.jackrabbit.webdav.property.DavPropertyNameSet in project jackrabbit by apache.

the class DavPropertyTest method testNodeWithPrimaryItem.

public void testNodeWithPrimaryItem() throws Exception {
    // create file node
    NodeId nid = getNodeId("/test");
    Name fileName = resolver.getQName("test.txt");
    Batch b = rs.createBatch(si, nid);
    b.addNode(nid, fileName, NameConstants.NT_FILE, null);
    String filePath = testPath + "/" + fileName.getLocalName();
    NodeId fileID = getNodeId(filePath);
    b.addNode(fileID, NameConstants.JCR_CONTENT, NameConstants.NT_RESOURCE, null);
    NodeId content = getNodeId(filePath + "/" + NameConstants.JCR_CONTENT);
    QValue lastModified = rs.getQValueFactory().create(Calendar.getInstance());
    QValue mimeType = rs.getQValueFactory().create("text/plain", PropertyType.STRING);
    QValue enc = rs.getQValueFactory().create("utf-8", PropertyType.STRING);
    b.addProperty(content, resolver.getQName(JcrConstants.JCR_LASTMODIFIED), lastModified);
    b.addProperty(content, resolver.getQName(JcrConstants.JCR_MIMETYPE), mimeType);
    b.addProperty(content, resolver.getQName(JcrConstants.JCR_ENCODING), enc);
    InputStream data = new ByteArrayInputStream("سش".getBytes("UTF-8"));
    b.addProperty(content, resolver.getQName(JcrConstants.JCR_DATA), rs.getQValueFactory().create(data));
    rs.submit(b);
    // test properties of the file node
    String uri = rs.getItemUri(fileID, si);
    DavPropertyNameSet set = doPropFindNames(uri);
    DavPropertyNameSet expected = new DavPropertyNameSet(BASE_SET);
    expected.addAll(EXISTING_ITEM_BASE_SET);
    expected.addAll(NODE_SET);
    expected.add(JCR_PARENT);
    expected.add(JCR_PRIMARYITEM);
    /*
         Expected property names

        {DAV:}getlastmodified
        {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}name
        {DAV:}current-user-privilege-set
        {http://www.day.com/jcr/webdav/1.0}primarynodetype
        {DAV:}resourcetype
        {DAV:}lockdiscovery
        {DAV:}workspace
        {http://www.day.com/jcr/webdav/1.0}primaryitem
        {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(JCR_DEFINITION);
    expected.remove(JCR_INDEX);
    expected.remove(JCR_REFERENCES);
    expected.remove(JCR_WEAK_REFERENCES);
    expected.remove(JCR_PRIMARYITEM);
    /*
        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(JCR_DEFINITION);
    props.add(JCR_INDEX);
    props.add(JCR_REFERENCES);
    props.add(JCR_WEAK_REFERENCES);
    props.add(JCR_PRIMARYITEM);
    DavPropertyNameSet result = doPropFindByProp(uri, props);
    assertPropertyNames(props, result);
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) Batch(org.apache.jackrabbit.spi.Batch) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) NodeId(org.apache.jackrabbit.spi.NodeId) DavPropertyNameSet(org.apache.jackrabbit.webdav.property.DavPropertyNameSet) DavPropertyName(org.apache.jackrabbit.webdav.property.DavPropertyName) Name(org.apache.jackrabbit.spi.Name)

Example 33 with DavPropertyNameSet

use of org.apache.jackrabbit.webdav.property.DavPropertyNameSet in project jackrabbit by apache.

the class DavPropertyTest method testMVProperty.

public void testMVProperty() throws Exception {
    String uri = rs.getItemUri(getPropertyId(getNodeId("/test"), resolver.getQName("propMV")), si);
    DavPropertyNameSet set = doPropFindNames(uri);
    DavPropertyNameSet expected = new DavPropertyNameSet(BASE_SET);
    expected.addAll(EXISTING_ITEM_BASE_SET);
    expected.addAll(PROPERTY_MV_SET);
    expected.add(JCR_PARENT);
    /*
         Expected property names

        {DAV:}getlastmodified
        {DAV:}workspace
        {http://www.day.com/jcr/webdav/1.0}values
        {http://www.day.com/jcr/webdav/1.0}definition
        {DAV:}comment
        {http://www.day.com/jcr/webdav/1.0}depth
        {http://www.day.com/jcr/webdav/1.0}parent
        {DAV:}displayname
        {DAV:}supportedlock
        {http://www.day.com/jcr/webdav/1.0}workspaceName
        {http://www.day.com/jcr/webdav/1.0}subscriptiondiscovery
        {DAV:}supported-method-set
        {DAV:}iscollection
        {DAV:}creator-displayname
        {DAV:}getcontenttype
        {DAV:}creationdate
        {http://www.day.com/jcr/webdav/1.0}name
        {DAV:}supported-report-set
        {DAV:}current-user-privilege-set
        {http://www.day.com/jcr/webdav/1.0}path
        {DAV:}lockdiscovery
        {DAV:}resourcetype
        {http://www.day.com/jcr/webdav/1.0}type
        {http://www.day.com/jcr/webdav/1.0}lengths
         */
    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(JCR_DEFINITION);
    expected.remove(JCR_LENGTHS);
    /*
        Expected all-props

        {DAV:}getlastmodified
        {http://www.day.com/jcr/webdav/1.0}values
        {http://www.day.com/jcr/webdav/1.0}depth
        {http://www.day.com/jcr/webdav/1.0}parent
        {http://www.day.com/jcr/webdav/1.0}workspaceName
        {DAV:}supportedlock
        {DAV:}displayname
        {DAV:}iscollection
        {DAV:}getcontenttype
        {http://www.day.com/jcr/webdav/1.0}name
        {DAV:}creationdate
        {http://www.day.com/jcr/webdav/1.0}path
        {http://www.day.com/jcr/webdav/1.0}type
        {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(JCR_DEFINITION);
    props.add(JCR_LENGTHS);
    DavPropertyNameSet result = doPropFindByProp(uri, props);
    assertPropertyNames(props, result);
}
Also used : DavPropertyNameSet(org.apache.jackrabbit.webdav.property.DavPropertyNameSet)

Example 34 with DavPropertyNameSet

use of org.apache.jackrabbit.webdav.property.DavPropertyNameSet in project jackrabbit by apache.

the class AbstractWebdavServlet method doPropFind.

/**
     * The PROPFIND method
     *
     * @param request
     * @param response
     * @param resource
     * @throws IOException
     */
protected void doPropFind(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException {
    if (!resource.exists()) {
        response.sendError(DavServletResponse.SC_NOT_FOUND);
        return;
    }
    int depth = request.getDepth(DEPTH_INFINITY);
    DavPropertyNameSet requestProperties = request.getPropFindProperties();
    int propfindType = request.getPropFindType();
    MultiStatus mstatus = new MultiStatus();
    mstatus.addResourceProperties(resource, requestProperties, propfindType, depth);
    response.sendMultiStatus(mstatus);
}
Also used : DavPropertyNameSet(org.apache.jackrabbit.webdav.property.DavPropertyNameSet) MultiStatus(org.apache.jackrabbit.webdav.MultiStatus)

Aggregations

DavPropertyNameSet (org.apache.jackrabbit.webdav.property.DavPropertyNameSet)34 HttpResponse (org.apache.http.HttpResponse)19 RepositoryException (javax.jcr.RepositoryException)16 DavException (org.apache.jackrabbit.webdav.DavException)15 MultiStatusResponse (org.apache.jackrabbit.webdav.MultiStatusResponse)15 HttpPropfind (org.apache.jackrabbit.webdav.client.methods.HttpPropfind)15 IOException (java.io.IOException)14 DavPropertySet (org.apache.jackrabbit.webdav.property.DavPropertySet)13 NodeId (org.apache.jackrabbit.spi.NodeId)9 ItemNotFoundException (javax.jcr.ItemNotFoundException)8 Batch (org.apache.jackrabbit.spi.Batch)6 MultiStatus (org.apache.jackrabbit.webdav.MultiStatus)4 Element (org.w3c.dom.Element)4 Name (org.apache.jackrabbit.spi.Name)3 HttpProppatch (org.apache.jackrabbit.webdav.client.methods.HttpProppatch)3 DavPropertyName (org.apache.jackrabbit.webdav.property.DavPropertyName)3 HrefProperty (org.apache.jackrabbit.webdav.property.HrefProperty)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 PathNotFoundException (javax.jcr.PathNotFoundException)2