use of eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter in project CzechIdMng by bcvsolutions.
the class AbstractSynchronizationExecutor method startReconciliation.
/**
* Start reconciliation. Is call after synchronization. Main purpose is find and
* resolve missing accounts
*
* @param entityType
* @param allAccountsSet
* @param config
* @param system
* @param log
* @param actionsLog
*/
protected void startReconciliation(SystemEntityType entityType, Set<String> allAccountsSet, AbstractSysSyncConfigDto config, SysSystemDto system, SysSyncLogDto log, List<SysSyncActionLogDto> actionsLog) {
if (!log.isRunning()) {
return;
}
AccAccountFilter accountFilter = new AccAccountFilter();
accountFilter.setSystemId(system.getId());
List<AccAccountDto> accounts = accountService.find(accountFilter, null).getContent();
for (AccAccountDto account : accounts) {
if (!log.isRunning()) {
return;
}
String uid = account.getRealUid();
if (!allAccountsSet.contains(uid)) {
SysSyncItemLogDto itemLog = new SysSyncItemLogDto();
try {
// Default setting for log item
itemLog.setIdentification(uid);
itemLog.setDisplayName(uid);
itemLog.setType(entityType.getEntityType().getSimpleName());
// Do reconciliation for one item (produces event)
// Start in new Transaction
SynchronizationContext builder = new SynchronizationContext();
builder.addUid(uid).addType(IcSyncDeltaTypeEnum.DELETE).addConfig(config).addSystem(system).addEntityType(entityType).addAccount(account).addLog(log).addLogItem(itemLog).addActionLogs(actionsLog);
CoreEvent<SysSyncItemLogDto> event = new CoreEvent<>(SynchronizationEventType.START_ITEM, itemLog);
event.getProperties().put(SynchronizationService.WRAPPER_SYNC_ITEM, builder);
EventResult<SysSyncItemLogDto> lastResult = entityEventManager.process(event).getLastResult();
boolean result = false;
if (lastResult != null && lastResult.getEvent().getProperties().containsKey(SynchronizationService.RESULT_SYNC_ITEM)) {
result = (boolean) lastResult.getEvent().getProperties().get(SynchronizationService.RESULT_SYNC_ITEM);
}
// Update (increased counter) and check state of sync (maybe was cancelled from
// sync or LRT)
updateAndCheckState(result, log);
} catch (Exception ex) {
String message = MessageFormat.format("Reconciliation - error for uid [{0}]", uid);
log.addToLog(message);
log.addToLog(Throwables.getStackTraceAsString(ex));
LOG.error(message, ex);
} finally {
config = synchronizationConfigService.save(config);
boolean existingItemLog = existItemLogInActions(actionsLog, itemLog);
actionsLog = saveActionLogs(actionsLog, log.getId());
//
if (!existingItemLog) {
addToItemLog(itemLog, MessageFormat.format("Missing action log for UID [{0}]!", uid));
initSyncActionLog(SynchronizationActionType.UNKNOWN, OperationResultType.ERROR, itemLog, log, actionsLog);
syncItemLogService.save(itemLog);
}
}
}
}
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter in project CzechIdMng by bcvsolutions.
the class DefaultPasswordFilterManager method getAccountsForPasswordChange.
/**
* Return accounts that exists in given uniform password definitions. Second parameter supportPasswordFilter
* return only managed system with password filter (echo support).
*
* @param passwordDefinitions
* @param identityId
* @param supportPasswordFilter
* @return
*/
private List<AccAccountDto> getAccountsForPasswordChange(List<AccUniformPasswordDto> passwordDefinitions, UUID identityId, Boolean supportPasswordFilter) {
Assert.notNull(identityId, "Identity cannot be null!");
List<AccAccountDto> accounts = Lists.newArrayList();
AccAccountFilter filter = new AccAccountFilter();
filter.setSupportPasswordFilter(supportPasswordFilter);
filter.setIdentityId(identityId);
for (AccUniformPasswordDto definition : passwordDefinitions) {
filter.setUniformPasswordId(definition.getId());
accounts.addAll(accountService.find(filter, null).getContent());
}
return accounts;
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter in project CzechIdMng by bcvsolutions.
the class DefaultAccAccountService method getAccount.
@Override
public AccAccountDto getAccount(String uid, UUID systemId) {
Assert.notNull(uid, "UID cannot be null!");
Assert.notNull(systemId, "System ID cannot be null!");
AccAccountFilter filter = new AccAccountFilter();
filter.setUid(uid);
filter.setSystemId(systemId);
List<AccAccountDto> accounts = this.find(filter, null).getContent();
if (accounts.isEmpty()) {
return null;
}
return accounts.get(0);
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter in project CzechIdMng by bcvsolutions.
the class AbstractProvisioningExecutor method getAccountSystemEntity.
protected AccAccountDto getAccountSystemEntity(UUID systemEntity) {
AccAccountFilter filter = new AccAccountFilter();
filter.setSystemEntityId(systemEntity);
List<AccAccountDto> accounts = this.accountService.find(filter, null).getContent();
if (accounts.isEmpty()) {
return null;
} else {
// We assume that system entity has only one account!
return accounts.get(0);
}
}
use of eu.bcvsolutions.idm.acc.dto.filter.AccAccountFilter in project CzechIdMng by bcvsolutions.
the class AbstractProvisioningProcessor method getAccounts.
/**
* Get accounts for system id and system edntity id
*
* @param systemId
* @param systemEntityId
* @return
*/
private List<UUID> getAccounts(UUID systemId, UUID systemEntityId) {
AccAccountFilter filter = new AccAccountFilter();
filter.setSystemEntityId(systemEntityId);
filter.setEntityType(SystemEntityType.IDENTITY);
filter.setSystemId(systemId);
return accountService.findIds(filter, null).getContent();
}
Aggregations