@Test public void testList() throws Exception { MockGeoServer.get().catalog() .resources() .resource("workspaces/foo/styles/one.yaml", "title: raw") .directory("workspaces/foo/styles") .resource("workspaces/foo/styles/icon.png", "PNG") .resource("workspaces/foo/styles/symbols.TTF", "TTF") .directory("styles") .resource("styles/global.png", "PNG") .geoServer().catalog() .workspace("foo", "http: .layer("one") .style().ysld("one.yaml") .geoServer().build(geoServer); GeoServerResourceLoader rl = this.geoServer.getCatalog().getResourceLoader(); Resource d = rl.get("workspaces/foo/styles"); assertEquals( d.getType(), Type.DIRECTORY ); assertEquals( 3, d.list().size() ); MvcResult result = mvc.perform(get("/app/api/icons/list/foo")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); JSONArr arr = JSONWrapper.read(result.getResponse().getContentAsString()).toArray(); assertEquals( 2, arr.size() ); for( Iterator<Object> i = arr.iterator(); i.hasNext();){ Object item = i.next(); if( item instanceof JSONObj){ JSONObj obj = (JSONObj) item; if(obj.str("name").equals("icon.png")){ assertEquals( "png", obj.get("format")); assertEquals( "image/png", obj.get("mime")); assertTrue( obj.str("url").endsWith("icon.png")); } } } d = rl.get("styles"); assertEquals( d.getType(), Type.DIRECTORY ); assertEquals( 1, d.list().size() ); result = mvc.perform(get("/app/api/icons/list")) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andReturn(); arr = JSONWrapper.read(result.getResponse().getContentAsString()).toArray(); assertEquals( 1, arr.size() ); }
@RequestMapping(value = "/list", method = RequestMethod.GET) public @ResponseBody JSONArr list(HttpServletRequest request) throws IOException { return list(null, request); }
IconController extends ApiController { @RequestMapping(value = "/list", method = RequestMethod.GET) public @ResponseBody JSONArr list(HttpServletRequest request) throws IOException { return list(null, request); } }
IconController extends ApiController { @RequestMapping(value = "/list", method = RequestMethod.GET) public @ResponseBody JSONArr list(HttpServletRequest request) throws IOException { return list(null, request); } @Autowired  IconController(GeoServer geoServer); }
IconController extends ApiController { @RequestMapping(value = "/list", method = RequestMethod.GET) public @ResponseBody JSONArr list(HttpServletRequest request) throws IOException { return list(null, request); } @Autowired  IconController(GeoServer geoServer); @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseBody JSONArr list(HttpServletRequest request); @RequestMapping(value = "/list/{wsName:.+}", method = RequestMethod.GET) @ResponseBody JSONArr list(@PathVariable String wsName, HttpServletRequest request); @RequestMapping(value = "", method = RequestMethod.POST,consumes=MediaType.MULTIPART_FORM_DATA_VALUE) @ResponseStatus(value=HttpStatus.CREATED) @ResponseBody JSONArr create(HttpServletRequest request ); @RequestMapping(value = "/{wsName:.+}", method = RequestMethod.POST,consumes=MediaType.MULTIPART_FORM_DATA_VALUE) @ResponseStatus(value=HttpStatus.CREATED) @ResponseBody JSONArr create(@PathVariable String wsName,  HttpServletRequest request ); @RequestMapping(value = "/{icon:.+}", method = RequestMethod.GET) HttpEntity raw(@PathVariable String icon); @RequestMapping(value = "/{wsName}/{icon:.+}", method = RequestMethod.GET) HttpEntity raw(@PathVariable String wsName, @PathVariable String icon); @RequestMapping(value = "/{icon:.+}", method = RequestMethod.DELETE) @ResponseStatus(value = HttpStatus.NO_CONTENT) void delete(@PathVariable String icon); @RequestMapping(value = "/{wsName}/{icon:.+}", method = RequestMethod.DELETE) @ResponseStatus(value = HttpStatus.NO_CONTENT) void delete(@PathVariable String wsName, @PathVariable String icon); @ExceptionHandler(FileUploadException.class) @ResponseBody JSONObj error(FileUploadException e, HttpServletResponse response); @ExceptionHandler(IllegalArgumentException.class) @ResponseBody JSONObj error(IllegalArgumentException e, HttpServletResponse response); }
IconController extends ApiController { @RequestMapping(value = "/list", method = RequestMethod.GET) public @ResponseBody JSONArr list(HttpServletRequest request) throws IOException { return list(null, request); } @Autowired  IconController(GeoServer geoServer); @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseBody JSONArr list(HttpServletRequest request); @RequestMapping(value = "/list/{wsName:.+}", method = RequestMethod.GET) @ResponseBody JSONArr list(@PathVariable String wsName, HttpServletRequest request); @RequestMapping(value = "", method = RequestMethod.POST,consumes=MediaType.MULTIPART_FORM_DATA_VALUE) @ResponseStatus(value=HttpStatus.CREATED) @ResponseBody JSONArr create(HttpServletRequest request ); @RequestMapping(value = "/{wsName:.+}", method = RequestMethod.POST,consumes=MediaType.MULTIPART_FORM_DATA_VALUE) @ResponseStatus(value=HttpStatus.CREATED) @ResponseBody JSONArr create(@PathVariable String wsName,  HttpServletRequest request ); @RequestMapping(value = "/{icon:.+}", method = RequestMethod.GET) HttpEntity raw(@PathVariable String icon); @RequestMapping(value = "/{wsName}/{icon:.+}", method = RequestMethod.GET) HttpEntity raw(@PathVariable String wsName, @PathVariable String icon); @RequestMapping(value = "/{icon:.+}", method = RequestMethod.DELETE) @ResponseStatus(value = HttpStatus.NO_CONTENT) void delete(@PathVariable String icon); @RequestMapping(value = "/{wsName}/{icon:.+}", method = RequestMethod.DELETE) @ResponseStatus(value = HttpStatus.NO_CONTENT) void delete(@PathVariable String wsName, @PathVariable String icon); @ExceptionHandler(FileUploadException.class) @ResponseBody JSONObj error(FileUploadException e, HttpServletResponse response); @ExceptionHandler(IllegalArgumentException.class) @ResponseBody JSONObj error(IllegalArgumentException e, HttpServletResponse response);  }