Package org.vfny.geoserver.wfs.requests

Examples of org.vfny.geoserver.wfs.requests.LockRequest


     * @throws ServiceException WfsException For any problems forming the
     *         request.
     * @throws WfsException DOCUMENT ME!
     */
    public Request getRequest(HttpServletRequest request) throws ServiceException {
        LockRequest currentRequest = new LockRequest();
        currentRequest.setHttpServletRequest(request);
        // set global request parameters
        LOGGER.finest("setting global request parameters");

        if (keyExists("VERSION")) {
            currentRequest.setVersion(getValue("VERSION"));
        }

        if (keyExists("REQUEST")) {
            currentRequest.setRequest(getValue("REQUEST"));
        }

        if (keyExists("EXPIRY")) {
            currentRequest.setExpiry(Integer.parseInt(getValue("EXPIRY")));
        }

        if (keyExists("LOCKACTION")) {
            String lockAction = getValue("LOCKACTION");

            if (lockAction == null) {
                currentRequest.setLockAll(true);
            } else if (lockAction.toUpperCase().equals("ALL")) {
                currentRequest.setLockAll(true);
            } else if (lockAction.toUpperCase().equals("SOME")) {
                currentRequest.setLockAll(false);
            } else {
                throw new WfsException("Illegal lock action: " + lockAction);
            }
        }

        // declare tokenizers for repeating elements
        LOGGER.finer("setting query request parameters");

        List typeList = readFlat(getValue("TYPENAME"), INNER_DELIMETER);
        LOGGER.finer("type list size: " + typeList.size());

        List filterList = readFilters(getValue("FEATUREID"),
                getValue("FILTER"), getValue("BBOX"));

        if (typeList.size() == 0) {
            typeList = getTypesFromFids(getValue("FEATUREID"));

            if (typeList.size() == 0) {
                throw new WfsException("The typename element is mandatory if "
                    + "no FEATUREID is present");
            }
        }

        int featureSize = typeList.size();
        int filterSize = filterList.size();

        // check for errors in the request
        if (((filterSize != featureSize) && (filterSize > 0))
                || ((filterSize > 0) && (featureSize == 0))) {
            throw new WfsException("Filter size does not match"
                + " feature types.  Filter size: " + filterSize
                + " Feature size: " + featureSize);
        } else {
            currentRequest.setLocks(typeList, filterList);

            return currentRequest;
        }
    }
View Full Code Here


    protected KvpRequestReader getKvpReader(Map kvps) {
        return new LockKvpReader(kvps);
    }

    public void testXml1() throws Exception {
        LockRequest request = new LockRequest();
        request.setLockAll(false);
        addLock1(request);
        assertTrue(runXmlTest(request, "lock1", true));
    }
View Full Code Here

        addLock1(request);
        assertTrue(runXmlTest(request, "lock1", true));
    }

    public void testXml2() throws Exception {
        LockRequest request = new LockRequest();
        request.addLock("roads", null);
        assertTrue(runXmlTest(request, "lock2", true));
    }
View Full Code Here

        request.addLock("roads", null);
        assertTrue(runXmlTest(request, "lock2", true));
    }

    public void testXml3() throws Exception {
        LockRequest request = new LockRequest();
        addLock3(request);
        assertTrue(runXmlTest(request, "lock3", true));
    }
View Full Code Here

        addLock3(request);
        assertTrue(runXmlTest(request, "lock3", true));
    }

    public void testXml4() throws Exception {
        LockRequest request = new LockRequest();
        addLock3(request);
        addLock1(request);
        request.setExpiry(3);
        assertTrue(runXmlTest(request, "lock4", true));
    }
View Full Code Here

    public void testKVP1() throws Exception {
        String testRequest = "VERSION=1.0.0&" + "REQUEST=lockFEATURE&"
            + "SERVICE=WFS&" + "TYPENAME=rail";

        // make base comparison objects
        LockRequest baseRequest = new LockRequest();
        baseRequest.addLock("rail", null, null);

        // run test
        assertTrue(runKvpTest(baseRequest, testRequest, true));
    }
View Full Code Here

    public void testKVP2() throws Exception {
        String testRequest = "VERSION=1.0.0&" + "REQUEST=lockFEATURE&"
            + "SERVICE=WFS&" + "TYPENAME=rail&" + "featureID=123";

        // make base comparison objects
        LockRequest baseRequest = new LockRequest();

        // baseRequest.addFeatureType("rail");
        FidFilter filter = factory.createFidFilter("123");

        //baseRequest.addFilter(filter);
        baseRequest.addLock("rail", filter, null);

        // run test
        assertTrue(runKvpTest(baseRequest, testRequest, true));
    }
View Full Code Here

    public void testKVP3() throws Exception {
        String testRequest = "VERSION=1.0.0&" + "REQUEST=lockFEATURE&"
            + "SERVICE=WFS&" + "TYPENAME=rail,roads";

        // make base comparison objects
        LockRequest baseRequest = new LockRequest();
        baseRequest.addLock("rail", null);
        baseRequest.addLock("roads", null);

        // run test
        assertTrue(runKvpTest(baseRequest, testRequest, true));
    }
View Full Code Here

    public void testKVP4() throws Exception {
        String testRequest = "VERSION=1.0.0&" + "SERVICE=WFS&"
            + "REQUEST=LockFEATURE&" + "LOCKACTION=all&"
            + "TYPENAME=rail,roads&"
            + "FILTER=(<Filter xmlns:gml='http://www.opengis.net/gml'><Within><PropertyName>location</PropertyName><gml:Box><gml:coordinates>10,10 20,20</gml:coordinates></gml:Box></Within></Filter>)(<Filter xmlns:gml='http://www.opengis.net/gml'><Within><PropertyName>location</PropertyName><gml:Box><gml:coordinates>10,10 20,20</gml:coordinates></gml:Box></Within></Filter>)";
        LockRequest baseRequest = new LockRequest();
        baseRequest.setVersion("1.0.0");
        baseRequest.setLockAll(true);

        // make base comparison objects
        GeometryFilter filter = factory.createGeometryFilter(AbstractFilter.GEOMETRY_WITHIN);
        //DJB changed this so it conforms to new FeatureType method
        AttributeExpression leftExpression = factory.createAttributeExpression((FeatureType)null,"location");
        //leftExpression.setAttributePath("location");

        // Creates coordinates for the linear ring
        Coordinate[] coords = new Coordinate[5];
        coords[0] = new Coordinate(10, 10);
        coords[1] = new Coordinate(10, 20);
        coords[2] = new Coordinate(20, 20);
        coords[3] = new Coordinate(20, 10);
        coords[4] = new Coordinate(10, 10);

        LinearRing outerShell = new LinearRing(coords, new PrecisionModel(), 0);
        Polygon polygon = new Polygon(outerShell, new PrecisionModel(), 0);
        LiteralExpression rightExpression = factory.createLiteralExpression(polygon);
        filter.addLeftGeometry(leftExpression);
        filter.addRightGeometry(rightExpression);
        baseRequest.addLock("rail", filter);
        baseRequest.addLock("roads", filter);

        //        baseRequest.addFilter(filter);
        //baseRequest.addFilter(filter);
        // run test
        assertTrue(runKvpTest(baseRequest, testRequest, true));
View Full Code Here

TOP

Related Classes of org.vfny.geoserver.wfs.requests.LockRequest

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.