@Test public void testPut() throws Exception { GeoServer gs = MockGeoServer.get().catalog() .workspace("foo", "http: .layer("one").info("The layer", "This layer is cool!").style().point().layer() .featureType().defaults().store("one") .geoServer().build(geoServer); JSONObj obj = new JSONObj().put("title", "new title").put("proj", "EPSG:4326").put("timeout", 1000); MockHttpServletRequestBuilder req = put("/app/api/layers/foo/one") .contentType(MediaType.APPLICATION_JSON) .content(obj.toString()); mvc.perform(req).andExpect(status().isOk()).andReturn(); LayerInfo l = gs.getCatalog().getLayerByName("foo:one"); verify(l, times(1)).setTitle("new title"); assertEquals(1000L, l.getMetadata().get("timeout")); }
@RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody JSONObj put(@PathVariable String wsName, @PathVariable String name, @RequestBody JSONObj obj, HttpServletRequest req) throws IOException, NoSuchAuthorityCodeException, TransformException, FactoryException { Catalog cat = geoServer.getCatalog(); WorkspaceInfo ws = findWorkspace(wsName, cat); LayerInfo layer = findLayer(wsName, name, cat); return update(layer, ws, obj,req); }
LayerController extends ApiController { @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody JSONObj put(@PathVariable String wsName, @PathVariable String name, @RequestBody JSONObj obj, HttpServletRequest req) throws IOException, NoSuchAuthorityCodeException, TransformException, FactoryException { Catalog cat = geoServer.getCatalog(); WorkspaceInfo ws = findWorkspace(wsName, cat); LayerInfo layer = findLayer(wsName, name, cat); return update(layer, ws, obj,req); } }
LayerController extends ApiController { @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody JSONObj put(@PathVariable String wsName, @PathVariable String name, @RequestBody JSONObj obj, HttpServletRequest req) throws IOException, NoSuchAuthorityCodeException, TransformException, FactoryException { Catalog cat = geoServer.getCatalog(); WorkspaceInfo ws = findWorkspace(wsName, cat); LayerInfo layer = findLayer(wsName, name, cat); return update(layer, ws, obj,req); } @Autowired  LayerController(GeoServer geoServer, RecentObjectCache recentCache, Importer importer); }
LayerController extends ApiController { @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody JSONObj put(@PathVariable String wsName, @PathVariable String name, @RequestBody JSONObj obj, HttpServletRequest req) throws IOException, NoSuchAuthorityCodeException, TransformException, FactoryException { Catalog cat = geoServer.getCatalog(); WorkspaceInfo ws = findWorkspace(wsName, cat); LayerInfo layer = findLayer(wsName, name, cat); return update(layer, ws, obj,req); } @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.PUT, consumes = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody JSONObj put(@PathVariable String wsName, @PathVariable String name, @RequestBody JSONObj obj, HttpServletRequest req) throws IOException, NoSuchAuthorityCodeException, TransformException, FactoryException { Catalog cat = geoServer.getCatalog(); WorkspaceInfo ws = findWorkspace(wsName, cat); LayerInfo layer = findLayer(wsName, name, cat); return update(layer, ws, obj,req); } @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);  }