MetadataExtentApi { @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 public List<ExtentDto> getAllRecordExtentAsJson( @ApiParam( value = API_PARAM_RECORD_UUID, required = true) @PathVariable(value = "metadataUuid") String metadataUuid, @ApiIgnore HttpServletRequest request) throws Exception { AbstractMetadata metadata = ApiUtils.canViewRecord(metadataUuid, request); String schemaId = metadata.getDataInfo().getSchemaId(); MetadataSchema schema = schemaManager.getSchema(schemaId); Element xmlData = metadata.getXmlData(false); List<?> extentList = Xml.selectNodes( xmlData, EXTENT_XPATH, schema.getNamespaces()); List<ExtentDto> response = new ArrayList<>(extentList.size() + 1); if (!"iso19110".equals(schemaId)) { response.add(new ExtentDto( String.format("%sapi/records/%s/extents.png", settingManager.getNodeURL(), metadataUuid), "ALL", "", "")); } int index = 1; for (Object extent : extentList) { if (extent instanceof Element) { Element extentElement = (Element) extent; String description = Xml.selectString(extentElement, EXTENT_DESCRIPTION_XPATH, schema.getNamespaces()); response.add(new ExtentDto( String.format("%sapi/records/%s/extents/%d.png", settingManager.getNodeURL(), metadataUuid, index), extentElement.getName(), XPath.getXPath(xmlData, (Element) extent), description)); index ++; } } return response; }  @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 getAllRecordExtentAsJson() throws Exception { MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(wac).build(); MockHttpSession mockHttpSession = loginAsAdmin(); String uuid = createTestData(); mockMvc.perform(get(String.format("/srv/api/records/%s/extents.json", uuid)) .session(mockHttpSession) .accept(MediaType.APPLICATION_JSON_VALUE)) .andExpect(status().is2xxSuccessful()) .andExpect(content().contentType(API_JSON_EXPECTED_ENCODING)) .andExpect(jsonPath("$", hasSize(3))) .andExpect(jsonPath("$[0].href", is(String.format("http: .andExpect(jsonPath("$[0].type", is("ALL"))) .andExpect(jsonPath("$[1].href", is(String.format("http: .andExpect(jsonPath("$[1].type", is("EX_BoundingPolygon"))) .andExpect(jsonPath("$[1].description", is(""))) .andExpect(jsonPath("$[2].type", is("EX_GeographicBoundingBox"))); }