Search in sources :

Example 16 with MultiStatus

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

the class BindTest method getResourceId.

// utility methods
// see http://greenbytes.de/tech/webdav/rfc5842.html#rfc.section.3.1
private URI getResourceId(String uri) throws IOException, DavException, URISyntaxException {
    DavPropertyNameSet names = new DavPropertyNameSet();
    names.add(BindConstants.RESOURCEID);
    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 resourceId = responses[0].getProperties(200).get(BindConstants.RESOURCEID);
    assertNotNull(resourceId);
    assertTrue(resourceId.getValue() instanceof Element);
    Element href = (Element) resourceId.getValue();
    assertEquals("href", href.getLocalName());
    String text = getUri(href);
    URI resid = new URI(text);
    return resid;
}
Also used : HttpPropfind(org.apache.jackrabbit.webdav.client.methods.HttpPropfind) ParentElement(org.apache.jackrabbit.webdav.bind.ParentElement) Element(org.w3c.dom.Element) 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) URI(java.net.URI)

Example 17 with MultiStatus

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

the class DavPropertyTest method doPropFindAll.

private DavPropertyNameSet doPropFindAll(String uri) throws Exception {
    HttpPropfind request = new HttpPropfind(uri, DavConstants.PROPFIND_ALL_PROP, 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 18 with MultiStatus

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

the class DavPropertyTest method doPropFindByProp.

private DavPropertyNameSet doPropFindByProp(String uri, DavPropertyNameSet props) throws Exception {
    HttpPropfind request = new HttpPropfind(uri, DavConstants.PROPFIND_BY_PROPERTY, props, 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 19 with MultiStatus

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

the class AbstractWebdavServlet method doPropPatch.

/**
     * The PROPPATCH method
     *
     * @param request
     * @param response
     * @param resource
     * @throws IOException
     */
protected void doPropPatch(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException {
    List<? extends PropEntry> changeList = request.getPropPatchChangeList();
    if (changeList.isEmpty()) {
        response.sendError(DavServletResponse.SC_BAD_REQUEST);
        return;
    }
    MultiStatus ms = new MultiStatus();
    MultiStatusResponse msr = resource.alterProperties(changeList);
    ms.addResponse(msr);
    response.sendMultiStatus(ms);
}
Also used : MultiStatusResponse(org.apache.jackrabbit.webdav.MultiStatusResponse) MultiStatus(org.apache.jackrabbit.webdav.MultiStatus)

Example 20 with MultiStatus

use of org.apache.jackrabbit.webdav.MultiStatus 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

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