Package org.apache.wink.webdav.model

Examples of org.apache.wink.webdav.model.Prop


    public void testNonExistingProperty() throws Exception {

        // request with depth 0
        Propfind propfind = new Propfind();
        QName propertyName = new QName("blah");
        Prop prop = new Prop();
        prop.setProperty(propertyName);
        propfind.setProp(prop);
        Multistatus multistatus = propfind(propfind, WebDAVCollectionResource.PATH, 0);

        // 1 response
        Map<String, Response> responses = multistatus.getResponsesAsMapByHref();
        Assert.assertEquals(1, responses.size());
        Response response = responses.get(WebDAVCollectionResource.PATH);
        Assert.assertNotNull(response);
        List<Propstat> propstats = response.getPropstat();
        Assert.assertEquals(1, propstats.size());
        Propstat propstat = propstats.get(0);
        prop = propstat.getProp();
        Assert.assertNotNull(prop.getAnyByName(propertyName));
        Assert.assertEquals(HttpStatus.NOT_FOUND.getCode(), propstat.getStatusCode());
    }
View Full Code Here


    public void testNonExistingProperty() throws Exception {

        // request with depth 0
        Propfind propfind = new Propfind();
        QName propertyName = new QName("blah");
        Prop prop = new Prop();
        prop.setProperty(propertyName);
        propfind.setProp(prop);
        Multistatus multistatus = propfind(propfind, "/", 0);

        // 1 response - '/'
        Map<String, Response> responses = multistatus.getResponsesAsMapByHref();
        Assert.assertEquals(1, responses.size());
        Response response = responses.get("/");
        Assert.assertNotNull(response);
        Assert.assertEquals(1, response.getPropstat().size());
        Propstat propstat = response.getPropstat().get(0);
        Assert.assertEquals(HttpStatus.NOT_FOUND.getCode(), propstat.getStatusCode());
        prop = propstat.getProp();
        Assert.assertEquals(1, prop.getAny().size());
        Assert.assertNotNull(prop.getAnyByName(propertyName));
    }
View Full Code Here

    public void testNonExistingProperty() throws Exception {

        // request with depth 0
        Propfind propfind = new Propfind();
        QName propertyName = new QName("blah");
        Prop prop = new Prop();
        prop.setProperty(propertyName);
        propfind.setProp(prop);
        Multistatus multistatus = propfind(propfind, "/", 0);

        // 1 response - '/'
        Map<String, Response> responses = multistatus.getResponsesAsMapByHref();
        Assert.assertEquals(1, responses.size());
        Response response = responses.get("/");
        Assert.assertNotNull(response);
        Assert.assertEquals(1, response.getPropstat().size());
        Propstat propstat = response.getPropstat().get(0);
        Assert.assertEquals(HttpStatus.NOT_FOUND.getCode(), propstat.getStatusCode());
        prop = propstat.getProp();
        Assert.assertEquals(1, prop.getAny().size());
        Assert.assertNotNull(prop.getAnyByName(propertyName));
    }
