Package org.geoserver.catalog

Examples of org.geoserver.catalog.LayerGroupInfo


        }

        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);
                }
            }
View Full Code Here


    }
    @RequestMapping(value="/{wsName}/{name}/layers", method = RequestMethod.GET)
    public @ResponseBody
    JSONArr mapLayerListGet(@PathVariable String wsName,
                            @PathVariable String name, HttpServletRequest req) {
        LayerGroupInfo m = findMap(wsName, name, catalog());
        return mapLayerList(m,req);
    }
View Full Code Here

    @RequestMapping(value="/{wsName}/{name}/layers", method = RequestMethod.PUT)
    public @ResponseBody JSONArr mapLayerListPut(@PathVariable String wsName,
                                                 @PathVariable String name,
                                                 @RequestBody JSONArr layers, HttpServletRequest req) {
        Catalog cat = geoServer.getCatalog();
        LayerGroupInfo m = findMap(wsName, name, cat);

        // original
        List<MapLayer> mapLayers = MapLayer.list(m);
        Map<String,MapLayer> lookup = Maps.uniqueIndex(mapLayers, new Function<MapLayer, String>() {
            @Nullable
            public String apply(@Nullable MapLayer input) {
                return input.layer.getName();
            }
        });
        // modified
        List<PublishedInfo> reLayers = new ArrayList<PublishedInfo>();
        Map<String,PublishedInfo> check = Maps.uniqueIndex(reLayers, new Function<PublishedInfo, String>() {
            @Nullable
            public String apply(@Nullable PublishedInfo input) {
                return input.getName();
            }
        });
        List<StyleInfo> reStyles = new ArrayList<StyleInfo>();
        for (JSONObj l : Lists.reverse(Lists.newArrayList(layers.objects()))) {
            String layerName = l.str("name");
            String layerWorkspace = l.str("workspace");
            MapLayer mapLayer = lookup.get(layerName);
            if (mapLayer == null) {
                LayerInfo layer = findLayer( layerWorkspace, layerName);
                if (layer != null) {
                    mapLayer = new MapLayer(layer, layer.getDefaultStyle());
                }
            }
            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();
        m.getLayers().addAll(reLayers);
        m.getStyles().clear();
        m.getStyles().addAll(reStyles);

        WorkspaceInfo ws = m.getWorkspace();

        Date modified = new Date();
        Metadata.modified(m, modified);
        Metadata.modified(ws, modified);
View Full Code Here

    @RequestMapping(value="/{wsName}/{name}/layers", method = RequestMethod.POST)
    public @ResponseBody JSONArr mapLayerListPost(@PathVariable String wsName,
                                                  @PathVariable String name,
                                                  @RequestBody JSONArr layers, HttpServletRequest req) {
        Catalog cat = geoServer.getCatalog();
        LayerGroupInfo m = findMap(wsName, name, cat);
        WorkspaceInfo ws = m.getWorkspace();

        List<PublishedInfo> appendLayers = new ArrayList<PublishedInfo>();
        Map<String,PublishedInfo> check = Maps.uniqueIndex(appendLayers, new Function<PublishedInfo, String>() {
            @Nullable
            public String apply(@Nullable PublishedInfo input) {
                return input.getName();
            }
        });
        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());
            }
            appendLayers.add(layer);
            appendStyles.add(layer.getDefaultStyle());
        }
        m.getLayers().addAll(appendLayers);
        m.getStyles().addAll(appendStyles);

        Date modified = new Date();
        Metadata.modified(m, modified);
        Metadata.modified(ws, modified);
View Full Code Here

   
    @RequestMapping(value="/{wsName}/{mpName}/layers/{name}", method = RequestMethod.GET)
    public @ResponseBody JSONObj mapLayerGet(@PathVariable String wsName,
                                             @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 )
View Full Code Here

    public @ResponseBody JSONArr plistRecentMaps() {
        JSONArr arr = new JSONArr();
        Catalog cat = geoServer.getCatalog();

        for (Ref ref : recent.list(LayerGroupInfo.class)) {
            LayerGroupInfo map = cat.getLayerGroup(ref.id);
            if( checkMap( map ) ){
                JSONObj obj = arr.addObject();
                map(obj, map, map.getWorkspace().getName());
            }
        }
        return arr;
    }
View Full Code Here

    public @ResponseBody JSONObj mapLayerDelete(@PathVariable String wsName,
                                                @PathVariable String mapName,
                                                @PathVariable String name, HttpServletRequest req) {
        Catalog cat = geoServer.getCatalog();

        LayerGroupInfo map = findMap(wsName, mapName, cat);
        WorkspaceInfo ws = map.getWorkspace();

        PublishedInfo layer = findMapLayer( map, name );
        int index = map.layers().indexOf(layer);
        boolean removed = map.getLayers().remove(layer);
        if( removed ){
            map.getStyles().remove(index);

            cat.save(map);
            recent.add(LayerGroupInfo.class, map);

            JSONObj delete = new JSONObj()
                .put("name", layer.getName())
                .put("removed", removed );
            return delete;
        }
        String message = String.format("Unable to remove map layer %s/$s/%s",map.getWorkspace().getName(),map.getName(),name);
        throw new IllegalStateException(message);
    }
View Full Code Here

                    .put("url",
                         IO.url(req, "/stores/%s/%s/%s", wsName, store.getName(),r.getNativeName())
                );
           
        } else if (l instanceof LayerGroupInfo) {
            LayerGroupInfo group = (LayerGroupInfo) l;
           
            IO.layer(obj, group, req);
//            String wsName = group.getWorkspace().getName();
//            obj.put("workspace", wsName);
//            obj.put("name", group.getName());
View Full Code Here

        // We only handle layers here. Layer groups are initially empty
        if (obj instanceof LayerInfo) {
            LayerInfo layerInfo = (LayerInfo) obj;
            gwc.createLayer(layerInfo);
        } else if (obj instanceof LayerGroupInfo) {
            LayerGroupInfo lgi = (LayerGroupInfo) obj;
            gwc.createLayer(lgi);
        }
    }
View Full Code Here

            }

            // Now we check for layer groups that are affected
            Iterator<LayerGroupInfo> lgiter = cat.getLayerGroups().iterator();
            while (lgiter.hasNext()) {
                LayerGroupInfo lgi = lgiter.next();
                boolean truncate = false;

                // First we check for referenced to affected layers
                liter = lgi.getLayers().iterator();
                while (!truncate && liter.hasNext()) {
                    LayerInfo li = liter.next();
                    if (layerNameList.contains(li.getResource().getPrefixedName())) {
                        truncate = true;
                    }
                }

                // Finally we need to check whether the style is used explicitly
                if (!truncate) {
                    Iterator<StyleInfo> siiter = lgi.getStyles().iterator();
                    while (!truncate && siiter.hasNext()) {
                        StyleInfo si2 = siiter.next();
                        if (si2 != null && si2.getName().equals(si.getName())) {
                            truncate = true;
                        }
                    }
                }

                if (truncate) {
                    gwc.truncate(lgi.getName());
                }
                // Next layer group
            }

        } else if (obj instanceof LayerInfo) {
            LayerInfo li = (LayerInfo) obj;
            gwc.createLayer(li);
        } else if (obj instanceof LayerGroupInfo) {
            LayerGroupInfo lgInfo = (LayerGroupInfo) obj;
            gwc.createLayer(lgInfo);
        }

    }
View Full Code Here

TOP

Related Classes of org.geoserver.catalog.LayerGroupInfo

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.