Search in sources :

Example 11 with SysProvisioningBatchDto

use of eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto in project CzechIdMng by bcvsolutions.

the class ProvisioningOperationRetryBulkAction method processDto.

@Override
protected OperationResult processDto(SysProvisioningOperationDto dto) {
    if (isRetryWholeBatchAttribute()) {
        SysProvisioningBatchDto batch = DtoUtils.getEmbedded(dto, SysProvisioningOperation_.batch, SysProvisioningBatchDto.class, null);
        if (batch == null) {
            batch = provisioningOperationBatchService.get(dto.getBatch());
        }
        provisioningExecutor.execute(batch);
    } else {
        provisioningExecutor.execute(dto);
    }
    return new OperationResult(OperationState.EXECUTED);
}
Also used : SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult)

Example 12 with SysProvisioningBatchDto

use of eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto in project CzechIdMng by bcvsolutions.

the class DefaultSysSystemEntityService method deleteInternal.

@Override
@Transactional
public void deleteInternal(SysSystemEntityDto systemEntity) {
    Assert.notNull(systemEntity, "System entity is required.");
    // 
    SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
    filter.setSystemId(systemEntity.getSystem());
    filter.setEntityType(systemEntity.getEntityType());
    filter.setSystemEntity(systemEntity.getId());
    // TODO: transform this behavior to events
    if (provisioningOperationService.count(filter) > 0) {
        SysSystemDto system = DtoUtils.getEmbedded(systemEntity, SysSystemEntity_.system);
        throw new ResultCodeException(AccResultCode.SYSTEM_ENTITY_DELETE_FAILED_HAS_OPERATIONS, ImmutableMap.of("uid", systemEntity.getUid(), "system", system.getName()));
    }
    // 
    // clear accounts - only link, can be rebuild
    AccAccountFilter accountFilter = new AccAccountFilter();
    accountFilter.setSystemEntityId(systemEntity.getId());
    accountService.find(accountFilter, null).forEach(account -> {
        account.setSystemEntity(null);
        accountService.save(account);
    });
    // 
    // clear batches
    SysProvisioningBatchDto batch = batchService.findBatch(systemEntity.getId());
    if (batch != null) {
        batchService.delete(batch);
    }
    // 
    super.deleteInternal(systemEntity);
}
Also used : SysProvisioningOperationFilter(eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter) AccAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with SysProvisioningBatchDto

use of eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto in project CzechIdMng by bcvsolutions.

the class SysProvisioningBatchController method retry.

@ResponseBody
@PreAuthorize("hasAuthority('" + AccGroupPermission.SYSTEM_ADMIN + "')")
@RequestMapping(value = "/{backendId}/retry", method = RequestMethod.PUT)
@ApiOperation(value = "Retry provisioning batch", nickname = "retryProvisioningBatch", tags = { SysProvisioningBatchController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = AccGroupPermission.SYSTEM_ADMIN, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = AccGroupPermission.SYSTEM_ADMIN, description = "") }) }, notes = "Retry all provisioning operations in given batch - retry all active operations in queue grouped by system entity ordered by incomming date.")
public ResponseEntity<?> retry(@ApiParam(value = "Provisioning batch's uuid identifier.", required = true) @PathVariable @NotNull String backendId) {
    SysProvisioningBatchDto batch = getDto(backendId);
    if (batch == null) {
        throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
    }
    provisioningExecutor.execute(batch);
    return new ResponseEntity<Void>(HttpStatus.NO_CONTENT);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) 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)

Example 14 with SysProvisioningBatchDto

use of eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto in project CzechIdMng by bcvsolutions.

the class SysProvisioningBatchController method cancel.

@ResponseBody
@PreAuthorize("hasAuthority('" + AccGroupPermission.SYSTEM_ADMIN + "')")
@RequestMapping(value = "/{backendId}/cancel", method = RequestMethod.PUT)
@ApiOperation(value = "Cance provisioning batch", nickname = "cancelProvisioningBatch", tags = { SysProvisioningBatchController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = AccGroupPermission.SYSTEM_ADMIN, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = AccGroupPermission.SYSTEM_ADMIN, description = "") }) }, notes = "Cancel all provisioning operations in given batch - cancel all active operations in queue grouped by system entity.")
public ResponseEntity<Void> cancel(@ApiParam(value = "Provisioning batch's uuid identifier.", required = true) @PathVariable @NotNull String backendId) {
    SysProvisioningBatchDto batch = getDto(backendId);
    if (batch == null) {
        throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
    }
    provisioningExecutor.cancel(batch);
    return new ResponseEntity<Void>(HttpStatus.NO_CONTENT);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) 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)

Example 15 with SysProvisioningBatchDto

use of eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto in project CzechIdMng by bcvsolutions.

the class ProvisioningBreakProcessorTest method testClearCache.

@Test
public void testClearCache() {
    SysSystemDto system = getHelper().createTestResourceSystem(true);
    IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
    createProvisioningBreak(20l, 3, null, ProvisioningEventType.UPDATE, system.getId());
    // 
    this.createAccount(system, identity);
    // 
    // create
    provisioningService.doProvisioning(identity);
    // 
    SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
    SysProvisioningBatchDto batch = batchService.findBatch(systemEntity.getId());
    List<SysProvisioningOperationDto> content = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
    // 
    provisioningService.doProvisioning(identity);
    // 
    content = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
    // 
    provisioningService.doProvisioning(identity);
    // 
    content = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
    // 
    assertTrue(content.isEmpty());
    // 
    SysBlockedOperationDto blockedOperation = new SysBlockedOperationDto();
    blockedOperation.blockUpdate();
    system.setBlockedOperation(blockedOperation);
    // block system
    system = systemService.save(system);
    // 
    blockedOperation = new SysBlockedOperationDto();
    blockedOperation.setUpdateOperation(Boolean.FALSE);
    system.setBlockedOperation(blockedOperation);
    // unblock system, clear cache
    system = systemService.save(system);
    // 
    provisioningService.doProvisioning(identity);
    provisioningService.doProvisioning(identity);
    // 
    systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
    batch = batchService.findBatch(systemEntity.getId());
    // 
    assertEquals(0, provisioningOperationService.findByBatchId(batch.getId(), null).getTotalElements());
}
Also used : SysProvisioningBatchDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto) SysBlockedOperationDto(eu.bcvsolutions.idm.acc.dto.SysBlockedOperationDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

SysProvisioningBatchDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto)24 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)16 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)15 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)14 Test (org.junit.Test)14 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)11 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)9 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)8 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)5 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)5 ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)4 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)4 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)4 SysProvisioningArchiveDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningArchiveDto)3 TestResource (eu.bcvsolutions.idm.acc.entity.TestResource)3 RetryProvisioningTaskExecutor (eu.bcvsolutions.idm.acc.scheduler.task.impl.RetryProvisioningTaskExecutor)3 DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)3 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)3 ResultModel (eu.bcvsolutions.idm.core.api.dto.ResultModel)3 UUID (java.util.UUID)3