View Full Code Here

        // the request is for all property names
        if (propfind.getPropname() != null) {
            Propstat propstat =
                response.getOrCreatePropstat(Response.Status.OK.getStatusCode(), null, null);
            Prop prop = propstat.getProp();
            // call the abstract method to allow the handler to fill in the
            // property names
            handler.setAllPropertyNames(this, prop, synd);
            // ensure that all property values are empty
            ensurePropertiesAreEmpty(prop);
        } else {
            Prop prop = null;
            // the request is for all properties
            if (propfind.getAllprop() != null) {
                prop = new Prop();
                handler.setAllPropertyNames(this, prop, synd);
            } else {
                // the request is for specific properties
                prop = propfind.getProp();
            }
View Full Code Here

        List<Propstat> propstats = response.getPropstat();
        Assert.assertEquals(propstats.size(), 2);

        Propstat propstat = propstats.get(0);
        Assert.assertEquals(propstat.getStatusCode(), 200);
        Prop prop = propstat.getProp();
        Element element = prop.getAnyByName(RESP1_PROPS[0]);
        Assert.assertNotNull(element);
        Assert.assertEquals(element.getLocalName(), RESP1_PROPS[0].getLocalPart());
        Assert.assertEquals(element.getNamespaceURI(), RESP1_PROPS[0].getNamespaceURI());
        element = prop.getAnyByName(RESP1_PROPS[1]);
        Assert.assertNotNull(element);
        Assert.assertEquals(element.getLocalName(), RESP1_PROPS[1].getLocalPart());
        Assert.assertEquals(element.getNamespaceURI(), RESP1_PROPS[1].getNamespaceURI());

        propstat = propstats.get(1);
        Assert.assertEquals(propstat.getStatusCode(), 403);
        Assert.assertEquals(propstat.getResponsedescription(), RESP1_PROPS_DESC);
        prop = propstat.getProp();
        element = prop.getAnyByName(RESP1_PROPS[2]);
        Assert.assertNotNull(element);
        Assert.assertEquals(element.getLocalName(), RESP1_PROPS[2].getLocalPart());
        Assert.assertEquals(element.getNamespaceURI(), RESP1_PROPS[2].getNamespaceURI());
        element = prop.getAnyByName(RESP1_PROPS[3]);
        Assert.assertNotNull(element);
        Assert.assertEquals(element.getLocalName(), RESP1_PROPS[3].getLocalPart());
        Assert.assertEquals(element.getNamespaceURI(), RESP1_PROPS[3].getNamespaceURI());

        // test write
        String write = write(multistatus);
        Diff diff = new Diff(input, write);
        Assert.assertTrue(diff.toString(), diff.similar());

        // test runtime creation
        multistatus = new Multistatus();
        multistatus.setResponsedescription(RESP1_DESC);
        response = new Response(RESP1_HREF);
        multistatus.getResponse().add(response);
        propstat = response.getOrCreatePropstat(200, null, null);
        prop = propstat.getProp();
        prop.setProperty(RESP1_PROPS[0], WebDAVModelHelper.createElement(NS1,
                                                                         "R:BoxType",
                                                                         "Box type A"));
        prop.setProperty(RESP1_PROPS[1], WebDAVModelHelper.createElement(NS1,
                                                                         "R:Name",
                                                                         "J.J. Johnson"));
        propstat = response.getOrCreatePropstat(403, RESP1_PROPS_DESC, null);
        prop = propstat.getProp();
        prop.setProperty(RESP1_PROPS[2]);
        prop.setProperty(RESP1_PROPS[3]);

        write = write(multistatus);
        diff = new Diff(input, write);
        Assert.assertTrue(diff.toString(), diff.similar());
    }
View Full Code Here

        Propstat propstat = propstats.get(0);
        Assert.assertEquals(propstat.getStatusCode(), 409);
        Assert.assertNull(propstat.getError());
        Assert.assertNull(propstat.getResponsedescription());
        // 1. property
        Prop prop = propstat.getProp();
        Assert.assertEquals(prop.getAny().size(), 1);
        Element element = prop.getAnyByName(RESP2_PROPS[0]);
        Assert.assertNotNull(element);
        Assert.assertEquals(element.getLocalName(), RESP2_PROPS[0].getLocalPart());
        Assert.assertEquals(element.getNamespaceURI(), RESP2_PROPS[0].getNamespaceURI());
        // 2. property
        propstat = propstats.get(1);
        Assert.assertEquals(propstat.getStatusCode(), 424);
        Assert.assertNull(propstat.getError());
        Assert.assertNull(propstat.getResponsedescription());
        prop = propstat.getProp();
        Assert.assertEquals(prop.getAny().size(), 1);
        element = prop.getAnyByName(RESP2_PROPS[1]);
        Assert.assertNotNull(element);
        Assert.assertEquals(element.getLocalName(), RESP2_PROPS[1].getLocalPart());
        Assert.assertEquals(element.getNamespaceURI(), RESP2_PROPS[1].getNamespaceURI());

        // test write
