Search in sources :

Example 1 with UnbindInfo

use of org.apache.jackrabbit.webdav.bind.UnbindInfo in project jackrabbit by apache.

the class BindTest method testUnbind.

//will fail until <https://issues.apache.org/jira/browse/JCR-1773> is fixed
public void testUnbind() throws Exception {
    String testcol = this.root + "testUnbind/";
    String subcol1 = testcol + "bindtest1/";
    String testres1 = subcol1 + "res1";
    String subcol2 = testcol + "bindtest2/";
    String testres2 = subcol2 + "res2";
    int status;
    try {
        HttpMkcol mkcol = new HttpMkcol(testcol);
        status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
        assertEquals(201, status);
        mkcol = new HttpMkcol(subcol1);
        status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
        assertEquals(201, status);
        mkcol = new HttpMkcol(subcol2);
        status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
        assertEquals(201, status);
        //create new resource R with path testSimpleBind/bindtest1/res1
        HttpPut put = new HttpPut(testres1);
        put.setEntity(new StringEntity("foo", ContentType.create("text/plain", "UTF-8")));
        status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
        assertEquals(201, status);
        //create new binding of R with path testSimpleBind/bindtest2/res2
        HttpBind bind = new HttpBind(subcol2, new BindInfo(testres1, "res2"));
        status = this.client.execute(bind, this.context).getStatusLine().getStatusCode();
        assertEquals(201, status);
        //check if both bindings report the same DAV:resource-id
        assertEquals(this.getResourceId(testres1), this.getResourceId(testres2));
        //remove new path
        HttpUnbind unbind = new HttpUnbind(subcol2, new UnbindInfo("res2"));
        status = this.client.execute(unbind, this.context).getStatusLine().getStatusCode();
        assertTrue("status: " + status, status == 200 || status == 204);
        //verify that the new binding is gone
        HttpHead head = new HttpHead(testres2);
        status = this.client.execute(head, this.context).getStatusLine().getStatusCode();
        assertEquals(404, status);
        //verify that the initial binding is still there
        head = new HttpHead(testres1);
        status = this.client.execute(head, this.context).getStatusLine().getStatusCode();
        assertEquals(200, status);
    } finally {
        delete(testcol);
    }
}
Also used : UnbindInfo(org.apache.jackrabbit.webdav.bind.UnbindInfo) StringEntity(org.apache.http.entity.StringEntity) HttpMkcol(org.apache.jackrabbit.webdav.client.methods.HttpMkcol) HttpBind(org.apache.jackrabbit.webdav.client.methods.HttpBind) HttpUnbind(org.apache.jackrabbit.webdav.client.methods.HttpUnbind) HttpPut(org.apache.http.client.methods.HttpPut) HttpHead(org.apache.http.client.methods.HttpHead) BindInfo(org.apache.jackrabbit.webdav.bind.BindInfo)

Example 2 with UnbindInfo

use of org.apache.jackrabbit.webdav.bind.UnbindInfo in project jackrabbit by apache.

the class WebdavRequestImpl method getUnbindInfo.

/**
     * @see org.apache.jackrabbit.webdav.bind.BindServletRequest#getUnbindInfo()
     */
public UnbindInfo getUnbindInfo() throws DavException {
    UnbindInfo info = null;
    Document requestDocument = getRequestDocument();
    if (requestDocument != null) {
        info = UnbindInfo.createFromXml(requestDocument.getDocumentElement());
    }
    return info;
}
Also used : UnbindInfo(org.apache.jackrabbit.webdav.bind.UnbindInfo) Document(org.w3c.dom.Document)

Example 3 with UnbindInfo

use of org.apache.jackrabbit.webdav.bind.UnbindInfo in project jackrabbit by apache.

the class AbstractWebdavServlet method doUnbind.

/**
     * The UNBIND method
     *
     * @param request
     * @param response
     * @param resource the collection resource from which a member will be removed
     * @throws IOException
     * @throws DavException
     */
protected void doUnbind(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException {
    UnbindInfo unbindInfo = request.getUnbindInfo();
    DavResource srcResource = getResourceFactory().createResource(request.getMemberLocator(unbindInfo.getSegment()), request, response);
    resource.removeMember(srcResource);
}
Also used : UnbindInfo(org.apache.jackrabbit.webdav.bind.UnbindInfo) DavResource(org.apache.jackrabbit.webdav.DavResource)

Aggregations

UnbindInfo (org.apache.jackrabbit.webdav.bind.UnbindInfo)3 HttpHead (org.apache.http.client.methods.HttpHead)1 HttpPut (org.apache.http.client.methods.HttpPut)1 StringEntity (org.apache.http.entity.StringEntity)1 DavResource (org.apache.jackrabbit.webdav.DavResource)1 BindInfo (org.apache.jackrabbit.webdav.bind.BindInfo)1 HttpBind (org.apache.jackrabbit.webdav.client.methods.HttpBind)1 HttpMkcol (org.apache.jackrabbit.webdav.client.methods.HttpMkcol)1 HttpUnbind (org.apache.jackrabbit.webdav.client.methods.HttpUnbind)1 Document (org.w3c.dom.Document)1