@SuppressWarnings("unused") @Test public void testGet() 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("foo") .geoServer().build(geoServer); LayerInfo l = gs.getCatalog().getLayerByName("foo:one"); l.getMetadata().put("timeout", 1000); gs.getCatalog().save(l); MvcResult result = mvc.perform(get("/app/api/layers/foo/one")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); JSONObj obj = JSONWrapper.read(result.getResponse().getContentAsString()).toObject(); assertEquals("one", obj.str("name")); assertEquals("foo", obj.str("workspace")); assertEquals("vector", obj.str("type")); assertEquals("The layer", obj.str("title")); assertEquals("This layer is cool!", obj.str("description")); assertEquals("point", obj.object("style").str("name")); assertEquals("EPSG:4326", obj.object("proj").str("srs")); assertEquals(-180d, obj.object("bbox").object("native").doub("west"), 0.1); assertEquals(-90d, obj.object("bbox").object("native").doub("south"), 0.1); assertEquals(180d, obj.object("bbox").object("native").doub("east"), 0.1); assertEquals(90d, obj.object("bbox").object("native").doub("north"), 0.1); assertEquals(0d, obj.object("bbox").object("native").array("center").doub(0), 0.1); assertEquals(0d, obj.object("bbox").object("native").array("center").doub(1), 0.1); assertEquals(-180d, obj.object("bbox").object("lonlat").doub("west"), 0.1); assertEquals(-90d, obj.object("bbox").object("lonlat").doub("south"), 0.1); assertEquals(180d, obj.object("bbox").object("lonlat").doub("east"), 0.1); assertEquals(90d, obj.object("bbox").object("lonlat").doub("north"), 0.1); assertEquals(0d, obj.object("bbox").object("lonlat").array("center").doub(0), 0.1); assertEquals(0d, obj.object("bbox").object("lonlat").array("center").doub(1), 0.1); assertEquals(1000L, obj.get("timeout")); assertNotNull(obj.get("modified")); assertNotNull(obj.get("created")); String mod = obj.object("modified").str("timestamp"); }
@RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.GET) public @ResponseBody JSONObj get(@PathVariable String wsName, @PathVariable String name, HttpServletRequest req) { LayerInfo l = findLayer(wsName, name, geoServer.getCatalog()); return layer(new JSONObj(), l, req); }
LayerController extends ApiController { @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.GET) public @ResponseBody JSONObj get(@PathVariable String wsName, @PathVariable String name, HttpServletRequest req) { LayerInfo l = findLayer(wsName, name, geoServer.getCatalog()); return layer(new JSONObj(), l, req); } }
LayerController extends ApiController { @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.GET) public @ResponseBody JSONObj get(@PathVariable String wsName, @PathVariable String name, HttpServletRequest req) { LayerInfo l = findLayer(wsName, name, geoServer.getCatalog()); return layer(new JSONObj(), l, req); } @Autowired  LayerController(GeoServer geoServer, RecentObjectCache recentCache, Importer importer); }
LayerController extends ApiController { @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.GET) public @ResponseBody JSONObj get(@PathVariable String wsName, @PathVariable String name, HttpServletRequest req) { LayerInfo l = findLayer(wsName, name, geoServer.getCatalog()); return layer(new JSONObj(), l, 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.GET) public @ResponseBody JSONObj get(@PathVariable String wsName, @PathVariable String name, HttpServletRequest req) { LayerInfo l = findLayer(wsName, name, geoServer.getCatalog()); return layer(new JSONObj(), l, 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);  }