View Full Code Here

        String input = loadStreamToString(getClass().getResourceAsStream("proppatch1.xml"));
        Propertyupdate propupdate = read(input);
        // set properties
        List<Prop> props = propupdate.getPropsToSet();
        Assert.assertEquals(1, props.size());
        Prop prop = props.get(0);
        Set<QName> propertyNames = new HashSet<QName>();
        WebDAVModelHelper.extractPropertyNames(prop, propertyNames);
        Assert.assertArrayEquals(propertyNames.toArray(new QName[propertyNames.size()]),
                                 new QName[] {SET_PROPERTY});

        Element element = prop.getAny().get(0);
        Element child = (Element)element.getFirstChild();
        Assert.assertNotNull(child);
        Assert.assertEquals(SET_PROPERTY_CHILD.getNamespaceURI(), child.getNamespaceURI());
        Assert.assertEquals(SET_PROPERTY_CHILD.getLocalPart(), child.getLocalName());
        Assert.assertEquals(SET_PROPERTY_CHILD_VALUES[0], child.getTextContent());

        child = (Element)child.getNextSibling();
        Assert.assertNotNull(child);
        Assert.assertEquals(SET_PROPERTY_CHILD.getNamespaceURI(), child.getNamespaceURI());
        Assert.assertEquals(SET_PROPERTY_CHILD.getLocalPart(), child.getLocalName());
        Assert.assertEquals(SET_PROPERTY_CHILD_VALUES[1], child.getTextContent());

        // remove properties
        props = propupdate.getPropsToRemove();
        Assert.assertEquals(1, props.size());
        prop = props.get(0);
        propertyNames = new HashSet<QName>();
        WebDAVModelHelper.extractPropertyNames(prop, propertyNames);
        Assert.assertArrayEquals(propertyNames.toArray(new QName[propertyNames.size()]),
                                 new QName[] {REMOVE_PROPERTY});

        // test write
        Diff diff = new Diff(input, write(propupdate));
        Assert.assertTrue(diff.toString(), diff.similar());

        // test runtime creation
        propupdate = new Propertyupdate();
        // set properties
        org.apache.wink.webdav.model.Set set = new org.apache.wink.webdav.model.Set();
        prop = new Prop();
        set.setProp(prop);
        propupdate.getRemoveOrSet().add(set);
        element = prop.setProperty(SET_PROPERTY);
        Element child1 =
            WebDAVModelHelper.createElement(SET_PROPERTY_CHILD, SET_PROPERTY_CHILD_VALUES[0]);
        Element child2 =
            WebDAVModelHelper.createElement(SET_PROPERTY_CHILD, SET_PROPERTY_CHILD_VALUES[1]);
        element.appendChild(child1);
        element.appendChild(child2);
        // remove properties
        Remove remove = new Remove();
        prop = new Prop();
        prop.setProperty(REMOVE_PROPERTY);
        remove.setProp(prop);
        propupdate.getRemoveOrSet().add(remove);
        diff = new Diff(input, write(propupdate));
        Assert.assertTrue(diff.toString(), diff.similar());
    }
View Full Code Here

    public void test1() throws Exception {

        // test read
        String input = loadStreamToString(getClass().getResourceAsStream("propfind1.xml"));
        Propfind propfind = read(input);
        Prop prop = propfind.getProp();
        Assert.assertEquals(PROPERTIES.length, prop.getAny().size());
        for (QName qname : PROPERTIES) {
            Element element = prop.getAnyByName(qname);
            Assert.assertNotNull(element);
            Assert.assertEquals(qname.getNamespaceURI(), element.getNamespaceURI());
            Assert.assertEquals(qname.getLocalPart(), element.getLocalName());
        }
        Assert.assertFalse(propfind.isAllprop());
        Assert.assertFalse(propfind.isPropname());

        // test write
        Diff diff = new Diff(input, write(propfind));
        Assert.assertTrue(diff.toString(), diff.similar());

        // test runtime creation
        propfind = new Propfind();
        prop = new Prop();
        propfind.setProp(prop);
        prop.setProperty(PROPERTIES[0]);
        prop.setProperty(PROPERTIES[1]);
        prop.setProperty(PROPERTIES[2]);
        prop.setProperty(PROPERTIES[3]);
        diff = new Diff(input, write(propfind));
        Assert.assertTrue(diff.toString(), diff.similar());
    }
View Full Code Here

        activelock.setTimeout(LOCK_TIMEOUT);
        // a lock token is not necessary for MS compatibility

        Lockdiscovery lockdiscovery = new Lockdiscovery();
        lockdiscovery.getActivelock().add(activelock);
        Prop prop = new Prop();
        prop.setLockdiscovery(lockdiscovery);

        Response response =
            RuntimeDelegate.getInstance().createResponseBuilder().entity(prop).build();
        return response;
    }
View Full Code Here

        // the request is for all property names
        if (propfind.getPropname() != null) {
            Propstat propstat =
                response.getOrCreatePropstat(Response.Status.OK.getStatusCode(), null, null);
            Prop prop = propstat.getProp();
            // call the abstract method to allow the handler to fill in the
            // property names
            handler.setAllPropertyNames(this, prop, synd);
            // ensure that all property values are empty
            ensurePropertiesAreEmpty(prop);
        } else {
            Prop prop = null;
            // the request is for all properties
            if (propfind.getAllprop() != null) {
                prop = new Prop();
                handler.setAllPropertyNames(this, prop, synd);
            } else {
                // the request is for specific properties
                prop = propfind.getProp();
            }
View Full Code Here

TOP

Related Classes of org.apache.wink.webdav.model.Prop

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.