RegionsApi { @ApiOperation( value = "Get list of regions", nickname = "getRegions" ) @RequestMapping( method = RequestMethod.GET, produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @ResponseStatus(HttpStatus.OK) @ApiResponses(value = { @ApiResponse(code = 200, message = "List of regions.") }) @ResponseBody public ListRegionsResponse getRegions( @RequestParam(required = false) String label, @RequestParam(required = false) String categoryId, @RequestParam(defaultValue = "-1") int maxRecords, @ApiIgnore @ApiParam(hidden = true) NativeWebRequest webRequest) throws Exception { final HttpServletRequest nativeRequest = webRequest.getNativeRequest(HttpServletRequest.class); ServiceContext context = ApiUtils.createServiceContext(nativeRequest); ApplicationContext applicationContext = ApplicationContextHolder.get(); Collection<RegionsDAO> daos = applicationContext.getBeansOfType(RegionsDAO.class).values(); Collection<Region> regions = Lists.newArrayList(); for (RegionsDAO dao : daos) { if (dao.includeInListing()) { Request request = createRequest(label, categoryId, maxRecords, context, dao); regions.addAll(request.execute()); } } final HttpServletResponse nativeResponse = webRequest.getNativeResponse(HttpServletResponse.class); nativeResponse.setHeader("Cache-Control", "no-cache"); return new ListRegionsResponse(regions); }  @ApiOperation( value = "Get list of regions", nickname = "getRegions" ) @RequestMapping( method = RequestMethod.GET, produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @ResponseStatus(HttpStatus.OK) @ApiResponses(value = { @ApiResponse(code = 200, message = "List of regions.") }) @ResponseBody ListRegionsResponse getRegions(
        @RequestParam(required = false)
            String label,
        @RequestParam(required = false)
            String categoryId,
        @RequestParam(defaultValue = "-1")
            int maxRecords,
        @ApiIgnore
            @ApiParam(hidden = true)
        NativeWebRequest webRequest); @ApiOperation( value = "Get list of region types", nickname = "getRegionTypes" ) @RequestMapping( path = "/types", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE }) @ResponseStatus(HttpStatus.OK) @ApiResponses(value = { @ApiResponse(code = 200, message = "List of region types.") }) @ResponseBody List<Category> getRegionTypes(
        HttpServletRequest request); static Request createRequest(String label, String categoryId,
                                  int maxRecords, ServiceContext context,
                                  RegionsDAO dao); @ApiOperation( value = "Get geometry as image", notes = "A rendering of the geometry as a png.", nickname = "getGeomAsImage") @RequestMapping( value = "/geom.png", produces = { MediaType.IMAGE_PNG_VALUE }, method = RequestMethod.GET) HttpEntity<byte[]> getGeomAsImage(
        @RequestParam(value = MAP_SRS_PARAM, defaultValue = "EPSG:4326") String srs,
        @ApiParam(value = "(optional) width of the image that is created. Only one of width and height are permitted")
        @RequestParam(value = WIDTH_PARAM, required = false, defaultValue = "300") Integer width,
        @ApiParam(value = "(optional) height of the image that is created. Only one of width and height are permitted")
        @RequestParam(value = HEIGHT_PARAM, required = false) Integer height,
        @ApiParam(value = "(optional) URL for loading a background image for regions or a key that references the namedBackgrounds (configured in config-spring-geonetwork.xml). A WMS Getmap request is the typical example. The URL must be parameterized with the following parameters: minx, maxx, miny, maxy, width, height")
        @RequestParam(value = BACKGROUND_PARAM, required = false, defaultValue = "settings") String background,
        @ApiParam(value = "(optional) a wkt or gml encoded geometry.")
        @RequestParam(value = GEOM_PARAM, required = false) String geomParam,
        @ApiParam(value = "(optional) defines if geom is wkt or gml. Allowed values are wkt and gml. if not specified the it is assumed the geometry is wkt")
        @RequestParam(value = GEOM_TYPE_PARAM, defaultValue = "WKT") String geomType,
        @ApiParam(value = "")
        @RequestParam(value = GEOM_SRS_PARAM, defaultValue = "EPSG:4326") String geomSrs,
        @ApiIgnore
            NativeWebRequest nativeWebRequest,
        @ApiIgnore
            HttpServletRequest request);  }
@Test public void getRegions() throws Exception { this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); this.mockHttpSession = loginAsAdmin(); this.mockMvc.perform(get("/srv/api/regions") .session(this.mockHttpSession) .accept(MediaType.parseMediaType("application/json"))) .andExpect(status().isOk()) .andExpect(content().contentType(API_JSON_EXPECTED_ENCODING)) .andExpect(jsonPath("$.regions", hasSize(greaterThan(0)))); }