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());
}
}
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);
}
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);
}
Aggregations