@Test public void testGet() throws Exception { @SuppressWarnings("unused") GeoServer gs = MockGeoServer.get().catalog() .resources() .resource("workspaces/foo/layergroups/map.xml", "layergroup placeholder") .geoServer() .catalog() .workspace("foo", "http: .map("map") .defaults() .info("The map", "This map is cool!") .layer("one").style().point().layer().featureType().defaults().store("shape").map() .layer("two").style().point().layer().featureType().defaults().store("shape") .geoServer().build(geoServer); LayerGroupInfo l = gs.getCatalog().getLayerGroupByName("map"); l.getMetadata().put("timeout", 1000); MvcResult result = mvc.perform(get("/app/api/maps/foo/map")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); JSONObj obj = JSONWrapper.read(result.getResponse().getContentAsString()).toObject(); assertEquals("map", obj.str("name")); assertEquals("foo", obj.str("workspace")); assertEquals("The map", obj.str("title")); assertEquals("This map is cool!", obj.str("description")); assertEquals(-180d, obj.object("bbox").doub("west"), 0.1); assertEquals(-90d, obj.object("bbox").doub("south"), 0.1); assertEquals(180d, obj.object("bbox").doub("east"), 0.1); assertEquals(90d, obj.object("bbox").doub("north"), 0.1); assertEquals(0d, obj.object("bbox").array("center").doub(0), 0.1); assertEquals(0d, obj.object("bbox").array("center").doub(1), 0.1); assertEquals(2, obj.array("layers").size()); Iterables.find(obj.array("layers"), new Predicate<Object>() { @Override public boolean apply(@Nullable Object o) { return "one".equals(JSONWrapper.wrap(o).toObject().str("name")); } }); Iterables.find(obj.array("layers"), new Predicate<Object>() { @Override public boolean apply(@Nullable Object o) { return "two".equals(JSONWrapper.wrap(o).toObject().str("name")); } }); assertEquals(1000L, obj.get("timeout")); assertNotNull(obj.get("modified")); }
@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); }
MapController extends ApiController { @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); } }
MapController extends ApiController { @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); } @Autowired  MapController(GeoServer geoServer, RecentObjectCache recentCache); }
MapController extends ApiController { @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); } @Autowired  MapController(GeoServer geoServer, RecentObjectCache recentCache); @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.DELETE) @ResponseStatus(value = HttpStatus.NO_CONTENT) void delete(@PathVariable String wsName, @PathVariable String name); @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.GET) @ResponseBody JSONObj get(@PathVariable String wsName,
                                     @PathVariable String name, HttpServletRequest req); @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) @ResponseBody JSONObj put(@PathVariable String wsName,
                                     @PathVariable String name, 
                                     @RequestBody JSONObj obj,
                                     HttpServletRequest req); @RequestMapping(value = "/{wsName}/{name:.+}/bounds", method = RequestMethod.PUT) @ResponseBody JSONObj bounds(@PathVariable String wsName,
                                     @PathVariable String name, 
                                     @RequestBody JSONObj obj,
                                     HttpServletRequest req); @RequestMapping(value = "/{wsName}/{name}/copy", method = RequestMethod.PUT) @ResponseBody JSONObj copy(@PathVariable String wsName,
                                     @PathVariable String name, 
                                     @RequestBody JSONObj obj,
                                     HttpServletRequest req); @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); @RequestMapping(value="/{wsName}/{name}/layers", method = RequestMethod.GET) @ResponseBody JSONArr mapLayerListGet(@PathVariable String wsName,
                            @PathVariable String name, HttpServletRequest req); @RequestMapping(value="/{wsName}/{name}/layers", method = RequestMethod.PUT) @ResponseBody JSONArr mapLayerListPut(@PathVariable String wsName,
                                                 @PathVariable String name,
                                                 @RequestBody JSONArr layers, HttpServletRequest req); @RequestMapping(value="/{wsName}/{name}/layers", method = RequestMethod.POST) @ResponseBody JSONArr mapLayerListPost(@PathVariable String wsName,
                                                  @PathVariable String name,
                                                  @RequestBody JSONArr layers, HttpServletRequest req); @RequestMapping(value="/{wsName}/{mpName}/layers/{name:.+}", method = RequestMethod.GET) @ResponseBody JSONObj mapLayerGet(@PathVariable String wsName,
                                             @PathVariable String mpName,
                                             @PathVariable String name, HttpServletRequest req); @RequestMapping(value="/recent", method = RequestMethod.GET) @ResponseBody JSONArr listRecentMaps(); @RequestMapping(value="/{wsName}/{mapName}/layers/{name:.+}", method = RequestMethod.DELETE) @ResponseBody JSONObj mapLayerDelete(@PathVariable String wsName,
                                                @PathVariable String mapName,
                                                @PathVariable String name, HttpServletRequest req); }
MapController extends ApiController { @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); } @Autowired  MapController(GeoServer geoServer, RecentObjectCache recentCache); @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.DELETE) @ResponseStatus(value = HttpStatus.NO_CONTENT) void delete(@PathVariable String wsName, @PathVariable String name); @RequestMapping(value="/{wsName}/{name:.+}", method = RequestMethod.GET) @ResponseBody JSONObj get(@PathVariable String wsName,
                                     @PathVariable String name, HttpServletRequest req); @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) @ResponseBody JSONObj put(@PathVariable String wsName,
                                     @PathVariable String name, 
                                     @RequestBody JSONObj obj,
                                     HttpServletRequest req); @RequestMapping(value = "/{wsName}/{name:.+}/bounds", method = RequestMethod.PUT) @ResponseBody JSONObj bounds(@PathVariable String wsName,
                                     @PathVariable String name, 
                                     @RequestBody JSONObj obj,
                                     HttpServletRequest req); @RequestMapping(value = "/{wsName}/{name}/copy", method = RequestMethod.PUT) @ResponseBody JSONObj copy(@PathVariable String wsName,
                                     @PathVariable String name, 
                                     @RequestBody JSONObj obj,
                                     HttpServletRequest req); @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); @RequestMapping(value="/{wsName}/{name}/layers", method = RequestMethod.GET) @ResponseBody JSONArr mapLayerListGet(@PathVariable String wsName,
                            @PathVariable String name, HttpServletRequest req); @RequestMapping(value="/{wsName}/{name}/layers", method = RequestMethod.PUT) @ResponseBody JSONArr mapLayerListPut(@PathVariable String wsName,
                                                 @PathVariable String name,
                                                 @RequestBody JSONArr layers, HttpServletRequest req); @RequestMapping(value="/{wsName}/{name}/layers", method = RequestMethod.POST) @ResponseBody JSONArr mapLayerListPost(@PathVariable String wsName,
                                                  @PathVariable String name,
                                                  @RequestBody JSONArr layers, HttpServletRequest req); @RequestMapping(value="/{wsName}/{mpName}/layers/{name:.+}", method = RequestMethod.GET) @ResponseBody JSONObj mapLayerGet(@PathVariable String wsName,
                                             @PathVariable String mpName,
                                             @PathVariable String name, HttpServletRequest req); @RequestMapping(value="/recent", method = RequestMethod.GET) @ResponseBody JSONArr listRecentMaps(); @RequestMapping(value="/{wsName}/{mapName}/layers/{name:.+}", method = RequestMethod.DELETE) @ResponseBody JSONObj mapLayerDelete(@PathVariable String wsName,
                                                @PathVariable String mapName,
                                                @PathVariable String name, HttpServletRequest req);  }