Search in sources :

Example 6 with ObjectPolicyConfigurationType

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

the class ModelUtils method determineObjectPolicyConfiguration.

public static <O extends ObjectType> ObjectPolicyConfigurationType determineObjectPolicyConfiguration(Class<O> objectClass, List<String> objectSubtypes, SystemConfigurationType systemConfigurationType) throws ConfigurationException {
    ObjectPolicyConfigurationType applicablePolicyConfigurationType = null;
    for (ObjectPolicyConfigurationType aPolicyConfigurationType : systemConfigurationType.getDefaultObjectPolicyConfiguration()) {
        QName typeQName = aPolicyConfigurationType.getType();
        ObjectTypes objectType = ObjectTypes.getObjectTypeFromTypeQName(typeQName);
        if (objectType == null) {
            throw new ConfigurationException("Unknown type " + typeQName + " in default object policy definition in system configuration");
        }
        if (objectType.getClassDefinition() == objectClass) {
            String aSubType = aPolicyConfigurationType.getSubtype();
            if (aSubType == null) {
                if (applicablePolicyConfigurationType == null) {
                    applicablePolicyConfigurationType = aPolicyConfigurationType;
                }
            } else if (objectSubtypes != null && objectSubtypes.contains(aSubType)) {
                applicablePolicyConfigurationType = aPolicyConfigurationType;
            }
        }
    }
    if (applicablePolicyConfigurationType != null) {
        return applicablePolicyConfigurationType;
    }
    // Deprecated
    for (ObjectPolicyConfigurationType aPolicyConfigurationType : systemConfigurationType.getObjectTemplate()) {
        QName typeQName = aPolicyConfigurationType.getType();
        ObjectTypes objectType = ObjectTypes.getObjectTypeFromTypeQName(typeQName);
        if (objectType == null) {
            throw new ConfigurationException("Unknown type " + typeQName + " in object template definition in system configuration");
        }
        if (objectType.getClassDefinition() == objectClass) {
            return aPolicyConfigurationType;
        }
    }
    // Deprecated method to specify user template. For compatibility only
    if (objectClass == UserType.class) {
        ObjectReferenceType templateRef = systemConfigurationType.getDefaultUserTemplateRef();
        if (templateRef == null) {
            return null;
        }
        ObjectPolicyConfigurationType policy = new ObjectPolicyConfigurationType();
        policy.setObjectTemplateRef(templateRef.clone());
        return policy;
    }
    return null;
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectPolicyConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType) QName(javax.xml.namespace.QName) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes)

Example 7 with ObjectPolicyConfigurationType

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

the class SchemaTransformer method determineObjectTemplate.

public <O extends ObjectType> ObjectTemplateType determineObjectTemplate(PrismObject<O> object, AuthorizationPhaseType phase, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException {
    PrismObject<SystemConfigurationType> systemConfiguration = systemObjectCache.getSystemConfiguration(result);
    if (systemConfiguration == null) {
        return null;
    }
    ObjectPolicyConfigurationType objectPolicyConfiguration = ModelUtils.determineObjectPolicyConfiguration(object, systemConfiguration.asObjectable());
    if (objectPolicyConfiguration == null) {
        return null;
    }
    ObjectReferenceType objectTemplateRef = objectPolicyConfiguration.getObjectTemplateRef();
    if (objectTemplateRef == null) {
        return null;
    }
    PrismObject<ObjectTemplateType> template = cacheRepositoryService.getObject(ObjectTemplateType.class, objectTemplateRef.getOid(), null, result);
    return template.asObjectable();
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ObjectPolicyConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType) ObjectTemplateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)

Example 8 with ObjectPolicyConfigurationType

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

the class SchemaTransformer method determineObjectTemplate.

public <O extends ObjectType> ObjectTemplateType determineObjectTemplate(Class<O> objectClass, AuthorizationPhaseType phase, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException {
    PrismObject<SystemConfigurationType> systemConfiguration = systemObjectCache.getSystemConfiguration(result);
    if (systemConfiguration == null) {
        return null;
    }
    ObjectPolicyConfigurationType objectPolicyConfiguration = ModelUtils.determineObjectPolicyConfiguration(objectClass, null, systemConfiguration.asObjectable());
    if (objectPolicyConfiguration == null) {
        return null;
    }
    ObjectReferenceType objectTemplateRef = objectPolicyConfiguration.getObjectTemplateRef();
    if (objectTemplateRef == null) {
        return null;
    }
    PrismObject<ObjectTemplateType> template = cacheRepositoryService.getObject(ObjectTemplateType.class, objectTemplateRef.getOid(), null, result);
    return template.asObjectable();
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ObjectPolicyConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType) ObjectTemplateType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)

Aggregations

ObjectPolicyConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectPolicyConfigurationType)7 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)4 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3 ObjectTemplateType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateType)3 NoFocusNameSchemaException (com.evolveum.midpoint.util.exception.NoFocusNameSchemaException)2 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)1 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 ExpressionVariables (com.evolveum.midpoint.repo.common.expression.ExpressionVariables)1 ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 AppenderConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.AppenderConfigurationType)1 AssignmentPolicyEnforcementType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType)1 ClassLoggerConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType)1 CleanupPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.CleanupPolicyType)1