Package com.boundlessgeo.geoserver.api.exceptions

Examples of com.boundlessgeo.geoserver.api.exceptions.BadRequestException


        CoordinateReferenceSystem crs = null;
        try {
            crs = Proj.get().crs(srs);
        }
        catch(Exception e1) {
            throw new BadRequestException("Bad srs: " + srs, e1);
        }

        if (crs == null) {
            throw new NotFoundException("No such projection: " + srs);
        }
View Full Code Here


                if (sortArr[1].equals("asc")) {
                    sortBy = Predicates.asc(sortArr[0]);
                } else if (sortArr[1].equals("desc")) {
                    sortBy = Predicates.desc(sortArr[0]);
                } else {
                    throw new BadRequestException("Sort order must be \"asc\" or \"desc\"");
                }
            } else {
                sortBy = Predicates.asc(sortArr[0]);
            }
        }
View Full Code Here

        WorkspaceInfo ws = findWorkspace(wsName, cat);

        String name = obj.str("name");
        if (name == null) {
            throw new BadRequestException("Layer object requires name");
        }
        try {
            @SuppressWarnings("unused")
            LayerInfo l = findLayer(wsName, name, cat);
            throw new BadRequestException("Layer named '" + wsName + ":" + name
                    + "' already exists");
        } catch (NotFoundException good) {
        }

        LayerInfo l = null;
        try {
            if (obj.has("layer")) {
                l = createLayerFromLayer(obj.object("layer"), ws, cat);
            } else if (obj.has("resource")) {
                l = createLayerFromResource(obj.object("resource"), ws, cat);
            } else {
                throw new BadRequestException("Layer create requires from (to create from existing layer) or resource " +
                    "(to create from store data)");
            }
        }
        catch(IOException e) {
            throw new RuntimeException("Failed to create layer: " + e.getMessage(), e);
        }

        // proj specified?
        JSONObj proj = obj.object("proj");
        if (proj != null) {
            String srs = null;
            try {
                srs = IO.srs(proj);
            } catch (IllegalArgumentException e) {
                throw new BadRequestException(e.getMessage(), e);
            }

            ResourceInfo r = l.getResource();
            r.setSRS(srs);
            try {
View Full Code Here

            WMSLayerInfo data = factory.createWMSLayer();
            builder.updateWMSLayer( data,  resource);
            l.setResource(data);
        }
        else {
            throw new BadRequestException("Unable to copy layer from " + origResource.getClass().getSimpleName());
        }

        l.setDefaultStyle(orig.getDefaultStyle());
        //builder.updateLayer( l, orig );
        return l;
View Full Code Here

                        new ReferencedEnvelope(IO.bounds(bbox.object("lonlat")), DefaultGeographicCRS.WGS84));
                }
            } else if ("proj".equals(prop)) {
                JSONObj proj = obj.object("proj");
                if (!proj.has("srs")) {
                    throw new BadRequestException("proj property must contain a 'srs' property");
                }
                String srs = proj.str("srs");
                try {
                    CRS.decode(srs);
                } catch (Exception e) {
                    throw new BadRequestException("Unknown spatial reference identifier: " + srs);
                }
                resource.setSRS(srs);
            }
        }
View Full Code Here

        WorkspaceInfo ws = findWorkspace(wsName, catalog);

        // get the uploaded files
        Iterator<FileItem> files = doFileUpload(request);
        if (!files.hasNext()) {
            throw new BadRequestException("Request must contain a single file");
        }

        // create a new temp directory for the uploaded file
        File uploadDir = dataDir().get(ws, "data", hasher.get().toLowerCase()).dir();
        if (!uploadDir.exists()) {
View Full Code Here

        ImportContext imp = findImport(id);

        Integer t = obj.integer("task");
        if (t == null) {
            throw new BadRequestException("Request must contain task identifier");
        }

        final ImportTask task = imp.task(t);
        if (task == null) {
            throw new NotFoundException("No such task: " + t + " for import: " + id);
        }

        ResourceInfo resource = task.getLayer().getResource();

        if (task.getState() == ImportTask.State.NO_CRS) {
            JSONObj proj = obj.object("proj");
            if (proj == null) {
                throw new BadRequestException("Request must contain a 'proj' property");
            }

            try {
                resource.setSRS(IO.srs(proj));
                resource.setNativeCRS(IO.crs(proj));
                importer.changed(task);
            }
            catch(Exception e) {
                throw new BadRequestException("Unable to parse proj: " + proj.toString());
            }
        }

        importer.run(imp, new ImportFilter() {
            @Override
View Full Code Here

        WorkspaceInfo ws = findWorkspace(wsName, cat);

        String name = obj.str("name");

        if (name == null) {
            throw new BadRequestException("Map object requires name");
        }

        try {
            findMap(wsName, name, cat);
            throw new BadRequestException("Map named '" + name + "' already exists");
        }
        catch(NotFoundException e) {
            // good!
        }

        String title = obj.str("title");
        String description = obj.str("abstract");
       
        Date created = new Date();

        CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;

        JSONObj proj = obj.object("proj");
        if (proj != null) {
            try {
                crs = IO.crs(proj);
            } catch (Exception e) {
                throw new BadRequestException("Error parsing proj: " + proj.toString());
            }
        }
        else {
            throw new BadRequestException("Map object requires projection");
        }

        ReferencedEnvelope bounds = null;
        boolean updateBounds = false;

        if (obj.has("bbox")) {
            Envelope envelope = IO.bounds(obj.object("bbox"));
            bounds = new ReferencedEnvelope( envelope, crs );
        }
        else {
            bounds = new ReferencedEnvelope(crs);
            updateBounds = true;
        }

        if (!obj.has("layers")) {
            throw new BadRequestException("Map object requires layers array");
        }

        LayerGroupInfo map = cat.getFactory().createLayerGroup();
        map.setName( name );
        map.setAbstract( description );
View Full Code Here

            }
            if (mapLayer == null) {
                throw new NotFoundException("No such layer: " + l.toString());
            }
            if(check.containsKey(layerName)){
                throw new BadRequestException("Duplicate layer: " + l.toString() );
            }
            reLayers.add(mapLayer.layer);
            reStyles.add(mapLayer.style);
        }
        m.getLayers().clear();
View Full Code Here

        List<StyleInfo> appendStyles = new ArrayList<StyleInfo>();
        for (JSONObj l : Lists.reverse(Lists.newArrayList(layers.objects()))) {
            String layerName = l.str("name");
            String layerWorkspace = l.str("worskpace");
            if( check.containsKey(layerName)){
                throw new BadRequestException("Duplicate layer: " + l.toString() );
            }
            LayerInfo layer = findLayer(layerWorkspace, layerName);
            if (layer == null) {
                throw new NotFoundException("No such layer: " + l.toString());
            }
View Full Code Here

TOP

Related Classes of com.boundlessgeo.geoserver.api.exceptions.BadRequestException

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.