Package com.boundlessgeo.geoserver.json

Examples of com.boundlessgeo.geoserver.json.JSONObj


        }

        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


            geoServer.getCatalog().save(l);
        }
    }

    JSONObj task(ImportTask task) {
        return new JSONObj().put("task", task.getId())
            .put("file", filename(task));
    }
View Full Code Here

    JSONObj complete(ImportTask task) {
        touch(task);

        LayerInfo layer = task.getLayer();
        JSONObj obj = task(task);
        IO.layer(obj.putObject("layer"), layer, null);
        return obj;
    }
View Full Code Here

    JSONObj pending(ImportTask task) {
        return task(task).put("problem", task.getState().toString());
    }

    JSONObj failed(ImportTask task) {
        JSONObj err = task(task);
        IO.error(err, task.getError() );
        return err;
    }
View Full Code Here

        IO.error(err, task.getError() );
        return err;
    }

    JSONObj ignored(ImportTask task) {
        return new JSONObj().put("task", task.getId()).put("file", filename(task));
    }
View Full Code Here

       
        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 );
        map.setTitle( title );
        map.setMode( Mode.SINGLE );
        map.setWorkspace(ws);

        for (Object o : obj.array("layers")) {
            JSONObj l = (JSONObj) o;

            LayerInfo layer = findLayer(wsName, l.str("name"), cat);
            map.getLayers().add(layer);
            map.getStyles().add(null);

            if (updateBounds) {
                try {
                    updateBounds(bounds, layer);
                } catch (Exception e) {
                    throw new RuntimeException("Error calculating map bounds ", e);
                }
            }

        }

        map.setBounds( bounds );

        Metadata.created(map, created);
        Metadata.modified(map, created);
        Metadata.modified(ws, created);

        cat.add( map );
        cat.save(ws);

        recent.add(LayerGroupInfo.class, map);
        return mapDetails(new JSONObj(), map, wsName, req);
    }
View Full Code Here

    @RequestMapping(value="/{wsName}/{name}", method = RequestMethod.GET)
    public @ResponseBody JSONObj get(@PathVariable String wsName,
                                     @PathVariable String name, HttpServletRequest req) {
        Catalog cat = catalog();
        LayerGroupInfo map = findMap(wsName, name, cat);
        return mapDetails(new JSONObj(), map, wsName, req);
    }
View Full Code Here

            map.setBounds(bounds);
        }
        if(obj.has("layers")){
            List<LayerInfo> layers = new ArrayList<LayerInfo>();
            for(Iterator<Object> i = obj.array("layers").iterator();i.hasNext();){
                JSONObj l = (JSONObj) i.next();
                String n = l.str("workspace")+":"+l.str("name");
                LayerInfo layer = cat.getLayerByName(n);
                layers.add(layer);
            }
            map.layers().clear();
            map.layers().addAll(layers);
        }
        // update configuration history
        String user = SecurityContextHolder.getContext().getAuthentication().getName();
        map.getMetadata().put("user", user );

        Date modified = new Date();
        Metadata.modified(map, modified);
        Metadata.modified(ws, modified);

        if(obj.has("change")){
            map.getMetadata().put("change", obj.str("change") );
        }
        else {
            map.getMetadata().put("change", "modified "+obj.keys() );
        }
        cat.save(map);
        cat.save(ws);

        recent.add(LayerGroupInfo.class, map);
        return mapDetails(new JSONObj(), map, wsName, req);
    }
View Full Code Here

        CloseableIterator<LayerGroupInfo> it = cat.list(LayerGroupInfo.class, equal("workspace.name", wsName));
        try {
            while (it.hasNext()) {
                LayerGroupInfo map = it.next();
                if( checkMap( map ) ){
                    JSONObj obj = arr.addObject();
                    map(obj, map, wsName);
                }
            }
        }
        finally {
View Full Code Here

                                             @PathVariable String mpName,
                                             @PathVariable String name, HttpServletRequest req) {
        LayerGroupInfo map = findMap(wsName, mpName, catalog());
        PublishedInfo layer = findMapLayer(map, name);
       
        JSONObj obj = layer(new JSONObj(), layer, req);
        obj.putObject("map")
            .put("name",  mpName )
            .put("url",IO.url(req,"/maps/%s/%s",wsName,mpName));
        return obj;
    }
View Full Code Here

TOP

Related Classes of com.boundlessgeo.geoserver.json.JSONObj

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.