use of eu.bcvsolutions.idm.core.api.domain.ModuleDescriptor in project CzechIdMng by bcvsolutions.
the class DefaultModuleServiceUnitTest method init.
@Before
public void init() {
PluginRegistry<ModuleDescriptor, String> registry = SimplePluginRegistry.create(Lists.newArrayList(new ModuleDescriptorOne(), new ModuleDescriptorTwo()));
defaultModuleService = new DefaultModuleService(registry, configurationService);
}
use of eu.bcvsolutions.idm.core.api.domain.ModuleDescriptor in project CzechIdMng by bcvsolutions.
the class DefaultModuleService method setEnabled.
@Override
public void setEnabled(String moduleId, boolean enabled) {
ModuleDescriptor moduleDescriptor = moduleDescriptorRegistry.getPluginFor(moduleId);
ModuleDescriptorDto moduleDescriptorDto = null;
if (moduleDescriptor == null) {
LOG.info("Frontend module [{}] will be enabled [{}].", moduleId, enabled);
// FE module - create basic descriptor
moduleDescriptorDto = new ModuleDescriptorDto(moduleId);
moduleDescriptorDto.setDisableable(true);
moduleDescriptorDto.setDisabled(!configurationService.getBooleanValue(getModuleConfigurationProperty(moduleId, ConfigurationService.PROPERTY_ENABLED), false));
} else {
LOG.info("Backend module [{}] will be enabled [{}].", moduleId, enabled);
//
moduleDescriptorDto = toDto(moduleDescriptor);
}
//
ModuleDescriptorEvent event = new ModuleDescriptorEvent(enabled ? ModuleDescriptorEventType.ENABLE : ModuleDescriptorEventType.DISABLE, moduleDescriptorDto);
entityEventManager.process(event);
}
use of eu.bcvsolutions.idm.core.api.domain.ModuleDescriptor in project CzechIdMng by bcvsolutions.
the class ModuleController method put.
/**
* Supports enable / disable only
*
* @param moduleId
* @param nativeRequest
* @return
*/
@ResponseBody
@RequestMapping(value = "/{moduleId}", method = RequestMethod.PUT)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.MODULE_UPDATE + "')")
@ApiOperation(value = "Update module properties", nickname = "putModule", 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 put(@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));
}
ModuleDescriptorDto md = (ModuleDescriptorDto) requestResourceResolver.resolve(nativeRequest, ModuleDescriptorDto.class, null);
moduleService.setEnabled(moduleId, !md.isDisabled());
return get(moduleId);
}
use of eu.bcvsolutions.idm.core.api.domain.ModuleDescriptor in project CzechIdMng by bcvsolutions.
the class ModuleController method put.
/**
* Supports enable / disable only
*
* @param moduleId
* @param nativeRequest
* @return
*/
@ResponseBody
@RequestMapping(value = "/{moduleId}", method = RequestMethod.PUT)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.MODULE_UPDATE + "')")
@ApiOperation(value = "Update module properties", nickname = "putModule", 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 put(@ApiParam(value = "Module's identifier.", required = true) @PathVariable @NotNull String moduleId, @Valid @RequestBody ModuleDescriptorDto dto) {
ModuleDescriptor updatedModuleDescriptor = moduleService.getModule(moduleId);
if (updatedModuleDescriptor == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", moduleId));
}
//
moduleService.setEnabled(moduleId, !dto.isDisabled());
return get(moduleId);
}
use of eu.bcvsolutions.idm.core.api.domain.ModuleDescriptor 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