Search in sources :

Example 11 with ResourceObjectDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectDefinition in project midpoint by Evolveum.

the class ProjectionUpdateOperation method setProjectionSecurityPolicy.

private void setProjectionSecurityPolicy(OperationResult result) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    ResourceObjectDefinition structuralObjectDefinition = projectionContext.getStructuralObjectDefinition();
    if (structuralObjectDefinition != null) {
        LOGGER.trace("setProjectionSecurityPolicy: structural object class def = {}", structuralObjectDefinition);
        SecurityPolicyType projectionSecurityPolicy = beans.securityHelper.locateProjectionSecurityPolicy(structuralObjectDefinition, task, result);
        LOGGER.trace("Located security policy for: {},\n {}", projectionContext, projectionSecurityPolicy);
        projectionContext.setProjectionSecurityPolicy(projectionSecurityPolicy);
    } else {
        LOGGER.trace("No structural object class definition, skipping determining security policy");
    }
}
Also used : ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition)

Example 12 with ResourceObjectDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectDefinition in project midpoint by Evolveum.

the class SyncTaskHelper method createObjectClassForShadow.

/**
 * Creates {@link ResourceObjectClass} for a single shadow.
 */
@NotNull
public ResourceObjectClass createObjectClassForShadow(ShadowType shadow, Task task, OperationResult opResult) throws ActivityRunException, SchemaException {
    String resourceOid = ShadowUtil.getResourceOid(shadow);
    ResourceType resource = getResource(resourceOid, task, opResult);
    checkNotInMaintenance(resource);
    ResourceSchema refinedSchema = getRefinedResourceSchema(resource);
    // TODO reconsider the algorithm used for deriving object class
    ResourceObjectDefinition objectClass = requireNonNull(ModelImplUtils.determineObjectDefinition(refinedSchema, shadow.asPrismObject()), "No object class found for the shadow");
    return new ResourceObjectClass(resource, objectClass, null, null);
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with ResourceObjectDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectDefinition in project midpoint by Evolveum.

the class SyncTaskHelper method createResourceObjectClass.

@NotNull
private ResourceObjectClass createResourceObjectClass(@NotNull ResourceObjectSetType resourceObjectSet, boolean checkForMaintenance, Task task, OperationResult opResult) throws ActivityRunException {
    String resourceOid = getResourceOid(resourceObjectSet);
    ResourceType resource = getResource(resourceOid, task, opResult);
    if (checkForMaintenance) {
        checkNotInMaintenance(resource);
    }
    ResourceSchema refinedResourceSchema = getRefinedResourceSchema(resource);
    ResourceObjectDefinition objectClassDefinition;
    try {
        objectClassDefinition = ModelImplUtils.determineObjectDefinition(refinedResourceSchema, resourceObjectSet, task);
    } catch (SchemaException e) {
        throw new ActivityRunException("Schema error", FATAL_ERROR, PERMANENT_ERROR, e);
    }
    if (objectClassDefinition == null) {
        LOGGER.debug("Processing all object classes");
    }
    return new ResourceObjectClass(resource, objectClassDefinition, resourceObjectSet.getKind(), resourceObjectSet.getIntent());
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) ActivityRunException(com.evolveum.midpoint.repo.common.activity.run.ActivityRunException) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with ResourceObjectDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectDefinition in project midpoint by Evolveum.

the class RefinedResourceSchemaAsserter method objectClass.

public ResourceObjectDefinitionAsserter<RefinedResourceSchemaAsserter<RA>> objectClass(QName ocQname) {
    ResourceObjectDefinition objectClassDefinition = getSchema().findDefinitionForObjectClass(ocQname);
    ResourceObjectDefinitionAsserter<RefinedResourceSchemaAsserter<RA>> asserter = new ResourceObjectDefinitionAsserter<>(objectClassDefinition, this, desc());
    copySetupTo(asserter);
    return asserter;
}
Also used : ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition)

Example 15 with ResourceObjectDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectDefinition in project midpoint by Evolveum.

the class ConstraintsChecker method checkAttributeUniqueness.

private boolean checkAttributeUniqueness(PrismProperty<?> identifier, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    ResourceType resource = provisioningContext.getResource();
    ResourceObjectDefinition definition = provisioningContext.getObjectDefinitionRequired();
    List<? extends PrismPropertyValue<?>> identifierValues = identifier.getValues();
    schemaCheck(!identifierValues.isEmpty(), "Empty identifier %s while checking uniqueness of %s (%s)", identifier, shadowOid, resource);
    // Note that we do not set matching rule here. We assume that values in repo and here are already normalized.
    ObjectQuery query = PrismContext.get().queryFor(ShadowType.class).itemWithDef(identifier.getDefinition(), ShadowType.F_ATTRIBUTES, identifier.getDefinition().getItemName()).eq(PrismValueCollectionsUtil.cloneCollection(identifierValues)).and().item(ShadowType.F_OBJECT_CLASS).eq(definition.getObjectClassName()).and().item(ShadowType.F_RESOURCE_REF).ref(resource.getOid()).and().block().item(ShadowType.F_DEAD).eq(false).or().item(ShadowType.F_DEAD).isNull().endBlock().build();
    return checkUniquenessByQuery(identifier, query, result);
}
Also used : ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Aggregations

ResourceObjectDefinition (com.evolveum.midpoint.schema.processor.ResourceObjectDefinition)64 QName (javax.xml.namespace.QName)19 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)17 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)16 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)14 ArrayList (java.util.ArrayList)14 Task (com.evolveum.midpoint.task.api.Task)12 Test (org.testng.annotations.Test)12 ResourceAttributeDefinition (com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition)8 NotNull (org.jetbrains.annotations.NotNull)8 ResourceAttributeContainer (com.evolveum.midpoint.schema.processor.ResourceAttributeContainer)6 ResourceAssociationDefinition (com.evolveum.midpoint.schema.processor.ResourceAssociationDefinition)5 Collection (java.util.Collection)5 Nullable (org.jetbrains.annotations.Nullable)5 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 ResourceAttribute (com.evolveum.midpoint.schema.processor.ResourceAttribute)4 ResourceObjectTypeDefinition (com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition)4 AutoCompleteQNamePanel (com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteQNamePanel)3 AutoCompleteTextPanel (com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel)2 ItemName (com.evolveum.midpoint.prism.path.ItemName)2