Search in sources :

Example 16 with DavProperty

use of org.apache.jackrabbit.webdav.property.DavProperty 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)

Aggregations

DavProperty (org.apache.jackrabbit.webdav.property.DavProperty)16 DefaultDavProperty (org.apache.jackrabbit.webdav.property.DefaultDavProperty)13 RepositoryException (javax.jcr.RepositoryException)11 Node (javax.jcr.Node)6 HrefProperty (org.apache.jackrabbit.webdav.property.HrefProperty)6 PropEntry (org.apache.jackrabbit.webdav.property.PropEntry)5 Property (javax.jcr.Property)4 MultiStatusResponse (org.apache.jackrabbit.webdav.MultiStatusResponse)4 DavException (org.apache.jackrabbit.webdav.DavException)3 DavPropertyName (org.apache.jackrabbit.webdav.property.DavPropertyName)3 Session (javax.jcr.Session)2 Version (javax.jcr.version.Version)2 HttpResponse (org.apache.http.HttpResponse)2 MultiStatus (org.apache.jackrabbit.webdav.MultiStatus)2 HttpPropfind (org.apache.jackrabbit.webdav.client.methods.HttpPropfind)2 LengthsProperty (org.apache.jackrabbit.webdav.jcr.property.LengthsProperty)2 ValuesProperty (org.apache.jackrabbit.webdav.jcr.property.ValuesProperty)2 JcrSupportedPrivilegesProperty (org.apache.jackrabbit.webdav.jcr.security.JcrSupportedPrivilegesProperty)2 JcrUserPrivilegesProperty (org.apache.jackrabbit.webdav.jcr.security.JcrUserPrivilegesProperty)2 DavPropertyNameSet (org.apache.jackrabbit.webdav.property.DavPropertyNameSet)2