Search in sources :

Example 91 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method createExclusionPolicyRule.

protected PolicyRuleType createExclusionPolicyRule(String excludedRoleOid) {
    PolicyRuleType policyRule = new PolicyRuleType();
    PolicyConstraintsType policyConstraints = new PolicyConstraintsType();
    ExclusionPolicyConstraintType exclusionConstraint = new ExclusionPolicyConstraintType();
    ObjectReferenceType targetRef = new ObjectReferenceType();
    targetRef.setOid(excludedRoleOid);
    targetRef.setType(RoleType.COMPLEX_TYPE);
    exclusionConstraint.setTargetRef(targetRef);
    policyConstraints.getExclusion().add(exclusionConstraint);
    policyRule.setPolicyConstraints(policyConstraints);
    return policyRule;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)

Example 92 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method getLiveLinkRef.

protected <F extends FocusType> PrismReferenceValue getLiveLinkRef(PrismObject<F> focus, String resourceOid) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    F focusType = focus.asObjectable();
    for (ObjectReferenceType linkRefType : focusType.getLinkRef()) {
        if (!relationRegistry.isMember(linkRefType.getRelation())) {
            continue;
        }
        String linkTargetOid = linkRefType.getOid();
        assertFalse("No linkRef oid", StringUtils.isBlank(linkTargetOid));
        PrismObject<ShadowType> account = getShadowModel(linkTargetOid, GetOperationOptions.createNoFetch(), false);
        if (resourceOid.equals(account.asObjectable().getResourceRef().getOid())) {
            // This is noFetch. Therefore there is no fetchResult
            return linkRefType.asReferenceValue();
        }
    }
    AssertJUnit.fail("Account for resource " + resourceOid + " not found in " + focus);
    // Never reached. But compiler complains about missing return
    return null;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 93 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method unassignAllRoles.

protected void unassignAllRoles(String userOid, boolean useRawPlusRecompute) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException {
    Task task = createPlainTask("unassignAllRoles");
    OperationResult result = task.getResult();
    PrismObject<UserType> user = modelService.getObject(UserType.class, userOid, null, task, result);
    Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
    for (AssignmentType assignment : user.asObjectable().getAssignment()) {
        ObjectReferenceType targetRef = assignment.getTargetRef();
        if (targetRef != null) {
            if (targetRef.getType().equals(RoleType.COMPLEX_TYPE)) {
                ContainerDelta<AssignmentType> assignmentDelta = prismContext.deltaFactory().container().createDelta(UserType.F_ASSIGNMENT, getUserDefinition());
                PrismContainerValue<AssignmentType> cval = prismContext.itemFactory().createContainerValue();
                cval.setId(assignment.getId());
                assignmentDelta.addValueToDelete(cval);
                modifications.add(assignmentDelta);
            }
        }
    }
    if (modifications.isEmpty()) {
        return;
    }
    ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createModifyDelta(userOid, modifications, UserType.class);
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(userDelta);
    modelService.executeChanges(deltas, useRawPlusRecompute ? executeOptions().raw() : null, task, result);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    if (useRawPlusRecompute) {
        recomputeUser(userOid, task, result);
        result.computeStatus();
        TestUtil.assertSuccess(result);
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)

Example 94 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method createModifyUserAddAccount.

protected ObjectDelta<UserType> createModifyUserAddAccount(String userOid, PrismObject<ResourceType> resource, String intent) throws SchemaException {
    PrismObject<ShadowType> account = getAccountShadowDefinition().instantiate();
    ObjectReferenceType resourceRef = new ObjectReferenceType();
    resourceRef.setOid(resource.getOid());
    account.asObjectable().setResourceRef(resourceRef);
    ResourceSchema refinedSchema = ResourceSchemaFactory.getCompleteSchema(resource);
    ResourceObjectDefinition rocd;
    if (StringUtils.isNotBlank(intent)) {
        rocd = refinedSchema.findObjectDefinitionRequired(ShadowKindType.ACCOUNT, intent);
        account.asObjectable().setIntent(intent);
    } else {
        // TODO or findObjectDefinitionRequired as well?
        rocd = refinedSchema.findDefaultOrAnyObjectTypeDefinition(ShadowKindType.ACCOUNT);
    }
    account.asObjectable().setObjectClass(rocd.getObjectClassDefinition().getTypeName());
    account.asObjectable().setKind(ShadowKindType.ACCOUNT);
    ObjectDelta<UserType> userDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid);
    PrismReferenceValue accountRefVal = itemFactory().createReferenceValue();
    accountRefVal.setObject(account);
    ReferenceDelta accountDelta = prismContext.deltaFactory().reference().createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal);
    userDelta.addModification(accountDelta);
    return userDelta;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)

Example 95 with ObjectReferenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.

the class AbstractModelIntegrationTest method setConflictResolution.

protected void setConflictResolution(QName objectType, String subType, ConflictResolutionType conflictResolution, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException {
    PrismObject<SystemConfigurationType> systemConfig = repositoryService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, parentResult);
    PrismContainerValue<ObjectPolicyConfigurationType> oldValue = null;
    for (ObjectPolicyConfigurationType focusPolicyType : systemConfig.asObjectable().getDefaultObjectPolicyConfiguration()) {
        if (QNameUtil.match(objectType, focusPolicyType.getType()) && MiscUtil.equals(subType, focusPolicyType.getSubtype())) {
            oldValue = focusPolicyType.asPrismContainerValue();
        }
    }
    Collection<ContainerDelta<ObjectPolicyConfigurationType>> modifications = new ArrayList<>();
    if (oldValue != null) {
        ContainerDelta<ObjectPolicyConfigurationType> deleteDelta = prismContext.deltaFactory().container().createModificationDelete(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, SystemConfigurationType.class, oldValue.clone());
        modifications.add(deleteDelta);
    }
    ObjectPolicyConfigurationType newFocusPolicyType = new ObjectPolicyConfigurationType();
    newFocusPolicyType.setType(objectType);
    newFocusPolicyType.setSubtype(subType);
    if (oldValue != null) {
        ObjectReferenceType oldObjectTemplateRef = oldValue.asContainerable().getObjectTemplateRef();
        if (oldObjectTemplateRef != null) {
            newFocusPolicyType.setObjectTemplateRef(oldObjectTemplateRef.clone());
        }
    }
    newFocusPolicyType.setConflictResolution(conflictResolution);
    ContainerDelta<ObjectPolicyConfigurationType> addDelta = prismContext.deltaFactory().container().createModificationAdd(SystemConfigurationType.F_DEFAULT_OBJECT_POLICY_CONFIGURATION, SystemConfigurationType.class, newFocusPolicyType);
    modifications.add(addDelta);
    modifySystemObjectInRepo(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), modifications, parentResult);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)

Aggregations

ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)278 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)104 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)61 Test (org.testng.annotations.Test)61 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)56 Task (com.evolveum.midpoint.task.api.Task)53 QName (javax.xml.namespace.QName)46 ArrayList (java.util.ArrayList)44 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)42 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)37 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)33 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)32 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)32 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)31 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)30 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)30 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)26 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)26 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)23 List (java.util.List)23