MetadataExtentApi { @ApiOperation( value = "Get one record extent as image", notes = API_EXTENT_DESCRIPTION, nickname = "getOneRecordExtent") @RequestMapping( value = "/{metadataUuid}/extents/{geometryIndex}.png", produces = { MediaType.IMAGE_PNG_VALUE }, method = RequestMethod.GET) public HttpEntity<byte[]> getOneRecordExtentAsImage( @ApiParam( value = API_PARAM_RECORD_UUID, required = true) @PathVariable(value = "metadataUuid") String metadataUuid, @ApiParam(value = "Index of the geometry or bounding box to display. Starts at 1.") @PathVariable(value = "geometryIndex") Integer geometryIndex, @RequestParam(value = MAP_SRS_PARAM, defaultValue = "EPSG:4326") String srs, @ApiParam(value = API_PARAM_WIDTH_DESCRIPTION) @RequestParam(value = WIDTH_PARAM, required = false, defaultValue = "300") Integer width, @ApiParam(value = API_PARAM_HEIGHT_DESCRIPTION) @RequestParam(value = HEIGHT_PARAM, required = false) Integer height, @ApiParam(value = API_PARAM_BG_DESCRIPTION) @RequestParam(value = BACKGROUND_PARAM, required = false, defaultValue = "settings") String background, @ApiParam(value = API_PARAM_FILL_DESCRIPTION) @RequestParam(value = "", required = false, defaultValue = "0,0,0,50") String fillColor, @ApiParam(value = API_PARAM_STROKE_DESCRIPTION) @RequestParam(value = "", required = false, defaultValue = "0,0,0,255") String strokeColor, @ApiIgnore NativeWebRequest nativeWebRequest, @ApiIgnore HttpServletRequest request) throws Exception { return getExtent(metadataUuid, srs, width, height, background, fillColor, strokeColor, geometryIndex, nativeWebRequest, request); }  @ApiOperation( value = "Get all record extents as image", notes = API_EXTENT_DESCRIPTION, nickname = "getAllRecordExtents") @RequestMapping( value = "/{metadataUuid}/extents.png", produces = { MediaType.IMAGE_PNG_VALUE }, method = RequestMethod.GET) HttpEntity<byte[]> getAllRecordExtentAsImage(
        @ApiParam(
            value = API_PARAM_RECORD_UUID,
            required = true)
        @PathVariable(value = "metadataUuid")
            String metadataUuid,
        @RequestParam(value = MAP_SRS_PARAM, defaultValue = "EPSG:4326") String srs,
        @ApiParam(value = API_PARAM_WIDTH_DESCRIPTION)
        @RequestParam(value = WIDTH_PARAM, required = false, defaultValue = "300") Integer width,
        @ApiParam(value = API_PARAM_HEIGHT_DESCRIPTION)
        @RequestParam(value = HEIGHT_PARAM, required = false) Integer height,
        @ApiParam(value = API_PARAM_BG_DESCRIPTION)
        @RequestParam(value = BACKGROUND_PARAM, required = false, defaultValue = "settings") String background,
        @ApiParam(value = API_PARAM_FILL_DESCRIPTION)
        @RequestParam(value = "", required = false, defaultValue = "0,0,0,50")
        String fillColor,
        @ApiParam(value = API_PARAM_STROKE_DESCRIPTION)
        @RequestParam(value = "", required = false, defaultValue = "0,0,0,255")
        String strokeColor,
        @ApiIgnore
            NativeWebRequest nativeWebRequest,
        @ApiIgnore
            HttpServletRequest request); @ApiOperation( value = "Get list of record extents", notes = API_EXTENT_DESCRIPTION, nickname = "getAllRecordExtentsAsJson") @RequestMapping( value = "/{metadataUuid}/extents.json", produces = { MediaType.APPLICATION_JSON_VALUE }, method = RequestMethod.GET) @ResponseBody List<ExtentDto> getAllRecordExtentAsJson(
        @ApiParam(
            value = API_PARAM_RECORD_UUID,
            required = true)
        @PathVariable(value = "metadataUuid")
            String metadataUuid,
        @ApiIgnore
            HttpServletRequest request); @ApiOperation( value = "Get one record extent as image", notes = API_EXTENT_DESCRIPTION, nickname = "getOneRecordExtent") @RequestMapping( value = "/{metadataUuid}/extents/{geometryIndex}.png", produces = { MediaType.IMAGE_PNG_VALUE }, method = RequestMethod.GET) HttpEntity<byte[]> getOneRecordExtentAsImage(
        @ApiParam(
            value = API_PARAM_RECORD_UUID,
            required = true)
        @PathVariable(value = "metadataUuid")
            String metadataUuid,
        @ApiParam(value = "Index of the geometry or bounding box to display. Starts at 1.")
        @PathVariable(value = "geometryIndex")
            Integer geometryIndex,
        @RequestParam(value = MAP_SRS_PARAM, defaultValue = "EPSG:4326") String srs,
        @ApiParam(value = API_PARAM_WIDTH_DESCRIPTION)
        @RequestParam(value = WIDTH_PARAM, required = false, defaultValue = "300") Integer width,
        @ApiParam(value = API_PARAM_HEIGHT_DESCRIPTION)
        @RequestParam(value = HEIGHT_PARAM, required = false) Integer height,
        @ApiParam(value = API_PARAM_BG_DESCRIPTION)
        @RequestParam(value = BACKGROUND_PARAM, required = false, defaultValue = "settings") String background,
        @ApiParam(value = API_PARAM_FILL_DESCRIPTION)
        @RequestParam(value = "", required = false, defaultValue = "0,0,0,50")
            String fillColor,
        @ApiParam(value = API_PARAM_STROKE_DESCRIPTION)
        @RequestParam(value = "", required = false, defaultValue = "0,0,0,255")
            String strokeColor,
        @ApiIgnore
            NativeWebRequest nativeWebRequest,
        @ApiIgnore
            HttpServletRequest request); static final String MAP_SRS_PARAM; static final String GEOM_SRS_PARAM; static final String WIDTH_PARAM; static final String GEOM_PARAM; static final String GEOM_TYPE_PARAM; static final String HEIGHT_PARAM; static final String BACKGROUND_PARAM; static final String SETTING_BACKGROUND; static final String WIDTH_AND_HEIGHT_BOTH_DEFINED_MESSAGE; static final String WIDTH_AND_HEIGHT_BOTH_MISSING_MESSAGE; }
@Test public void getOneRecordExtentAsImage() throws Exception { MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(wac).build(); MockHttpSession mockHttpSession = loginAsAdmin(); String uuid = createTestData(); byte[] reponseBuffer = mockMvc.perform(get(String.format("/srv/api/records/%s/extents.png", uuid)) .session(mockHttpSession) .accept(MediaType.IMAGE_PNG_VALUE)) .andExpect(status().is2xxSuccessful()) .andExpect(content().contentType(API_PNG_EXPECTED_ENCODING)) .andReturn().getResponse().getContentAsByteArray(); saveImageToDiskIfConfiguredToDoSo(reponseBuffer, name.getMethodName()); assertEquals("b02baec6d92832ecd5653db78093a427", DigestUtils.md5DigestAsHex(reponseBuffer)); }