use of eu.bcvsolutions.idm.core.api.dto.ModuleDescriptorDto in project CzechIdMng by bcvsolutions.
the class ModuleController method patch.
/**
* Supports enable / disable only
*
* @param moduleId
* @param nativeRequest
* @return
*/
@ResponseBody
@RequestMapping(value = "/{moduleId}", method = RequestMethod.PATCH)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.MODULE_UPDATE + "')")
@ApiOperation(value = "Update module properties", nickname = "patchModule", tags = { ModuleController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.MODULE_UPDATE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.MODULE_UPDATE, description = "") }) }, notes = "Supports enable / disable only")
public ModuleDescriptorDto patch(@ApiParam(value = "Module's identifier.", required = true) @PathVariable @NotNull String moduleId, HttpServletRequest nativeRequest) {
ModuleDescriptor updatedModuleDescriptor = moduleService.getModule(moduleId);
if (updatedModuleDescriptor == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", moduleId));
}
//
ServletServerHttpRequest request = new ServletServerHttpRequest(nativeRequest);
try {
ModuleDescriptorDto dto = objectMapper.readValue(request.getBody(), ModuleDescriptorDto.class);
moduleService.setEnabled(moduleId, !dto.isDisabled());
} catch (IOException ex) {
throw new ResultCodeException(CoreResultCode.BAD_REQUEST, ex);
}
//
return get(moduleId);
}
Aggregations