Search in sources :

Example 6 with DavPropertyNameSet

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

the class DavPropertyTest method testVersion.

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

        {DAV:}getlastmodified
        {DAV:}version-name
        {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
        {DAV:}checkout-set
        {DAV:}predecessor-set
        {http://www.day.com/jcr/webdav/1.0}name
        {DAV:}current-user-privilege-set
        {http://www.day.com/jcr/webdav/1.0}primarynodetype
        {DAV:}version-history
        {DAV:}successor-set
        {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:}label-name-set
        {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_UUID);
    expected.remove(VersionResource.VERSION_NAME);
    expected.remove(VersionResource.LABEL_NAME_SET);
    expected.remove(VersionResource.PREDECESSOR_SET);
    expected.remove(VersionResource.SUCCESSOR_SET);
    expected.remove(VersionResource.VERSION_HISTORY);
    expected.remove(VersionResource.CHECKOUT_SET);
    /*
        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_UUID);
    props.add(VersionResource.VERSION_NAME);
    props.add(VersionResource.LABEL_NAME_SET);
    props.add(VersionResource.PREDECESSOR_SET);
    props.add(VersionResource.SUCCESSOR_SET);
    props.add(VersionResource.VERSION_HISTORY);
    props.add(VersionResource.CHECKOUT_SET);
    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 DavPropertyNameSet

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

the class DavPropertyTest method testRepositoryRoot.

public void testRepositoryRoot() throws Exception {
    DavPropertyNameSet names = doPropFindNames(repoURI);
    DavPropertyNameSet expected = new DavPropertyNameSet(BASE_SET);
    /*
         Expected property names

         {DAV:}getlastmodified
         {DAV:}creator-displayname
         {DAV:}comment
         {DAV:}creationdate
         {DAV:}supported-report-set
         {DAV:}displayname
         {DAV:}supportedlock
         {http://www.day.com/jcr/webdav/1.0}workspaceName
         {DAV:}resourcetype
         {DAV:}lockdiscovery
         {DAV:}supported-method-set
         {DAV:}iscollection
         */
    assertPropertyNames(expected, names);
    DavPropertyNameSet all = doPropFindAll(repoURI);
    expected.remove(DeltaVConstants.COMMENT);
    expected.remove(DeltaVConstants.CREATOR_DISPLAYNAME);
    expected.remove(DeltaVConstants.SUPPORTED_METHOD_SET);
    expected.remove(DeltaVConstants.SUPPORTED_REPORT_SET);
    /*
        Expected all-props

        {DAV:}getlastmodified
        {DAV:}creationdate
        {DAV:}displayname
        {DAV:}supportedlock
        {http://www.day.com/jcr/webdav/1.0}workspaceName
        {DAV:}resourcetype
        {DAV:}lockdiscovery
        {DAV:}iscollection
         */
    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);
    DavPropertyNameSet result = doPropFindByProp(repoURI, props);
    assertPropertyNames(props, result);
}
Also used : DavPropertyNameSet(org.apache.jackrabbit.webdav.property.DavPropertyNameSet)

Example 8 with DavPropertyNameSet

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

the class RFC4918PropfindTest method testPropfindInclude.

public void testPropfindInclude() throws IOException, DavException, URISyntaxException {
    String testuri = this.root + "iftest";
    int status;
    try {
        HttpPut put = new HttpPut(testuri);
        put.setEntity(new StringEntity("1"));
        status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
        assertEquals("status: " + status, 201, status);
        DavPropertyNameSet names = new DavPropertyNameSet();
        names.add(DeltaVConstants.COMMENT);
        HttpPropfind propfind = new HttpPropfind(testuri, DavConstants.PROPFIND_ALL_PROP_INCLUDE, names, 0);
        HttpResponse resp = this.client.execute(propfind, this.context);
        status = resp.getStatusLine().getStatusCode();
        assertEquals(207, status);
        MultiStatus multistatus = propfind.getResponseBodyAsMultiStatus(resp);
        MultiStatusResponse[] responses = multistatus.getResponses();
        assertEquals(1, responses.length);
        MultiStatusResponse response = responses[0];
        DavPropertySet found = response.getProperties(200);
        DavPropertySet notfound = response.getProperties(404);
        assertTrue(found.contains(DeltaVConstants.COMMENT) || notfound.contains(DeltaVConstants.COMMENT));
    } finally {
        delete(testuri);
    }
}
Also used : StringEntity(org.apache.http.entity.StringEntity) DavPropertySet(org.apache.jackrabbit.webdav.property.DavPropertySet) HttpPropfind(org.apache.jackrabbit.webdav.client.methods.HttpPropfind) DavPropertyNameSet(org.apache.jackrabbit.webdav.property.DavPropertyNameSet) MultiStatusResponse(org.apache.jackrabbit.webdav.MultiStatusResponse) HttpResponse(org.apache.http.HttpResponse) MultiStatus(org.apache.jackrabbit.webdav.MultiStatus) HttpPut(org.apache.http.client.methods.HttpPut)

Example 9 with DavPropertyNameSet

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

the class RepositoryServiceImpl method internalGetPrivilegeDefinitions.

private PrivilegeDefinition[] internalGetPrivilegeDefinitions(SessionInfo sessionInfo, String uri) throws RepositoryException {
    DavPropertyNameSet nameSet = new DavPropertyNameSet();
    nameSet.add(SecurityConstants.SUPPORTED_PRIVILEGE_SET);
    HttpPropfind request = null;
    try {
        request = new HttpPropfind(uri, nameSet, DEPTH_0);
        HttpResponse response = executeRequest(sessionInfo, request);
        request.checkSuccess(response);
        MultiStatusResponse[] mresponses = request.getResponseBodyAsMultiStatus(response).getResponses();
        if (mresponses.length < 1) {
            throw new PathNotFoundException("Unable to retrieve privileges definitions.");
        }
        DavPropertyName displayName = SecurityConstants.SUPPORTED_PRIVILEGE_SET;
        DavProperty<?> p = mresponses[0].getProperties(DavServletResponse.SC_OK).get(displayName);
        if (p == null) {
            return new PrivilegeDefinition[0];
        } else {
            // build PrivilegeDefinition(s) from the supported-privileges dav property
            Map<Name, SupportedPrivilege> spMap = new HashMap<Name, SupportedPrivilege>();
            fillSupportedPrivilegeMap(new SupportedPrivilegeSetProperty(p).getValue(), spMap, getNameFactory());
            List<PrivilegeDefinition> pDefs = new ArrayList<PrivilegeDefinition>();
            for (Name privilegeName : spMap.keySet()) {
                SupportedPrivilege sp = spMap.get(privilegeName);
                Set<Name> aggrnames = null;
                SupportedPrivilege[] aggregates = sp.getSupportedPrivileges();
                if (aggregates != null && aggregates.length > 0) {
                    aggrnames = new HashSet<Name>();
                    for (SupportedPrivilege aggregate : aggregates) {
                        Name aggregateName = nameFactory.create(aggregate.getPrivilege().getNamespace().getURI(), aggregate.getPrivilege().getName());
                        aggrnames.add(aggregateName);
                    }
                }
                PrivilegeDefinition def = new PrivilegeDefinitionImpl(privilegeName, sp.isAbstract(), aggrnames);
                pDefs.add(def);
            }
            return pDefs.toArray(new PrivilegeDefinition[pDefs.size()]);
        }
    } catch (IOException e) {
        throw new RepositoryException(e);
    } catch (DavException e) {
        throw ExceptionConverter.generate(e);
    } finally {
        if (request != null) {
            request.releaseConnection();
        }
    }
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) DavException(org.apache.jackrabbit.webdav.DavException) MultiStatusResponse(org.apache.jackrabbit.webdav.MultiStatusResponse) ArrayList(java.util.ArrayList) HttpResponse(org.apache.http.HttpResponse) PrivilegeDefinition(org.apache.jackrabbit.spi.PrivilegeDefinition) RepositoryException(javax.jcr.RepositoryException) IOException(java.io.IOException) DavPropertyName(org.apache.jackrabbit.webdav.property.DavPropertyName) DavPropertyName(org.apache.jackrabbit.webdav.property.DavPropertyName) Name(org.apache.jackrabbit.spi.Name) HttpPropfind(org.apache.jackrabbit.webdav.client.methods.HttpPropfind) PrivilegeDefinitionImpl(org.apache.jackrabbit.spi.commons.privilege.PrivilegeDefinitionImpl) DavPropertyNameSet(org.apache.jackrabbit.webdav.property.DavPropertyNameSet) SupportedPrivilegeSetProperty(org.apache.jackrabbit.webdav.security.SupportedPrivilegeSetProperty) PathNotFoundException(javax.jcr.PathNotFoundException) SupportedPrivilege(org.apache.jackrabbit.webdav.security.SupportedPrivilege)

Example 10 with DavPropertyNameSet

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

the class RepositoryServiceImpl method internalSetNamespaces.

/**
     *
     * @param sessionInfo
     * @param namespaces
     * @throws NamespaceException
     * @throws UnsupportedRepositoryOperationException
     * @throws AccessDeniedException
     * @throws RepositoryException
     */
private void internalSetNamespaces(SessionInfo sessionInfo, Map<String, String> namespaces) throws RepositoryException {
    DavPropertySet setProperties = new DavPropertySet();
    setProperties.add(createNamespaceProperty(namespaces));
    HttpProppatch request = null;
    try {
        String uri = uriResolver.getWorkspaceUri(sessionInfo.getWorkspaceName());
        request = new HttpProppatch(uri, setProperties, new DavPropertyNameSet());
        initMethod(request, sessionInfo, true);
        HttpResponse response = executeRequest(sessionInfo, request);
        request.checkSuccess(response);
    } catch (IOException e) {
        throw new RepositoryException(e);
    } catch (DavException e) {
        throw ExceptionConverter.generate(e);
    } finally {
        if (request != null) {
            request.releaseConnection();
        }
    }
}
Also used : DavPropertySet(org.apache.jackrabbit.webdav.property.DavPropertySet) HttpProppatch(org.apache.jackrabbit.webdav.client.methods.HttpProppatch) DavException(org.apache.jackrabbit.webdav.DavException) DavPropertyNameSet(org.apache.jackrabbit.webdav.property.DavPropertyNameSet) HttpResponse(org.apache.http.HttpResponse) RepositoryException(javax.jcr.RepositoryException) IOException(java.io.IOException)

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