Search in sources :

Example 11 with ModuleDescriptorDto

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);
}
Also used : ModuleDescriptor(eu.bcvsolutions.idm.core.api.domain.ModuleDescriptor) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) ModuleDescriptorDto(eu.bcvsolutions.idm.core.api.dto.ModuleDescriptorDto) IOException(java.io.IOException) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ModuleDescriptorDto (eu.bcvsolutions.idm.core.api.dto.ModuleDescriptorDto)11 ModuleDescriptorEvent (eu.bcvsolutions.idm.core.api.event.ModuleDescriptorEvent)4 ModuleDescriptor (eu.bcvsolutions.idm.core.api.domain.ModuleDescriptor)3 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)3 SysConnectorServerDto (eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto)2 SysSystemFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter)2 SysSystem (eu.bcvsolutions.idm.acc.entity.SysSystem)2 SysRemoteServerService (eu.bcvsolutions.idm.acc.service.api.SysRemoteServerService)2 SysSystemService (eu.bcvsolutions.idm.acc.service.api.SysSystemService)2 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)2 ConfidentialStorage (eu.bcvsolutions.idm.core.api.service.ConfidentialStorage)2 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)2 ApiOperation (io.swagger.annotations.ApiOperation)2 List (java.util.List)2 Test (org.junit.Test)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 Lists (com.google.common.collect.Lists)1