@SuppressWarnings("unused") @Test public void testDelete() throws Exception { GeoServer gs = MockGeoServer.get().catalog() .workspace("foo", "http: .layer("one") .info("The layer", "This layer is cool!") .meta(Metadata.IMPORTED, new Date()) .style().layer() .featureType().store("foo") .geoServer().build(geoServer); mvc.perform(delete("/app/api/layers/foo/one")) .andExpect(status().isNoContent()) .andReturn(); Catalog cat = geoServer.getCatalog(); verify(cat, times(1)).remove(isA(LayerInfo.class)); verify(cat, times(1)).remove(isA(StyleInfo.class)); }
@RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.DELETE) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void delete(@PathVariable String wsName, @PathVariable String name) throws IOException { Catalog cat = geoServer.getCatalog(); WorkspaceInfo ws = findWorkspace(wsName, cat); LayerInfo layer = findLayer(wsName, name, cat); recent.remove(LayerInfo.class, layer); recent.add(WorkspaceInfo.class, ws); CascadeDeleteVisitor remover = new CascadeDeleteVisitor(cat); remover.visit(layer); if (layer.getMetadata().containsKey(Metadata.IMPORTED)) { StyleInfo s = layer.getDefaultStyle(); try { remover.visit(s); dataDir().style(s).delete(); } catch(Exception e) { LOG.log(Level.WARNING, "Unable to delete style for layer " + wsName + ":" + layer.getName(), e); } } }
LayerController extends ApiController { @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.DELETE) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void delete(@PathVariable String wsName, @PathVariable String name) throws IOException { Catalog cat = geoServer.getCatalog(); WorkspaceInfo ws = findWorkspace(wsName, cat); LayerInfo layer = findLayer(wsName, name, cat); recent.remove(LayerInfo.class, layer); recent.add(WorkspaceInfo.class, ws); CascadeDeleteVisitor remover = new CascadeDeleteVisitor(cat); remover.visit(layer); if (layer.getMetadata().containsKey(Metadata.IMPORTED)) { StyleInfo s = layer.getDefaultStyle(); try { remover.visit(s); dataDir().style(s).delete(); } catch(Exception e) { LOG.log(Level.WARNING, "Unable to delete style for layer " + wsName + ":" + layer.getName(), e); } } } }
LayerController extends ApiController { @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.DELETE) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void delete(@PathVariable String wsName, @PathVariable String name) throws IOException { Catalog cat = geoServer.getCatalog(); WorkspaceInfo ws = findWorkspace(wsName, cat); LayerInfo layer = findLayer(wsName, name, cat); recent.remove(LayerInfo.class, layer); recent.add(WorkspaceInfo.class, ws); CascadeDeleteVisitor remover = new CascadeDeleteVisitor(cat); remover.visit(layer); if (layer.getMetadata().containsKey(Metadata.IMPORTED)) { StyleInfo s = layer.getDefaultStyle(); try { remover.visit(s); dataDir().style(s).delete(); } catch(Exception e) { LOG.log(Level.WARNING, "Unable to delete style for layer " + wsName + ":" + layer.getName(), e); } } } @Autowired  LayerController(GeoServer geoServer, RecentObjectCache recentCache, Importer importer); }
LayerController extends ApiController { @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.DELETE) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void delete(@PathVariable String wsName, @PathVariable String name) throws IOException { Catalog cat = geoServer.getCatalog(); WorkspaceInfo ws = findWorkspace(wsName, cat); LayerInfo layer = findLayer(wsName, name, cat); recent.remove(LayerInfo.class, layer); recent.add(WorkspaceInfo.class, ws); CascadeDeleteVisitor remover = new CascadeDeleteVisitor(cat); remover.visit(layer); if (layer.getMetadata().containsKey(Metadata.IMPORTED)) { StyleInfo s = layer.getDefaultStyle(); try { remover.visit(s); dataDir().style(s).delete(); } catch(Exception e) { LOG.log(Level.WARNING, "Unable to delete style for layer " + wsName + ":" + layer.getName(), e); } } } @Autowired  LayerController(GeoServer geoServer, RecentObjectCache recentCache, Importer importer); @RequestMapping(value="/{wsName:.+}", method = RequestMethod.GET) @ResponseBody JSONObj list(@PathVariable String wsName, 
            @RequestParam(value="page", required=false) Integer page,
            @RequestParam(value="count", required=false, defaultValue=""+DEFAULT_PAGESIZE) Integer count,
            @RequestParam(value="sort", required=false) String sort, 
            @RequestParam(value="filter", required=false) String textFilter, 
            HttpServletRequest req); @RequestMapping(value = "/{wsName:.+}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) @ResponseBody JSONObj create(@PathVariable String wsName, @RequestBody JSONObj obj, HttpServletRequest req); @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.GET) @ResponseBody JSONObj get(@PathVariable String wsName, @PathVariable String name, HttpServletRequest req); @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.DELETE) @ResponseStatus(value = HttpStatus.NO_CONTENT) void delete(@PathVariable String wsName, @PathVariable String name); @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.PATCH) @ResponseBody JSONObj patch(@PathVariable String wsName, @PathVariable String name, @RequestBody JSONObj obj, HttpServletRequest req); @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseBody JSONObj put(@PathVariable String wsName, @PathVariable String name, @RequestBody JSONObj obj, HttpServletRequest req); void computeNativeBounds(ResourceInfo r, Catalog catalog); void computeLatLonBounds(ResourceInfo r, Catalog catalog); @RequestMapping(value="/{wsName}/{name}/style", method = RequestMethod.PUT, consumes = YsldHandler.MIMETYPE) @ResponseStatus(value = HttpStatus.OK) void style(@RequestBody byte[] rawStyle, @PathVariable String wsName,
        @PathVariable String name, @RequestParam(value="map", required=false) String mapName); @RequestMapping(value="/{wsName}/{name}/style", method = RequestMethod.GET, produces = YsldHandler.MIMETYPE) @ResponseBody Object style(@PathVariable String wsName, @PathVariable String name); @ExceptionHandler(InvalidYsldException.class) @ResponseBody JSONObj error(InvalidYsldException e, HttpServletResponse response); @RequestMapping(value="/recent", method = RequestMethod.GET) @ResponseBody JSONArr recent(HttpServletRequest req); }
