Search in sources :

Example 26 with RefinedAttributeDefinition

use of com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition in project midpoint by Evolveum.

the class AccessChecker method checkAdd.

public void checkAdd(ProvisioningContext ctx, PrismObject<ShadowType> shadow, OperationResult parentResult) throws SchemaException, SecurityViolationException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException {
    OperationResult result = parentResult.createMinorSubresult(OPERATION_NAME);
    ResourceAttributeContainer attributeCont = ShadowUtil.getAttributesContainer(shadow);
    for (ResourceAttribute<?> attribute : attributeCont.getAttributes()) {
        RefinedAttributeDefinition attrDef = ctx.getObjectClassDefinition().findAttributeDefinition(attribute.getElementName());
        // schema layer is the original one.
        if (attrDef == null) {
            String msg = "No definition for attribute " + attribute.getElementName() + " in " + ctx.getObjectClassDefinition();
            result.recordFatalError(msg);
            throw new SchemaException(msg);
        }
        PropertyLimitations limitations = attrDef.getLimitations(LayerType.MODEL);
        if (limitations == null) {
            continue;
        }
        // We cannot throw error here. At least not now. Provisioning will internally use ignored attributes
        // e.g. for simulated capabilities. This is not a problem for normal operations, but it is a problem
        // for delayed operations (e.g. consistency) that are passing through this code again.
        // TODO: we need to figure a way how to avoid this loop
        //			if (limitations.isIgnore()) {
        //				String message = "Attempt to create shadow with ignored attribute "+attribute.getName();
        //				LOGGER.error(message);
        //				throw new SchemaException(message);
        //			}
        PropertyAccessType access = limitations.getAccess();
        if (access == null) {
            continue;
        }
        if (access.isAdd() == null || !access.isAdd()) {
            String message = "Attempt to add shadow with non-createable attribute " + attribute.getElementName();
            LOGGER.error(message);
            result.recordFatalError(message);
            throw new SecurityViolationException(message);
        }
    }
    result.recordSuccess();
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) RefinedAttributeDefinition(com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition) PropertyAccessType(com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyAccessType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceAttributeContainer(com.evolveum.midpoint.schema.processor.ResourceAttributeContainer) PropertyLimitations(com.evolveum.midpoint.common.refinery.PropertyLimitations)

Example 27 with RefinedAttributeDefinition

use of com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition in project midpoint by Evolveum.

the class MidpointFunctionsImpl method countAccounts.

private <T> Integer countAccounts(ResourceType resourceType, QName attributeName, T attributeValue, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType);
    RefinedObjectClassDefinition rAccountDef = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT);
    RefinedAttributeDefinition attrDef = rAccountDef.findAttributeDefinition(attributeName);
    ObjectQuery query = QueryBuilder.queryFor(ShadowType.class, prismContext).itemWithDef(attrDef, ShadowType.F_ATTRIBUTES, attrDef.getName()).eq(attributeValue).and().item(ShadowType.F_OBJECT_CLASS).eq(rAccountDef.getObjectClassDefinition().getTypeName()).and().item(ShadowType.F_RESOURCE_REF).ref(resourceType.getOid()).build();
    return modelObjectResolver.countObjects(ShadowType.class, query, null, task, result);
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) RefinedAttributeDefinition(com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 28 with RefinedAttributeDefinition

use of com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition in project midpoint by Evolveum.

the class PrismPropertyPanel method hasOutbound.

private boolean hasOutbound(IModel<IW> model) {
    ItemWrapper wrapper = model.getObject();
    //        Item property = wrapper.getItem();
    ItemDefinition def = wrapper.getItemDefinition();
    if (!(def instanceof RefinedAttributeDefinition)) {
        return false;
    }
    RefinedAttributeDefinition refinedDef = (RefinedAttributeDefinition) def;
    return refinedDef.hasOutboundMapping();
}
Also used : RefinedAttributeDefinition(com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition)

Aggregations

RefinedAttributeDefinition (com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition)28 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)12 QName (javax.xml.namespace.QName)10 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)8 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)6 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)5 PropertyLimitations (com.evolveum.midpoint.common.refinery.PropertyLimitations)4 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)4 ResourceAttributeContainer (com.evolveum.midpoint.schema.processor.ResourceAttributeContainer)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)3 PropertyAccessType (com.evolveum.midpoint.xml.ns._public.common.common_3.PropertyAccessType)3 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)2 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)2 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2