SiteApi { @ApiOperation( value = "Get site informations", notes = "", nickname = "getInformation") @RequestMapping( path = "/info", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ApiResponses(value = { @ApiResponse(code = 200, message = "Site information.") }) @ResponseBody public SiteInformation getInformation(HttpServletRequest request ) throws Exception { ServiceContext context = ApiUtils.createServiceContext(request); return new SiteInformation(context, (GeonetContext) context .getHandlerContext(Geonet.CONTEXT_NAME)); }  static void reloadServices(ServiceContext context); @ApiOperation( value = "Get site (or portal) description", notes = "", nickname = "getDescription") @RequestMapping( produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ApiResponses(value = { @ApiResponse(code = 200, message = "Site description.") }) @ResponseBody SettingsListResponse get(
        @ApiIgnore
        HttpServletRequest request
    ); @ApiOperation( value = "Get settings", notes = "Return settings for anonymous users, internals are allowed for authenticated.", nickname = "getSettings") @RequestMapping( path = "/settings", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ApiResponses(value = { @ApiResponse(code = 200, message = "Settings.") }) @ResponseBody SettingsListResponse getSettingsSet(
        @ApiParam(
            value = "Setting set. A common set of settings to retrieve.",
            required = false
        )
        @RequestParam(
            required = false
        )
            SettingSet[] set,
        @ApiParam(
            value = "Setting key",
            required = false
        )
        @RequestParam(
            required = false
        )
            String[] key,
        HttpServletRequest request,
        @ApiIgnore
        @ApiParam(
            hidden = true
        )
            HttpSession httpSession
    ); @ApiOperation( value = "Get settings with details", notes = "Provides also setting properties.", nickname = "getSettingsDetails") @RequestMapping( path = "/settings/details", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ApiResponses(value = { @ApiResponse(code = 200, message = "Settings with details.") }) @ResponseBody @PreAuthorize("hasRole('Administrator')") List<Setting> getSettingsDetails(
        @ApiParam(
            value = "Setting set. A common set of settings to retrieve.",
            required = false
        )
        @RequestParam(
            required = false
        )
            SettingSet[] set,
        @ApiParam(
            value = "Setting key",
            required = false
        )
        @RequestParam(
            required = false
        )
            String[] key,
        HttpServletRequest request,
        @ApiIgnore
        @ApiParam(
            hidden = true
        )
            HttpSession httpSession
    ); @ApiOperation( value = "Save settings", notes = "", nickname = "saveSettingsDetails") @RequestMapping( path = "/settings", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST ) @PreAuthorize("hasRole('Administrator')") @ResponseStatus(HttpStatus.NO_CONTENT) @ApiResponses(value = { @ApiResponse(code = 204, message = "Settings saved."), @ApiResponse(code = 403, message = ApiParams.API_RESPONSE_NOT_ALLOWED_ONLY_ADMIN) }) void saveSettings(
        @ApiIgnore
        @ApiParam(hidden = false)
        @RequestParam
            Map<String, String> allRequestParams,
        HttpServletRequest request,
        @ApiIgnore
        @ApiParam(
            hidden = true
        )
            HttpSession httpSession
    ); @ApiOperation( value = "Get site informations", notes = "", nickname = "getInformation") @RequestMapping( path = "/info", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ApiResponses(value = { @ApiResponse(code = 200, message = "Site information.") }) @ResponseBody SiteInformation getInformation(HttpServletRequest request
    ); @ApiOperation( value = "Is CAS enabled?", notes = "", nickname = "isCasEnabled") @RequestMapping( path = "/info/isCasEnabled", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET) @ResponseStatus(value = HttpStatus.OK) @ResponseBody // This service returns a boolean, not encapsulated in json // TODO: Review to return a valid JSON, check also similar methods boolean isCasEnabled(
        HttpServletRequest request
    ); @ApiOperation( value = "Update staging profile", notes = "TODO: Needs doc", nickname = "updateStagingProfile") @RequestMapping( path = "/info/staging/{profile}", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.PUT) @ResponseStatus(HttpStatus.NO_CONTENT) @ApiResponses(value = { @ApiResponse(code = 204, message = "Staging profile saved."), @ApiResponse(code = 403, message = ApiParams.API_RESPONSE_NOT_ALLOWED_ONLY_ADMIN) }) @PreAuthorize("hasRole('Administrator')") void updateStagingProfile(
        @PathVariable
            SystemInfo.Staging profile); @ApiOperation( value = "Is in read-only mode?", notes = "", nickname = "isReadOnly") @RequestMapping( path = "/info/readonly", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET) @ResponseStatus(value = HttpStatus.OK) @ResponseBody boolean isReadOnly(
    ); @ApiOperation( value = "Is indexing?", notes = "", nickname = "isIndexing") @RequestMapping( path = "/indexing", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET) @ResponseStatus(value = HttpStatus.OK) @ResponseBody boolean isIndexing(
        HttpServletRequest request
    ); @ApiOperation( value = "Index", notes = "", nickname = "index") @RequestMapping( path = "/index", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.PUT) @PreAuthorize("hasRole('Editor')") @ResponseBody HttpEntity index(
        @ApiParam(value = "Drop and recreate index",
            required = false)
        @RequestParam(required = false, defaultValue = "true")
        boolean reset,
        @ApiParam(value = "Records having only XLinks",
            required = false)
        @RequestParam(required = false, defaultValue = "false")
            boolean havingXlinkOnly,
//        @ApiParam(value = API_PARAM_RECORD_UUIDS_OR_SELECTION,
//            required = false,
//            example = "")
//        @RequestParam(required = false)
//        String[] uuids,
        @ApiParam(
            value = ApiParams.API_PARAM_BUCKET_NAME,
            required = false)
        @RequestParam(
            required = false
        )
        String bucket,
        HttpServletRequest request
    ); @ApiOperation( value = "Index in Elastic", notes = "", nickname = "indexes") @RequestMapping( path = "/index/es", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.PUT) @PreAuthorize("hasRole('Editor')") @ResponseBody HttpEntity indexEs(
        @ApiParam(value = "Drop and recreate index",
            required = false)
        @RequestParam(required = false, defaultValue = "true")
            boolean reset,
        @ApiParam(value = "Records having only XLinks",
            required = false)
        @RequestParam(required = false, defaultValue = "false")
            boolean havingXlinkOnly,
//        @ApiParam(value = API_PARAM_RECORD_UUIDS_OR_SELECTION,
//            required = false,
//            example = "")
//        @RequestParam(required = false)
//        String[] uuids,
        @ApiParam(
            value = ApiParams.API_PARAM_BUCKET_NAME,
            required = false)
        @RequestParam(
            required = false
        )
            String bucket,
        HttpServletRequest request
    ); @ApiOperation( value = "Delete index in Elastic", notes = "", nickname = "deleteIndexes") @RequestMapping( path = "/index/es", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.DELETE) @PreAuthorize("hasRole('Editor')") @ResponseBody HttpEntity deleteIndexEs(); @ApiOperation( value = "Get build details", notes = "To know when and how this version of the application was built.", nickname = "getSystemInfo") @RequestMapping( path = "/info/build", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ApiResponses(value = { @ApiResponse(code = 200, message = "Build info.") }) @ResponseBody SystemInfo getSystemInfo(
    ); @ApiOperation( value = "Set catalog logo", notes = "Logos are stored in the data directory " + "resources/images/harvesting as PNG or GIF images. " + "When a logo is assigned to the catalog, a new " + "image is created in images/logos/<catalogUuid>.png.", nickname = "setLogo") @RequestMapping( path = "/logo", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.PUT) @PreAuthorize("hasRole('UserAdmin')") @ResponseStatus(HttpStatus.NO_CONTENT) @ApiResponses(value = { @ApiResponse(code = 204, message = "Logo set."), @ApiResponse(code = 403, message = ApiParams.API_RESPONSE_NOT_ALLOWED_ONLY_USER_ADMIN) }) void setLogo(
        @ApiParam(value = "Logo to use for the catalog")
        @RequestParam("file")
            String file,
        @ApiParam(
            value = "Create favicon too",
            required = false
        )
        @RequestParam(
            defaultValue = "false",
            required = false
        )
            boolean asFavicon,
        HttpServletRequest request

    ); @ApiOperation( value = "Get XSL tranformations available", notes = "XSL transformations may be applied while importing or harvesting records.", nickname = "getXslTransformations") @RequestMapping( path = "/info/transforms", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) @ApiResponses(value = { @ApiResponse(code = 200, message = "XSLT available.") }) @ResponseBody List<String> getXslTransformations(
    );  }
@Test public void getInformation() throws Exception { this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); this.mockHttpSession = loginAsAdmin(); this.mockMvc.perform(get("/srv/api/site/info") .accept(MediaType.parseMediaType("application/json")) .session(this.mockHttpSession)) .andExpect(status().isOk()) .andExpect(content().contentType(API_JSON_EXPECTED_ENCODING)) .andExpect(jsonPath("$.catalogue['data.dataDir']", is(not(isEmptyOrNullString())))) .andExpect(jsonPath("$.index['index.path']", is(not(isEmptyOrNullString())))) .andExpect(jsonPath("$.main['java.version']", is(not(isEmptyOrNullString())))) .andExpect(jsonPath("$.database['db.url']", is(not(isEmptyOrNullString())))); }