Search in sources :

Example 61 with OrgType

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;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 62 with OrgType

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());
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 63 with OrgType

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();
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AuthorizationException(com.evolveum.midpoint.util.exception.AuthorizationException) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AuthorizationException(com.evolveum.midpoint.util.exception.AuthorizationException) RestartResponseException(org.apache.wicket.RestartResponseException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) SystemException(com.evolveum.midpoint.util.exception.SystemException)

Example 64 with OrgType

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;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 65 with OrgType

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()));
    }
}
Also used : DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) QName(javax.xml.namespace.QName) S_AtomicFilterExit(com.evolveum.midpoint.prism.query.builder.S_AtomicFilterExit) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Aggregations

OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)123 Test (org.testng.annotations.Test)70 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)69 Task (com.evolveum.midpoint.task.api.Task)69 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)31 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)26 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)23 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)22 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)15 PrismObject (com.evolveum.midpoint.prism.PrismObject)13 ArrayList (java.util.ArrayList)13 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)11 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)11 Entry (org.opends.server.types.Entry)10 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)9 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)8 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)8 QName (javax.xml.namespace.QName)8 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)7 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)7