Search in sources :

Example 26 with MultiStatusResponse

use of org.apache.jackrabbit.webdav.MultiStatusResponse in project jackrabbit by apache.

the class AclPrincipalReport method init.

/**
     * @see Report#init(DavResource, ReportInfo)
     */
@Override
public void init(DavResource resource, ReportInfo info) throws DavException {
    super.init(resource, info);
    // build the DAV:responses objects.
    DavProperty<?> acl = resource.getProperty(SecurityConstants.ACL);
    if (!(acl instanceof AclProperty)) {
        throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, "DAV:acl property expected.");
    }
    DavResourceLocator loc = resource.getLocator();
    Map<String, MultiStatusResponse> respMap = new HashMap<String, MultiStatusResponse>();
    List<AclProperty.Ace> list = (List<AclProperty.Ace>) ((AclProperty) acl).getValue();
    for (AclProperty.Ace ace : list) {
        String href = ace.getPrincipal().getHref();
        if (href == null || respMap.containsKey(href)) {
            // ignore non-href principals and principals that have been listed before
            continue;
        }
        // href-principal that has not been found before
        DavResourceLocator princLocator = loc.getFactory().createResourceLocator(loc.getPrefix(), href);
        DavResource principalResource = resource.getFactory().createResource(princLocator, resource.getSession());
        respMap.put(href, new MultiStatusResponse(principalResource, info.getPropertyNameSet()));
    }
    this.responses = respMap.values().toArray(new MultiStatusResponse[respMap.size()]);
}
Also used : AclProperty(org.apache.jackrabbit.webdav.security.AclProperty) DavResource(org.apache.jackrabbit.webdav.DavResource) DavException(org.apache.jackrabbit.webdav.DavException) HashMap(java.util.HashMap) MultiStatusResponse(org.apache.jackrabbit.webdav.MultiStatusResponse) List(java.util.List) DavResourceLocator(org.apache.jackrabbit.webdav.DavResourceLocator)

Example 27 with MultiStatusResponse

use of org.apache.jackrabbit.webdav.MultiStatusResponse in project jackrabbit by apache.

the class ExpandPropertyReport method addResponses.

/**
     * Fills the specified <code>MultiStatus</code> object by generating a
     * <code>MultiStatusResponse</code> for the given resource (and
     * its member according to the depth value).
     *
     * @param res
     * @param depth
     * @param ms
     * @see #getResponse(DavResource, Iterator)
     */
private void addResponses(DavResource res, int depth, MultiStatus ms) {
    MultiStatusResponse response = getResponse(res, propertyElements);
    ms.addResponse(response);
    if (depth > 0 && res.isCollection()) {
        DavResourceIterator it = res.getMembers();
        while (it.hasNext()) {
            addResponses(it.nextResource(), depth - 1, ms);
        }
    }
}
Also used : DavResourceIterator(org.apache.jackrabbit.webdav.DavResourceIterator) MultiStatusResponse(org.apache.jackrabbit.webdav.MultiStatusResponse)

Aggregations

MultiStatusResponse (org.apache.jackrabbit.webdav.MultiStatusResponse)27 RepositoryException (javax.jcr.RepositoryException)18 HttpResponse (org.apache.http.HttpResponse)18 DavException (org.apache.jackrabbit.webdav.DavException)17 HttpPropfind (org.apache.jackrabbit.webdav.client.methods.HttpPropfind)16 DavPropertyNameSet (org.apache.jackrabbit.webdav.property.DavPropertyNameSet)15 IOException (java.io.IOException)13 DavPropertySet (org.apache.jackrabbit.webdav.property.DavPropertySet)11 ItemNotFoundException (javax.jcr.ItemNotFoundException)10 ArrayList (java.util.ArrayList)5 MultiStatus (org.apache.jackrabbit.webdav.MultiStatus)5 NodeId (org.apache.jackrabbit.spi.NodeId)4 DavProperty (org.apache.jackrabbit.webdav.property.DavProperty)4 DavPropertyName (org.apache.jackrabbit.webdav.property.DavPropertyName)4 HrefProperty (org.apache.jackrabbit.webdav.property.HrefProperty)4 Element (org.w3c.dom.Element)4 HashSet (java.util.HashSet)3 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)3 CurrentUserPrivilegeSetProperty (org.apache.jackrabbit.webdav.security.CurrentUserPrivilegeSetProperty)3 Privilege (org.apache.jackrabbit.webdav.security.Privilege)3