use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter in project CzechIdMng by bcvsolutions.
the class SysSystemEntityController method toFilter.
@Override
protected SysSystemEntityFilter toFilter(MultiValueMap<String, Object> parameters) {
SysSystemEntityFilter filter = new SysSystemEntityFilter();
filter.setText(getParameterConverter().toString(parameters, "text"));
filter.setSystemId(getParameterConverter().toUuid(parameters, "systemId"));
filter.setEntityType(getParameterConverter().toEnum(parameters, "entityType", SystemEntityType.class));
filter.setUid(getParameterConverter().toString(parameters, "uid"));
return filter;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter in project CzechIdMng by bcvsolutions.
the class BasicVirtualConnector method updateSystemEntity.
/**
* We have to change system entity directly from VS module (request can be
* started/executed async => standard process update UID in system entity (ACC
* module) will not works!)
*
* @param uidValue
* @param attributeUidValue
* @param systemEntityMustExists
*/
private void updateSystemEntity(String uidValue, Object attributeUidValue, boolean systemEntityMustExists) {
SysSystemEntityFilter systemEntityFilter = new SysSystemEntityFilter();
systemEntityFilter.setUid(uidValue);
systemEntityFilter.setSystemId(systemId);
List<SysSystemEntityDto> systemEntities = systemEntityService.find(systemEntityFilter, null).getContent();
if (systemEntities.isEmpty() && !systemEntityMustExists) {
return;
}
if (systemEntities.isEmpty()) {
throw new IcException(MessageFormat.format("System entity was not found for UID [{0}] and system ID [{1}]! Change UID attribute (new [{2}]) cannot be executed!", uidValue, systemId, attributeUidValue));
}
if (systemEntities.size() > 1) {
throw new IcException(MessageFormat.format("For UID [{0}] and system ID [{1}] was found too many items [{2}]! Change UID attribute (new [{3}]) cannot be executed!", uidValue, systemId, systemEntities.size(), attributeUidValue));
}
SysSystemEntityDto systemEntity = systemEntities.get(0);
systemEntity.setUid((String) attributeUidValue);
systemEntity.setWish(false);
// Save changed system entity
systemEntityService.save(systemEntity);
LOG.info("Update account - UID was changed (old: {} new: {}). System entity was updated.", uidValue, attributeUidValue);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter in project CzechIdMng by bcvsolutions.
the class RoleSynchronizationExecutor method assignMissingIdentityRoles.
/**
* Assign missing identity roles.
*/
private void assignMissingIdentityRoles(IdmRoleDto roleDto, SysSyncRoleConfigDto config, SysSyncItemLogDto logItem, List<IdmIdentityRoleDto> existsIdentityRoleDtos, Set<UUID> membersContractIds, SysSystemDto userSystemDto, int[] count, String uid, SynchronizationContext context) {
// On every 20th item will be hibernate flushed and check if sync was not ended.
if (count[0] % 20 == 0 && count[0] > 0) {
if (!checkForCancelAndFlush(config)) {
return;
}
}
count[0]++;
// Need to find account using SysSystemEntityDto uid, because uid of AccAccountDto can be different.
SysSystemEntityFilter entityFilter = new SysSystemEntityFilter();
entityFilter.setEntityType(SystemEntityType.IDENTITY);
entityFilter.setSystemId(userSystemDto.getId());
entityFilter.setUid(uid);
SysSystemEntityDto systemEntity = systemEntityService.find(entityFilter, null).stream().findFirst().orElse(null);
if (systemEntity == null) {
return;
}
AccAccountFilter accAccountFilter = new AccAccountFilter();
accAccountFilter.setSystemEntityId(systemEntity.getId());
final UUID accAccountId = accountService.findIds(accAccountFilter, null).stream().findFirst().orElse(null);
if (accAccountId == null) {
return;
}
AccIdentityAccountFilter identityAccountWithoutRelationFilter = new AccIdentityAccountFilter();
identityAccountWithoutRelationFilter.setAccountId(accAccountId);
AccIdentityAccountDto identityAccountDto = identityAccountService.find(identityAccountWithoutRelationFilter, null).getContent().stream().findFirst().orElse(null);
if (identityAccountDto == null) {
return;
}
UUID identityId = identityAccountDto.getIdentity();
IdmIdentityContractDto primeContract = identityContractService.getPrimeContract(identityId);
if (primeContract == null) {
addToItemLog(logItem, MessageFormat.format("!!Role was not assigned to the user [{0}], because primary contract was not found!!", uid));
initSyncActionLog(SynchronizationActionType.UPDATE_ENTITY, OperationResultType.WARNING, logItem, context.getLog(), context.getActionLogs());
return;
}
membersContractIds.add(primeContract.getId());
IdmIdentityRoleDto existIdentityRoleDto = existsIdentityRoleDtos.stream().filter(identityRole -> primeContract.getId().equals(identityRole.getIdentityContract())).findFirst().orElse(null);
if (existIdentityRoleDto != null) {
// Identity already has the role.
return;
}
addToItemLog(logItem, MessageFormat.format("Role is not assigned for user [{0}] and contract [{1}]. Role request for add role will be created.", uid, primeContract.getId()));
// Get cache with role-requests by identity-contract.
Map<UUID, UUID> roleRequestCache = getRoleRequestCache();
// Get role-request for the primary contract from a cache. If no request is present, then create one.
initRoleRequest(primeContract, roleRequestCache, config);
UUID roleRequestId = roleRequestCache.get(primeContract.getId());
IdmRoleRequestDto mockRoleRequest = new IdmRoleRequestDto();
mockRoleRequest.setId(roleRequestId);
// Create a concept for assign a role to primary contract.
roleRequestService.createConcept(mockRoleRequest, primeContract, null, roleDto.getId(), ConceptRoleRequestOperation.ADD);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemEntityServiceFilterTest method testSystemId.
@Test
public void testSystemId() {
SysSystemDto system1 = helper.createTestResourceSystem(false);
SysSystemDto system2 = helper.createTestResourceSystem(false);
createEntitySystem("test1-" + System.currentTimeMillis(), SystemEntityType.CONTRACT, system1.getId(), UUID.randomUUID());
SysSystemEntityDto entity2 = createEntitySystem("test2-" + System.currentTimeMillis(), SystemEntityType.CONTRACT, system2.getId(), UUID.randomUUID());
createEntitySystem("test3-" + System.currentTimeMillis(), SystemEntityType.CONTRACT, system2.getId(), UUID.randomUUID());
//
SysSystemEntityFilter testFilter = new SysSystemEntityFilter();
testFilter.setSystemId(system2.getId());
Page<SysSystemEntityDto> pages = entityService.find(testFilter, null);
assertEquals(2, pages.getTotalElements());
SysSystemEntityDto foundedSystem = pages.getContent().stream().filter(sys -> sys.getId().equals(entity2.getId())).findAny().get();
assertNotNull(foundedSystem);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemEntityServiceFilterTest method testEntityType.
@Test
public void testEntityType() {
SysSystemDto system = helper.createTestResourceSystem(false);
createEntitySystem("test1-" + System.currentTimeMillis(), SystemEntityType.ROLE, system.getId(), UUID.randomUUID());
SysSystemEntityDto entity2 = createEntitySystem("test2-" + System.currentTimeMillis(), SystemEntityType.TREE, system.getId(), UUID.randomUUID());
createEntitySystem("tes3t-" + System.currentTimeMillis(), SystemEntityType.IDENTITY, system.getId(), UUID.randomUUID());
//
SysSystemEntityFilter testFilter = new SysSystemEntityFilter();
testFilter.setEntityType(entity2.getEntityType());
testFilter.setUid(entity2.getUid());
Page<SysSystemEntityDto> pages = entityService.find(testFilter, null);
assertEquals(1, pages.getTotalElements());
assertEquals(entity2.getId(), pages.getContent().get(0).getId());
}
Aggregations