Search in sources :

Example 16 with HttpPropfind

use of org.apache.jackrabbit.webdav.client.methods.HttpPropfind 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 17 with HttpPropfind

use of org.apache.jackrabbit.webdav.client.methods.HttpPropfind 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 18 with HttpPropfind

use of org.apache.jackrabbit.webdav.client.methods.HttpPropfind 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 19 with HttpPropfind

use of org.apache.jackrabbit.webdav.client.methods.HttpPropfind 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)

Aggregations

HttpResponse (org.apache.http.HttpResponse)19 HttpPropfind (org.apache.jackrabbit.webdav.client.methods.HttpPropfind)19 MultiStatusResponse (org.apache.jackrabbit.webdav.MultiStatusResponse)16 DavPropertyNameSet (org.apache.jackrabbit.webdav.property.DavPropertyNameSet)15 RepositoryException (javax.jcr.RepositoryException)13 DavException (org.apache.jackrabbit.webdav.DavException)12 IOException (java.io.IOException)11 DavPropertySet (org.apache.jackrabbit.webdav.property.DavPropertySet)11 ItemNotFoundException (javax.jcr.ItemNotFoundException)9 MultiStatus (org.apache.jackrabbit.webdav.MultiStatus)6 HttpClient (org.apache.http.client.HttpClient)3 NodeId (org.apache.jackrabbit.spi.NodeId)3 HrefProperty (org.apache.jackrabbit.webdav.property.HrefProperty)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 PathNotFoundException (javax.jcr.PathNotFoundException)2 Name (org.apache.jackrabbit.spi.Name)2 PropertyId (org.apache.jackrabbit.spi.PropertyId)2 NamePathResolver (org.apache.jackrabbit.spi.commons.conversion.NamePathResolver)2 DavProperty (org.apache.jackrabbit.webdav.property.DavProperty)2