use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class IdentityByTreeNodeEvaluatorIntegrationTest method testSubpositionMoreContract.
@Test
public void testSubpositionMoreContract() {
IdmTreeNodeDto parent = getHelper().createTreeNode();
IdmTreeNodeDto parentTwo = getHelper().createTreeNode(getHelper().createName(), parent);
IdmTreeNodeDto position = getHelper().createTreeNode(getHelper().createName(), parentTwo);
// Evaluator is on parentTwo
IdmRoleDto role = prepareRoleWithEvaluator(parentTwo);
// Position is sub child
IdmIdentityDto identity = prepareIdentityOnWorkPosition(parent);
IdmIdentityDto administrator = getHelper().createIdentity();
try {
getHelper().login(administrator);
List<IdmIdentityDto> users = identityService.find(null, IdmBasePermission.READ).getContent();
// only myself
assertEquals(0, users.size());
checkIdentityInList(identity, users, false);
} finally {
getHelper().logout();
}
getHelper().assignRoles(getHelper().getPrimeContract(administrator), role);
try {
getHelper().login(administrator);
List<IdmIdentityDto> users = identityService.find(null, IdmBasePermission.READ).getContent();
assertEquals(0, users.size());
checkIdentityInList(identity, users, false);
} finally {
getHelper().logout();
}
IdmIdentityContractDto newContract = getHelper().createContract(identity, position);
try {
getHelper().login(administrator);
List<IdmIdentityDto> users = identityService.find(null, IdmBasePermission.READ).getContent();
assertEquals(1, users.size());
checkIdentityInList(identity, users, true);
} finally {
getHelper().logout();
}
identityContractService.delete(newContract);
try {
getHelper().login(administrator);
List<IdmIdentityDto> users = identityService.find(null, IdmBasePermission.READ).getContent();
assertEquals(0, users.size());
checkIdentityInList(identity, users, false);
} finally {
getHelper().logout();
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class IdentityByTreeNodeEvaluatorIntegrationTest method testSubpositionOnContract.
@Test
public void testSubpositionOnContract() {
IdmTreeNodeDto parent = getHelper().createTreeNode();
IdmTreeNodeDto parentTwo = getHelper().createTreeNode(getHelper().createName(), parent);
IdmTreeNodeDto position = getHelper().createTreeNode(getHelper().createName(), parentTwo);
// Evaluator is on parent
IdmRoleDto role = prepareRoleWithEvaluator(parent);
// Position is sub child
IdmIdentityDto identity = prepareIdentityOnWorkPosition(position);
IdmIdentityDto administrator = getHelper().createIdentity();
try {
getHelper().login(administrator);
List<IdmIdentityDto> users = identityService.find(null, IdmBasePermission.READ).getContent();
// only myself
assertEquals(0, users.size());
checkIdentityInList(identity, users, false);
} finally {
getHelper().logout();
}
getHelper().assignRoles(getHelper().getPrimeContract(administrator), role);
try {
getHelper().login(administrator);
List<IdmIdentityDto> users = identityService.find(null, IdmBasePermission.READ).getContent();
assertEquals(1, users.size());
checkIdentityInList(identity, users, true);
} finally {
getHelper().logout();
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class IdentityByTreeNodeEvaluatorIntegrationTest method testOneContract.
@Test
public void testOneContract() {
IdmTreeNodeDto position = getHelper().createTreeNode();
IdmRoleDto role = prepareRoleWithEvaluator(position);
IdmIdentityDto identity = prepareIdentityOnWorkPosition(position);
IdmIdentityDto administrator = getHelper().createIdentity();
try {
getHelper().login(administrator);
List<IdmIdentityDto> users = identityService.find(null, IdmBasePermission.READ).getContent();
// only myself
assertEquals(0, users.size());
checkIdentityInList(identity, users, false);
} finally {
getHelper().logout();
}
getHelper().assignRoles(getHelper().getPrimeContract(administrator), role);
try {
getHelper().login(administrator);
List<IdmIdentityDto> users = identityService.find(null, IdmBasePermission.READ).getContent();
assertEquals(1, users.size());
checkIdentityInList(identity, users, true);
} finally {
getHelper().logout();
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class TreeSynchronizationExecutor method doDeleteEntity.
/**
* Delete entity linked with given account
*
* @param account
* @param entityType
* @param log
* @param logItem
* @param actionLogs
*/
@Override
protected void doDeleteEntity(AccAccountDto account, SystemEntityType entityType, SysSyncLogDto log, SysSyncItemLogDto logItem, List<SysSyncActionLogDto> actionLogs) {
IdmTreeNodeDto treeNode = this.getDtoByAccount(null, account);
if (treeNode == null) {
addToItemLog(logItem, "Warning! - Tree node was not found and cannot be deleted (maybe was deleted within deleting of parent node).");
initSyncActionLog(SynchronizationActionType.DELETE_ENTITY, OperationResultType.WARNING, logItem, log, actionLogs);
return;
}
logItem.setDisplayName(treeNode.getName());
// Delete entity (recursively)
deleteChildrenRecursively(treeNode, logItem);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class TreeSynchronizationExecutor method getValueByMappedAttribute.
@Override
protected Object getValueByMappedAttribute(AttributeMapping attribute, List<IcAttribute> icAttributes, SynchronizationContext context) {
Object transformedValue = super.getValueByMappedAttribute(attribute, icAttributes, context);
if (transformedValue != null && PARENT_FIELD.equals(attribute.getIdmPropertyName())) {
String parentUid = transformedValue.toString();
SysSystemMappingDto systemMapping = systemMappingService.get(((SysSystemAttributeMappingDto) attribute).getSystemMapping());
try {
UUID parentUUID = UUID.fromString(parentUid);
IdmTreeNodeDto parentNode = treeNodeService.get(parentUUID);
if (parentNode != null) {
if (!systemMapping.getTreeType().equals(parentNode.getTreeType())) {
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_TREE_PARENT_NODE_IS_NOT_FROM_SAME_TREE_TYPE, ImmutableMap.of("parentNode", parentNode.getCode(), "systemId", context.getSystem().getName()));
}
addToItemLog(context.getLogItem(), MessageFormat.format("Transformed value from the parent attribute contains the UUID of idmTreeNode [{0}].", parentNode.getCode()));
return parentNode.getId();
}
} catch (IllegalArgumentException ex) {
// OK this is not UUID of tree node
addToItemLog(context.getLogItem(), MessageFormat.format("Parent value [{0}] is not UUID of a tree node.", parentUid));
}
SysSchemaObjectClassDto schemaObjectClass = schemaObjectClassService.get(systemMapping.getObjectClass());
UUID systemId = schemaObjectClass.getSystem();
// Find account by UID from parent field
AccAccountFilter accountFilter = new AccAccountFilter();
accountFilter.setUid(parentUid);
accountFilter.setSystemId(systemId);
List<AccAccountDto> parentAccounts = accountService.find(accountFilter, null).getContent();
if (!parentAccounts.isEmpty()) {
UUID parentAccount = parentAccounts.get(0).getId();
// Find relation between tree and account
AccTreeAccountFilter treeAccountFilter = new AccTreeAccountFilter();
treeAccountFilter.setAccountId(parentAccount);
List<AccTreeAccountDto> treeAccounts = treeAccountService.find(treeAccountFilter, null).getContent();
if (!treeAccounts.isEmpty()) {
// Find parent tree node by ID
// TODO: resolve more treeAccounts situations
// parent uuid - we are working with dtos
transformedValue = treeAccounts.get(0).getTreeNode();
} else {
LOG.warn("For parent UID: [{}] on system ID [{}] and acc account: [{}], was not found tree accounts! Return null value in parent!!", parentUid, systemId, parentAccount);
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_TREE_PARENT_TREE_ACCOUNT_NOT_FOUND, ImmutableMap.of("parentUid", parentUid, "systemId", systemId, "parentAccount", parentAccount));
}
} else {
LOG.warn("For parent UID: [{}] on system ID [{}], was not found parents account! Return null value in parent!!", parentUid, systemId);
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_TREE_PARENT_ACCOUNT_NOT_FOUND, ImmutableMap.of("parentUid", parentUid, "systemId", systemId));
}
}
return transformedValue;
}
Aggregations