LayerController extends ApiController { @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.DELETE) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void delete(@PathVariable String wsName, @PathVariable String name) throws IOException { Catalog cat = geoServer.getCatalog(); WorkspaceInfo ws = findWorkspace(wsName, cat); LayerInfo layer = findLayer(wsName, name, cat); recent.remove(LayerInfo.class, layer); recent.add(WorkspaceInfo.class, ws); CascadeDeleteVisitor remover = new CascadeDeleteVisitor(cat); remover.visit(layer); if (layer.getMetadata().containsKey(Metadata.IMPORTED)) { StyleInfo s = layer.getDefaultStyle(); try { remover.visit(s); dataDir().style(s).delete(); } catch(Exception e) { LOG.log(Level.WARNING, "Unable to delete style for layer " + wsName + ":" + layer.getName(), e); } } } @Autowired  LayerController(GeoServer geoServer, RecentObjectCache recentCache, Importer importer); @RequestMapping(value="/{wsName:.+}", method = RequestMethod.GET) @ResponseBody JSONObj list(@PathVariable String wsName, 
            @RequestParam(value="page", required=false) Integer page,
            @RequestParam(value="count", required=false, defaultValue=""+DEFAULT_PAGESIZE) Integer count,
            @RequestParam(value="sort", required=false) String sort, 
            @RequestParam(value="filter", required=false) String textFilter, 
            HttpServletRequest req); @RequestMapping(value = "/{wsName:.+}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) @ResponseBody JSONObj create(@PathVariable String wsName, @RequestBody JSONObj obj, HttpServletRequest req); @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.GET) @ResponseBody JSONObj get(@PathVariable String wsName, @PathVariable String name, HttpServletRequest req); @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.DELETE) @ResponseStatus(value = HttpStatus.NO_CONTENT) void delete(@PathVariable String wsName, @PathVariable String name); @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.PATCH) @ResponseBody JSONObj patch(@PathVariable String wsName, @PathVariable String name, @RequestBody JSONObj obj, HttpServletRequest req); @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseBody JSONObj put(@PathVariable String wsName, @PathVariable String name, @RequestBody JSONObj obj, HttpServletRequest req); void computeNativeBounds(ResourceInfo r, Catalog catalog); void computeLatLonBounds(ResourceInfo r, Catalog catalog); @RequestMapping(value="/{wsName}/{name}/style", method = RequestMethod.PUT, consumes = YsldHandler.MIMETYPE) @ResponseStatus(value = HttpStatus.OK) void style(@RequestBody byte[] rawStyle, @PathVariable String wsName,
        @PathVariable String name, @RequestParam(value="map", required=false) String mapName); @RequestMapping(value="/{wsName}/{name}/style", method = RequestMethod.GET, produces = YsldHandler.MIMETYPE) @ResponseBody Object style(@PathVariable String wsName, @PathVariable String name); @ExceptionHandler(InvalidYsldException.class) @ResponseBody JSONObj error(InvalidYsldException e, HttpServletResponse response); @RequestMapping(value="/recent", method = RequestMethod.GET) @ResponseBody JSONArr recent(HttpServletRequest req);  }