Search in sources :

Example 1 with VsAccountFilter

use of eu.bcvsolutions.idm.vs.dto.filter.VsAccountFilter in project CzechIdMng by bcvsolutions.

the class BasicVirtualConnector method searchByPage.

/**
 * Do search for given page and invoke result handler
 *
 * @param handler
 * @param pageable
 */
private void searchByPage(IcResultsHandler handler, Pageable pageable) {
    VsAccountFilter accountFilter = new VsAccountFilter();
    accountFilter.setSystemId(systemId);
    Page<VsAccountDto> resultsPage = accountService.find(accountFilter, pageable);
    List<VsAccountDto> results = resultsPage.getContent();
    results.forEach(account -> {
        boolean canContinue = handler.handle(this.read(new IcUidAttributeImpl(IcAttributeInfo.NAME, account.getUid(), null), new IcObjectClassImpl(IcObjectClassInfo.ACCOUNT)));
        if (!canContinue) {
            // Handler stop next searching
            return;
        }
    });
    if (resultsPage.hasNext()) {
        this.searchByPage(handler, resultsPage.nextPageable());
    }
}
Also used : IcObjectClassImpl(eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl) IcUidAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcUidAttributeImpl) VsAccountDto(eu.bcvsolutions.idm.vs.dto.VsAccountDto) VsAccountFilter(eu.bcvsolutions.idm.vs.dto.filter.VsAccountFilter)

Example 2 with VsAccountFilter

use of eu.bcvsolutions.idm.vs.dto.filter.VsAccountFilter in project CzechIdMng by bcvsolutions.

the class SystemDeleteProcessor method process.

@Override
public EventResult<SysSystemDto> process(EntityEvent<SysSystemDto> event) {
    SysSystemDto system = event.getContent();
    Assert.notNull(system);
    // 
    // If exists unresolved vs request, then is not possible to delete
    // system
    VsRequestFilter requestFilter = new VsRequestFilter();
    requestFilter.setSystemId(system.getId());
    requestFilter.setState(VsRequestState.IN_PROGRESS);
    if (requestService.find(requestFilter, null).getTotalElements() > 0) {
        throw new ResultCodeException(VsResultCode.VS_SYSTEM_DELETE_FAILED_HAS_REQUEST, ImmutableMap.of("system", system.getName()));
    }
    // Delete archived vs requests
    requestFilter = new VsRequestFilter();
    requestFilter.setSystemId(system.getId());
    requestFilter.setOnlyArchived(Boolean.TRUE);
    requestService.find(requestFilter, null).forEach(entity -> {
        requestService.delete(entity);
    });
    // Delete vs account
    VsAccountFilter accountFilter = new VsAccountFilter();
    accountFilter.setSystemId(system.getId());
    accountService.find(accountFilter, null).forEach(entity -> {
        accountService.delete(entity);
    });
    // Delete vs account form definition
    if (system.getConnectorKey() != null) {
        String virtualSystemKey = MessageFormat.format("{0}:systemId={1}", system.getConnectorKey().getFullName(), system.getId());
        IdmFormDefinitionDto definition = this.formDefinitionService.findOneByTypeAndCode(VsAccount.class.getName(), virtualSystemKey);
        if (definition != null) {
            formDefinitionService.delete(definition);
        }
    }
    // Delete vs implementers
    VsSystemImplementerFilter implementerFilter = new VsSystemImplementerFilter();
    implementerFilter.setSystemId(system.getId());
    systemImplementerService.find(implementerFilter, null).forEach(entity -> {
        systemImplementerService.delete(entity);
    });
    return new DefaultEventResult<>(event, this);
}
Also used : VsAccount(eu.bcvsolutions.idm.vs.entity.VsAccount) VsSystemImplementerFilter(eu.bcvsolutions.idm.vs.dto.filter.VsSystemImplementerFilter) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) VsAccountFilter(eu.bcvsolutions.idm.vs.dto.filter.VsAccountFilter) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) VsRequestFilter(eu.bcvsolutions.idm.vs.dto.filter.VsRequestFilter) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 3 with VsAccountFilter

use of eu.bcvsolutions.idm.vs.dto.filter.VsAccountFilter in project CzechIdMng by bcvsolutions.

the class DefaultVsAccountService method findByUidSystem.

@Override
public VsAccountDto findByUidSystem(String uidValue, UUID systemId) {
    Assert.notNull(uidValue, "Uid value cannot be null!");
    Assert.notNull(systemId, "Id of CzechIdM system cannot be null!");
    VsAccountFilter filter = new VsAccountFilter();
    filter.setUid(uidValue);
    filter.setSystemId(systemId);
    List<VsAccountDto> accounts = this.find(filter, null).getContent();
    if (accounts.size() > 1) {
        throw new IcException(MessageFormat.format("To many vs accounts for uid [{0}] and system [{1}]!", uidValue, systemId));
    }
    return accounts.isEmpty() ? null : accounts.get(0);
}
Also used : VsAccountDto(eu.bcvsolutions.idm.vs.dto.VsAccountDto) VsAccountFilter(eu.bcvsolutions.idm.vs.dto.filter.VsAccountFilter) IcException(eu.bcvsolutions.idm.ic.exception.IcException)

Aggregations

VsAccountFilter (eu.bcvsolutions.idm.vs.dto.filter.VsAccountFilter)3 VsAccountDto (eu.bcvsolutions.idm.vs.dto.VsAccountDto)2 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)1 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)1 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)1 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)1 IcException (eu.bcvsolutions.idm.ic.exception.IcException)1 IcObjectClassImpl (eu.bcvsolutions.idm.ic.impl.IcObjectClassImpl)1 IcUidAttributeImpl (eu.bcvsolutions.idm.ic.impl.IcUidAttributeImpl)1 VsRequestFilter (eu.bcvsolutions.idm.vs.dto.filter.VsRequestFilter)1 VsSystemImplementerFilter (eu.bcvsolutions.idm.vs.dto.filter.VsSystemImplementerFilter)1 VsAccount (eu.bcvsolutions.idm.vs.entity.VsAccount)1