Search in sources :

Example 11 with MultiStatus

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

the class LocateByUuidReport method init.

/**
     * @see Report#init(DavResource, ReportInfo)
     */
@Override
public void init(DavResource resource, ReportInfo info) throws DavException {
    // delegate basic validation to super class
    super.init(resource, info);
    // make also sure, the info contains a DAV:href child element
    if (!info.containsContentElement(DavConstants.XML_HREF, DavConstants.NAMESPACE)) {
        throw new DavException(DavServletResponse.SC_BAD_REQUEST, "dcr:locate-by-uuid element must at least contain a single DAV:href child.");
    }
    // immediately build the final multistatus element
    try {
        Element hrefElem = info.getContentElement(DavConstants.XML_HREF, DavConstants.NAMESPACE);
        String uuid = DomUtil.getTextTrim(hrefElem);
        DavResourceLocator resourceLoc = resource.getLocator();
        Node n = getRepositorySession().getNodeByUUID(uuid);
        DavResourceLocator loc = resourceLoc.getFactory().createResourceLocator(resourceLoc.getPrefix(), resourceLoc.getWorkspacePath(), n.getPath(), false);
        DavResource locatedResource = resource.getFactory().createResource(loc, resource.getSession());
        ms = new MultiStatus();
        ms.addResourceProperties(locatedResource, info.getPropertyNameSet(), info.getDepth());
    } catch (RepositoryException e) {
        throw new JcrDavException(e);
    }
}
Also used : JcrDavException(org.apache.jackrabbit.webdav.jcr.JcrDavException) DavResource(org.apache.jackrabbit.webdav.DavResource) DavException(org.apache.jackrabbit.webdav.DavException) JcrDavException(org.apache.jackrabbit.webdav.jcr.JcrDavException) Element(org.w3c.dom.Element) Node(javax.jcr.Node) MultiStatus(org.apache.jackrabbit.webdav.MultiStatus) RepositoryException(javax.jcr.RepositoryException) DavResourceLocator(org.apache.jackrabbit.webdav.DavResourceLocator)

Example 12 with MultiStatus

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

the class DavPropertyTest method doPropFindNames.

private DavPropertyNameSet doPropFindNames(String uri) throws Exception {
    HttpPropfind request = new HttpPropfind(uri, DavConstants.PROPFIND_PROPERTY_NAMES, DavConstants.DEPTH_0);
    HttpClient cl = rs.getClient(si);
    HttpResponse response = cl.execute(request, rs.getContext(si));
    request.checkSuccess(response);
    MultiStatus ms = request.getResponseBodyAsMultiStatus(response);
    assertEquals(1, ms.getResponses().length);
    return ms.getResponses()[0].getPropertyNames(HttpStatus.SC_OK);
}
Also used : HttpPropfind(org.apache.jackrabbit.webdav.client.methods.HttpPropfind) HttpClient(org.apache.http.client.HttpClient) HttpResponse(org.apache.http.HttpResponse) MultiStatus(org.apache.jackrabbit.webdav.MultiStatus)

Example 13 with MultiStatus

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

the class BindTest method getParentSet.

private DavProperty getParentSet(String uri) throws IOException, DavException, URISyntaxException {
    DavPropertyNameSet names = new DavPropertyNameSet();
    names.add(BindConstants.PARENTSET);
    HttpPropfind propfind = new HttpPropfind(uri, names, 0);
    HttpResponse response = this.client.execute(propfind, this.context);
    int status = response.getStatusLine().getStatusCode();
    assertEquals(207, status);
    MultiStatus multistatus = propfind.getResponseBodyAsMultiStatus(response);
    MultiStatusResponse[] responses = multistatus.getResponses();
    assertEquals(1, responses.length);
    DavProperty parentset = responses[0].getProperties(200).get(BindConstants.PARENTSET);
    assertNotNull(parentset);
    return parentset;
}
Also used : HttpPropfind(org.apache.jackrabbit.webdav.client.methods.HttpPropfind) DavPropertyNameSet(org.apache.jackrabbit.webdav.property.DavPropertyNameSet) MultiStatusResponse(org.apache.jackrabbit.webdav.MultiStatusResponse) DavProperty(org.apache.jackrabbit.webdav.property.DavProperty) HttpResponse(org.apache.http.HttpResponse) MultiStatus(org.apache.jackrabbit.webdav.MultiStatus)

Example 14 with MultiStatus

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

the class LocateByHistoryReport method getMultiStatus.

/**
     * Retrieve the <code>MultiStatus</code> that is returned in response to a locate-by-history
     * report request.
     *
     * @return
     * @throws NullPointerException if info or resource is <code>null</code>.
     */
private MultiStatus getMultiStatus() {
    MultiStatus ms = new MultiStatus();
    buildResponse(resource, info.getPropertyNameSet(), info.getDepth(), ms);
    return ms;
}
Also used : MultiStatus(org.apache.jackrabbit.webdav.MultiStatus)

Example 15 with MultiStatus

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

the class VersionTreeReport method getMultiStatus.

/**
     * Retrieve the <code>MultiStatus</code> that is returned in response to a locate-by-history
     * report request.
     *
     * @return
     * @throws NullPointerException if info or resource is <code>null</code>.
     */
private MultiStatus getMultiStatus() {
    if (info == null || resource == null) {
        throw new NullPointerException("Error while running DAV:version-tree report");
    }
    MultiStatus ms = new MultiStatus();
    buildResponse(resource, info.getPropertyNameSet(), info.getDepth(), ms);
    return ms;
}
Also used : MultiStatus(org.apache.jackrabbit.webdav.MultiStatus)

Aggregations

MultiStatus (org.apache.jackrabbit.webdav.MultiStatus)20 HttpResponse (org.apache.http.HttpResponse)8 RepositoryException (javax.jcr.RepositoryException)7 DavException (org.apache.jackrabbit.webdav.DavException)6 HttpPropfind (org.apache.jackrabbit.webdav.client.methods.HttpPropfind)6 MultiStatusResponse (org.apache.jackrabbit.webdav.MultiStatusResponse)5 DavPropertyNameSet (org.apache.jackrabbit.webdav.property.DavPropertyNameSet)4 Element (org.w3c.dom.Element)4 Node (javax.jcr.Node)3 HttpClient (org.apache.http.client.HttpClient)3 DavResourceLocator (org.apache.jackrabbit.webdav.DavResourceLocator)3 IOException (java.io.IOException)2 EventListener (javax.jcr.observation.EventListener)2 Version (javax.jcr.version.Version)2 DavResource (org.apache.jackrabbit.webdav.DavResource)2 JcrDavException (org.apache.jackrabbit.webdav.jcr.JcrDavException)2 DavProperty (org.apache.jackrabbit.webdav.property.DavProperty)2 VersionControlledResource (org.apache.jackrabbit.webdav.version.VersionControlledResource)2 URI (java.net.URI)1 Item (javax.jcr.Item)1