use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method dumpOrgTree.
protected String dumpOrgTree(String topOrgOid) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class + ".assertSubOrgs");
OperationResult result = task.getResult();
PrismObject<OrgType> topOrg = modelService.getObject(OrgType.class, topOrgOid, null, task, result);
String dump = dumpOrgTree(topOrg, task, result);
result.computeStatus();
TestUtil.assertSuccess(result);
return dump;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.
the class AbstractOrgClosureTest method _test390CyclePrevention.
protected void _test390CyclePrevention() throws Exception {
OperationResult opResult = new OperationResult("===[ test390CyclePrevention ]===");
// we hope it exists
String childOid = orgsByLevels.get(1).get(0);
OrgType child = repositoryService.getObject(OrgType.class, childOid, null, opResult).asObjectable();
// we hope it exists too
ObjectReferenceType parentOrgRef = child.getParentOrgRef().get(0);
String parentOid = parentOrgRef.getOid();
System.out.println("Adding cycle-introducing link from " + parentOid + " to " + childOid);
List<ItemDelta> modifications = new ArrayList<>();
ObjectReferenceType ort = new ObjectReferenceType();
ort.setOid(childOid);
ort.setType(OrgType.COMPLEX_TYPE);
ItemDelta addParent = ReferenceDelta.createModificationAdd(OrgType.class, OrgType.F_PARENT_ORG_REF, prismContext, ort.asReferenceValue());
modifications.add(addParent);
try {
repositoryService.modifyObject(OrgType.class, parentOid, modifications, opResult);
throw new AssertionError("Cycle-introducing link from " + parentOid + " to " + childOid + " was successfully added!");
} catch (Exception e) {
// ok, expected
// would be fine to check the kind of exception...
System.out.println("Got exception (as expected): " + e);
}
checkClosure(getVertices());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.
the class PageAdminObjectDetails method loadParentOrgs.
private void loadParentOrgs(ObjectWrapper<O> wrapper, Task task, OperationResult result) {
OperationResult subResult = result.createMinorSubresult(OPERATION_LOAD_PARENT_ORGS);
PrismObject<O> focus = wrapper.getObject();
// to better handle (ignore) errors.
for (ObjectReferenceType parentOrgRef : focus.asObjectable().getParentOrgRef()) {
PrismObject<OrgType> parentOrg = null;
try {
parentOrg = getModelService().getObject(OrgType.class, parentOrgRef.getOid(), null, task, subResult);
LOGGER.trace("Loaded parent org with result {}", new Object[] { subResult.getLastSubresult() });
} catch (AuthorizationException e) {
// This can happen if the user has permission to read parentOrgRef but it does not have
// the permission to read target org
// It is OK to just ignore it.
subResult.muteLastSubresultError();
LOGGER.debug("User {} does not have permission to read parent org unit {} (ignoring error)", task.getOwner().getName(), parentOrgRef.getOid());
} catch (Exception ex) {
subResult.recordWarning("Cannot load parent org " + parentOrgRef.getOid(), ex);
LOGGER.warn("Cannot load parent org {}: {}", parentOrgRef.getOid(), ex.getMessage(), ex);
}
if (parentOrg != null) {
wrapper.getParentOrgs().add(parentOrg);
}
}
subResult.computeStatus();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.
the class RoleMemberPanel method createProjectList.
private List<OrgType> createProjectList() {
ObjectQuery query = QueryBuilder.queryFor(OrgType.class, getPrismContext()).item(OrgType.F_TENANT).eq(true).or().item(OrgType.F_TENANT).isNull().build();
List<PrismObject<OrgType>> orgs = WebModelServiceUtils.searchObjects(OrgType.class, query, new OperationResult("Tenant search"), getPageBase());
List<OrgType> orgTypes = new ArrayList<>();
for (PrismObject<OrgType> org : orgs) {
orgTypes.add(org.asObjectable());
}
return orgTypes;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType in project midpoint by Evolveum.
the class RoleMemberPanel method createDirectMemberQuery.
private ObjectQuery createDirectMemberQuery() {
ObjectQuery query;
String oid = getModelObject().getOid();
S_AtomicFilterExit q = QueryBuilder.queryFor(FocusType.class, getPrismContext()).item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(createReferenceValuesList());
DropDownChoice<OrgType> tenantChoice = (DropDownChoice) get(createComponentPath(ID_TENANT));
OrgType tenant = tenantChoice.getModelObject();
if (tenant != null) {
q = q.and().item(FocusType.F_ASSIGNMENT, AssignmentType.F_TENANT_REF).ref(createReference(tenant).asReferenceValue());
}
DropDownChoice<OrgType> projectChoice = (DropDownChoice) get(createComponentPath(ID_PROJECT));
OrgType project = projectChoice.getModelObject();
if (project != null) {
q = q.and().item(FocusType.F_ASSIGNMENT, AssignmentType.F_ORG_REF).ref(createReference(project).asReferenceValue());
}
query = q.build();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Searching members of role {} with query:\n{}", oid, query.debugDump());
}
DropDownChoice<QName> objectTypeChoice = (DropDownChoice) get(createComponentPath(ID_OBJECT_TYPE));
QName objectType = objectTypeChoice.getModelObject();
if (objectType == null || FocusType.COMPLEX_TYPE.equals(objectType)) {
return query;
} else {
return ObjectQuery.createObjectQuery(TypeFilter.createType(objectType, query.getFilter()));
}
}
Aggregations