Search in sources :

Example 1 with MatchingRule

use of com.evolveum.midpoint.prism.match.MatchingRule in project midpoint by Evolveum.

the class SubstringFilter method match.

@Override
public boolean match(PrismContainerValue containerValue, MatchingRuleRegistry matchingRuleRegistry) throws SchemaException {
    Item item = getObjectItem(containerValue);
    MatchingRule matching = getMatchingRuleFromRegistry(matchingRuleRegistry, item);
    for (Object val : item.getValues()) {
        if (val instanceof PrismPropertyValue) {
            Object value = ((PrismPropertyValue) val).getValue();
            Iterator<String> iterator = (Iterator<String>) toRealValues().iterator();
            while (iterator.hasNext()) {
                StringBuilder sb = new StringBuilder();
                if (!anchorStart) {
                    sb.append(".*");
                }
                sb.append(Pattern.quote(iterator.next()));
                if (!anchorEnd) {
                    sb.append(".*");
                }
                if (matching.matchRegex(value, sb.toString())) {
                    return true;
                }
            }
        }
        if (val instanceof PrismReferenceValue) {
            throw new UnsupportedOperationException("matching substring on the prism reference value not supported yet");
        }
    }
    return false;
}
Also used : Iterator(java.util.Iterator) MatchingRule(com.evolveum.midpoint.prism.match.MatchingRule)

Example 2 with MatchingRule

use of com.evolveum.midpoint.prism.match.MatchingRule in project midpoint by Evolveum.

the class TestSanity method test016ProvisioningSearchAccountsIterative.

@Test
public void test016ProvisioningSearchAccountsIterative() throws Exception {
    TestUtil.displayTestTile("test016ProvisioningSearchAccountsIterative");
    // GIVEN
    OperationResult result = new OperationResult(TestSanity.class.getName() + ".test016ProvisioningSearchAccountsIterative");
    RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceTypeOpenDjrepo, prismContext);
    final RefinedObjectClassDefinition refinedAccountDefinition = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT);
    QName objectClass = refinedAccountDefinition.getObjectClassDefinition().getTypeName();
    ObjectQuery q = ObjectQueryUtil.createResourceAndObjectClassQuery(resourceTypeOpenDjrepo.getOid(), objectClass, prismContext);
    //        ObjectQuery q = QueryConvertor.createObjectQuery(ResourceObjectShadowType.class, query, prismContext);
    final Collection<ObjectType> objects = new HashSet<ObjectType>();
    final MatchingRule caseIgnoreMatchingRule = matchingRuleRegistry.getMatchingRule(StringIgnoreCaseMatchingRule.NAME, DOMUtil.XSD_STRING);
    ResultHandler handler = new ResultHandler<ObjectType>() {

        @Override
        public boolean handle(PrismObject<ObjectType> prismObject, OperationResult parentResult) {
            ObjectType objectType = prismObject.asObjectable();
            objects.add(objectType);
            display("Found object", objectType);
            assertTrue(objectType instanceof ShadowType);
            ShadowType shadow = (ShadowType) objectType;
            assertNotNull(shadow.getOid());
            assertNotNull(shadow.getName());
            assertEquals(RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS, shadow.getObjectClass());
            assertEquals(RESOURCE_OPENDJ_OID, shadow.getResourceRef().getOid());
            String icfUid = getAttributeValue(shadow, getOpenDjPrimaryIdentifierQName());
            assertNotNull("No ICF UID", icfUid);
            String icfName = getNormalizedAttributeValue(shadow, refinedAccountDefinition, getOpenDjSecondaryIdentifierQName());
            assertNotNull("No ICF NAME", icfName);
            try {
                PrismAsserts.assertEquals("Wrong shadow name", caseIgnoreMatchingRule, shadow.getName().getOrig(), icfName);
            } catch (SchemaException e) {
                throw new IllegalArgumentException(e.getMessage(), e);
            }
            assertNotNull("Missing LDAP uid", getAttributeValue(shadow, new QName(ResourceTypeUtil.getResourceNamespace(resourceTypeOpenDjrepo), "uid")));
            assertNotNull("Missing LDAP cn", getAttributeValue(shadow, new QName(ResourceTypeUtil.getResourceNamespace(resourceTypeOpenDjrepo), "cn")));
            assertNotNull("Missing LDAP sn", getAttributeValue(shadow, new QName(ResourceTypeUtil.getResourceNamespace(resourceTypeOpenDjrepo), "sn")));
            assertNotNull("Missing activation", shadow.getActivation());
            assertNotNull("Missing activation status", shadow.getActivation().getAdministrativeStatus());
            return true;
        }
    };
    // WHEN
    provisioningService.searchObjectsIterative(ShadowType.class, q, null, handler, null, result);
    // THEN
    display("Count", objects.size());
}
Also used : QName(javax.xml.namespace.QName) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResultHandler(com.evolveum.midpoint.schema.ResultHandler) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) GenericObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) StringIgnoreCaseMatchingRule(com.evolveum.midpoint.prism.match.StringIgnoreCaseMatchingRule) MatchingRule(com.evolveum.midpoint.prism.match.MatchingRule) HashSet(java.util.HashSet) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 3 with MatchingRule

use of com.evolveum.midpoint.prism.match.MatchingRule in project midpoint by Evolveum.

the class AbstractIntegrationTest method assertShadowCommon.

protected void assertShadowCommon(PrismObject<ShadowType> shadow, String oid, String username, ResourceType resourceType, QName objectClass, final MatchingRule<String> nameMatchingRule, boolean requireNormalizedIdentfiers, boolean useMatchingRuleForShadowName) throws SchemaException {
    assertShadow(shadow);
    if (oid != null) {
        assertEquals("Shadow OID mismatch (prism)", oid, shadow.getOid());
    }
    ShadowType resourceObjectShadowType = shadow.asObjectable();
    if (oid != null) {
        assertEquals("Shadow OID mismatch (jaxb)", oid, resourceObjectShadowType.getOid());
    }
    assertEquals("Shadow objectclass", objectClass, resourceObjectShadowType.getObjectClass());
    assertEquals("Shadow resourceRef OID", resourceType.getOid(), shadow.asObjectable().getResourceRef().getOid());
    PrismContainer<Containerable> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
    assertNotNull("Null attributes in shadow for " + username, attributesContainer);
    assertFalse("Empty attributes in shadow for " + username, attributesContainer.isEmpty());
    if (useMatchingRuleForShadowName) {
        MatchingRule<PolyString> polyMatchingRule = new MatchingRule<PolyString>() {

            @Override
            public QName getName() {
                return nameMatchingRule.getName();
            }

            @Override
            public boolean isSupported(QName xsdType) {
                return nameMatchingRule.isSupported(xsdType);
            }

            @Override
            public boolean match(PolyString a, PolyString b) throws SchemaException {
                return nameMatchingRule.match(a.getOrig(), b.getOrig());
            }

            @Override
            public boolean matchRegex(PolyString a, String regex) throws SchemaException {
                return nameMatchingRule.matchRegex(a.getOrig(), regex);
            }

            @Override
            public PolyString normalize(PolyString original) throws SchemaException {
                return new PolyString(nameMatchingRule.normalize(original.getOrig()));
            }
        };
        PrismAsserts.assertPropertyValueMatch(shadow, ShadowType.F_NAME, polyMatchingRule, PrismTestUtil.createPolyString(username));
    } else {
        PrismAsserts.assertPropertyValue(shadow, ShadowType.F_NAME, PrismTestUtil.createPolyString(username));
    }
    RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType);
    ObjectClassComplexTypeDefinition ocDef = rSchema.findObjectClassDefinition(objectClass);
    if (ocDef.getSecondaryIdentifiers().isEmpty()) {
        ResourceAttributeDefinition idDef = ocDef.getPrimaryIdentifiers().iterator().next();
        PrismProperty<String> idProp = attributesContainer.findProperty(idDef.getName());
        assertNotNull("No primary identifier (" + idDef.getName() + ") attribute in shadow for " + username, idProp);
        if (nameMatchingRule == null) {
            assertEquals("Unexpected primary identifier in shadow for " + username, username, idProp.getRealValue());
        } else {
            if (requireNormalizedIdentfiers) {
                assertEquals("Unexpected primary identifier in shadow for " + username, nameMatchingRule.normalize(username), idProp.getRealValue());
            } else {
                PrismAsserts.assertEquals("Unexpected primary identifier in shadow for " + username, nameMatchingRule, username, idProp.getRealValue());
            }
        }
    } else {
        ResourceAttributeDefinition idSecDef = ocDef.getSecondaryIdentifiers().iterator().next();
        PrismProperty<String> idProp = attributesContainer.findProperty(idSecDef.getName());
        assertNotNull("No secondary identifier (" + idSecDef.getName() + ") attribute in shadow for " + username, idProp);
        if (nameMatchingRule == null) {
            assertEquals("Unexpected secondary identifier in shadow for " + username, username, idProp.getRealValue());
        } else {
            if (requireNormalizedIdentfiers) {
                assertEquals("Unexpected secondary identifier in shadow for " + username, nameMatchingRule.normalize(username), idProp.getRealValue());
            } else {
                PrismAsserts.assertEquals("Unexpected secondary identifier in shadow for " + username, nameMatchingRule, username, idProp.getRealValue());
            }
        }
    }
}
Also used : ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) QName(javax.xml.namespace.QName) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Containerable(com.evolveum.midpoint.prism.Containerable) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) MatchingRule(com.evolveum.midpoint.prism.match.MatchingRule)

Example 4 with MatchingRule

use of com.evolveum.midpoint.prism.match.MatchingRule in project midpoint by Evolveum.

the class TestSanityLegacy method test016ProvisioningSearchAccountsIterative.

@Test
public void test016ProvisioningSearchAccountsIterative() throws Exception {
    TestUtil.displayTestTile("test016ProvisioningSearchAccountsIterative");
    // GIVEN
    OperationResult result = new OperationResult(TestSanityLegacy.class.getName() + ".test016ProvisioningSearchAccountsIterative");
    RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceTypeOpenDjrepo, prismContext);
    final RefinedObjectClassDefinition refinedAccountDefinition = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT);
    QName objectClass = refinedAccountDefinition.getObjectClassDefinition().getTypeName();
    ObjectQuery q = ObjectQueryUtil.createResourceAndObjectClassQuery(resourceTypeOpenDjrepo.getOid(), objectClass, prismContext);
    //        ObjectQuery q = QueryConvertor.createObjectQuery(ResourceObjectShadowType.class, query, prismContext);
    final Collection<ObjectType> objects = new HashSet<>();
    final MatchingRule caseIgnoreMatchingRule = matchingRuleRegistry.getMatchingRule(StringIgnoreCaseMatchingRule.NAME, DOMUtil.XSD_STRING);
    ResultHandler handler = new ResultHandler<ObjectType>() {

        @Override
        public boolean handle(PrismObject<ObjectType> prismObject, OperationResult parentResult) {
            ObjectType objectType = prismObject.asObjectable();
            objects.add(objectType);
            display("Found object", objectType);
            assertTrue(objectType instanceof ShadowType);
            ShadowType shadow = (ShadowType) objectType;
            assertNotNull(shadow.getOid());
            assertNotNull(shadow.getName());
            assertEquals(new QName(ResourceTypeUtil.getResourceNamespace(resourceTypeOpenDjrepo), "AccountObjectClass"), shadow.getObjectClass());
            assertEquals(RESOURCE_OPENDJ_OID, shadow.getResourceRef().getOid());
            String icfUid = getAttributeValue(shadow, SchemaConstants.ICFS_UID);
            assertNotNull("No ICF UID", icfUid);
            String icfName = getNormalizedAttributeValue(shadow, refinedAccountDefinition, SchemaConstants.ICFS_NAME);
            assertNotNull("No ICF NAME", icfName);
            try {
                PrismAsserts.assertEquals("Wrong shadow name", caseIgnoreMatchingRule, shadow.getName().getOrig(), icfName);
            } catch (SchemaException e) {
                throw new IllegalArgumentException(e.getMessage(), e);
            }
            assertNotNull("Missing LDAP uid", getAttributeValue(shadow, new QName(ResourceTypeUtil.getResourceNamespace(resourceTypeOpenDjrepo), "uid")));
            assertNotNull("Missing LDAP cn", getAttributeValue(shadow, new QName(ResourceTypeUtil.getResourceNamespace(resourceTypeOpenDjrepo), "cn")));
            assertNotNull("Missing LDAP sn", getAttributeValue(shadow, new QName(ResourceTypeUtil.getResourceNamespace(resourceTypeOpenDjrepo), "sn")));
            assertNotNull("Missing activation", shadow.getActivation());
            assertNotNull("Missing activation status", shadow.getActivation().getAdministrativeStatus());
            return true;
        }
    };
    // WHEN
    provisioningService.searchObjectsIterative(ShadowType.class, q, null, handler, null, result);
    // THEN
    display("Count", objects.size());
}
Also used : QName(javax.xml.namespace.QName) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResultHandler(com.evolveum.midpoint.schema.ResultHandler) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) GenericObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) StringIgnoreCaseMatchingRule(com.evolveum.midpoint.prism.match.StringIgnoreCaseMatchingRule) MatchingRule(com.evolveum.midpoint.prism.match.MatchingRule) HashSet(java.util.HashSet) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 5 with MatchingRule

use of com.evolveum.midpoint.prism.match.MatchingRule in project midpoint by Evolveum.

the class ShadowManager method updateShadow.

/**
	 * Updates repository shadow based on shadow from resource. Handles rename cases,
	 * change of auxiliary object classes, etc.
	 * @returns repository shadow as it should look like after the update
	 */
@SuppressWarnings("unchecked")
public PrismObject<ShadowType> updateShadow(ProvisioningContext ctx, PrismObject<ShadowType> currentResourceShadow, PrismObject<ShadowType> oldRepoShadow, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, ObjectAlreadyExistsException, ConfigurationException, CommunicationException, ExpressionEvaluationException {
    RefinedObjectClassDefinition ocDef = ctx.computeCompositeObjectClassDefinition(currentResourceShadow);
    ObjectDelta<ShadowType> shadowDelta = oldRepoShadow.createModifyDelta();
    PrismContainer<Containerable> currentResourceAttributesContainer = currentResourceShadow.findContainer(ShadowType.F_ATTRIBUTES);
    PrismContainer<Containerable> oldRepoAttributesContainer = oldRepoShadow.findContainer(ShadowType.F_ATTRIBUTES);
    ShadowType oldRepoShadowType = oldRepoShadow.asObjectable();
    ShadowType currentResourceShadowType = currentResourceShadow.asObjectable();
    if (oldRepoShadowType.isExists() != currentResourceShadowType.isExists()) {
        // Resource object obviously exists when we have got here
        shadowDelta.addModificationReplaceProperty(ShadowType.F_EXISTS, currentResourceShadowType.isExists());
    }
    CachingStategyType cachingStrategy = ProvisioningUtil.getCachingStrategy(ctx);
    for (Item<?, ?> currentResourceItem : currentResourceAttributesContainer.getValue().getItems()) {
        if (currentResourceItem instanceof PrismProperty<?>) {
            PrismProperty<?> currentResourceAttrProperty = (PrismProperty<?>) currentResourceItem;
            RefinedAttributeDefinition<Object> attrDef = ocDef.findAttributeDefinition(currentResourceAttrProperty.getElementName());
            if (ProvisioningUtil.shouldStoreAtributeInShadow(ocDef, attrDef.getName(), cachingStrategy)) {
                MatchingRule matchingRule = matchingRuleRegistry.getMatchingRule(attrDef.getMatchingRuleQName(), attrDef.getTypeName());
                PrismProperty<Object> oldRepoAttributeProperty = oldRepoAttributesContainer.findProperty(currentResourceAttrProperty.getElementName());
                if (oldRepoAttributeProperty == null) {
                    PropertyDelta<?> attrAddDelta = currentResourceAttrProperty.createDelta();
                    for (PrismPropertyValue pval : currentResourceAttrProperty.getValues()) {
                        Object normalizedRealValue;
                        if (matchingRule == null) {
                            normalizedRealValue = pval.getValue();
                        } else {
                            normalizedRealValue = matchingRule.normalize(pval.getValue());
                        }
                        attrAddDelta.addValueToAdd(new PrismPropertyValue(normalizedRealValue));
                        LOGGER.trace("CURRENT ATTR:\n{}\nATTR DELTA:\n{}", currentResourceAttrProperty.debugDump(1), attrAddDelta.debugDump(1));
                    }
                    shadowDelta.addModification(attrAddDelta);
                } else {
                    if (attrDef.isSingleValue()) {
                        Object currentResourceRealValue = currentResourceAttrProperty.getRealValue();
                        Object currentResourceNormalizedRealValue;
                        if (matchingRule == null) {
                            currentResourceNormalizedRealValue = currentResourceRealValue;
                        } else {
                            currentResourceNormalizedRealValue = matchingRule.normalize(currentResourceRealValue);
                        }
                        if (!currentResourceNormalizedRealValue.equals(oldRepoAttributeProperty.getRealValue())) {
                            LOGGER.trace("CURRENT ATTR:\n{}\ncurrentResourceNormalizedRealValue: {}", currentResourceAttrProperty.debugDump(1), currentResourceNormalizedRealValue);
                            shadowDelta.addModificationReplaceProperty(currentResourceAttrProperty.getPath(), currentResourceNormalizedRealValue);
                        }
                    } else {
                        PrismProperty<Object> normalizedCurrentResourceAttrProperty = (PrismProperty<Object>) currentResourceAttrProperty.clone();
                        if (matchingRule != null) {
                            for (PrismPropertyValue pval : normalizedCurrentResourceAttrProperty.getValues()) {
                                Object normalizedRealValue = matchingRule.normalize(pval.getValue());
                                pval.setValue(normalizedRealValue);
                            }
                        }
                        PropertyDelta<Object> attrDiff = oldRepoAttributeProperty.diff(normalizedCurrentResourceAttrProperty);
                        LOGGER.trace("DIFF:\n{}\n-\n{}\n=:\n{}", oldRepoAttributeProperty == null ? null : oldRepoAttributeProperty.debugDump(1), normalizedCurrentResourceAttrProperty == null ? null : normalizedCurrentResourceAttrProperty.debugDump(1), attrDiff == null ? null : attrDiff.debugDump(1));
                        if (attrDiff != null && !attrDiff.isEmpty()) {
                            attrDiff.setParentPath(new ItemPath(ShadowType.F_ATTRIBUTES));
                            shadowDelta.addModification(attrDiff);
                        }
                    }
                }
            }
        }
    }
    for (Item<?, ?> oldRepoItem : oldRepoAttributesContainer.getValue().getItems()) {
        if (oldRepoItem instanceof PrismProperty<?>) {
            PrismProperty<?> oldRepoAttrProperty = (PrismProperty<?>) oldRepoItem;
            RefinedAttributeDefinition<Object> attrDef = ocDef.findAttributeDefinition(oldRepoAttrProperty.getElementName());
            PrismProperty<Object> currentAttribute = currentResourceAttributesContainer.findProperty(oldRepoAttrProperty.getElementName());
            if (attrDef == null || !ProvisioningUtil.shouldStoreAtributeInShadow(ocDef, attrDef.getName(), cachingStrategy) || currentAttribute == null) {
                // No definition for this property it should not be there or no current value: remove it from the shadow
                PropertyDelta<?> oldRepoAttrPropDelta = oldRepoAttrProperty.createDelta();
                oldRepoAttrPropDelta.addValuesToDelete((Collection) PrismPropertyValue.cloneCollection(oldRepoAttrProperty.getValues()));
                shadowDelta.addModification(oldRepoAttrPropDelta);
            }
        }
    }
    PolyString currentShadowName = ShadowUtil.determineShadowName(currentResourceShadow);
    PolyString oldRepoShadowName = oldRepoShadow.getName();
    if (!currentShadowName.equalsOriginalValue(oldRepoShadowName)) {
        PropertyDelta<?> shadowNameDelta = PropertyDelta.createModificationReplaceProperty(ShadowType.F_NAME, oldRepoShadow.getDefinition(), currentShadowName);
        shadowDelta.addModification(shadowNameDelta);
    }
    PropertyDelta<QName> auxOcDelta = (PropertyDelta) PrismProperty.diff(oldRepoShadow.findProperty(ShadowType.F_AUXILIARY_OBJECT_CLASS), currentResourceShadow.findProperty(ShadowType.F_AUXILIARY_OBJECT_CLASS));
    if (auxOcDelta != null) {
        shadowDelta.addModification(auxOcDelta);
    }
    if (cachingStrategy == CachingStategyType.NONE) {
        if (oldRepoShadowType.getCachingMetadata() != null) {
            shadowDelta.addModificationReplaceProperty(ShadowType.F_CACHING_METADATA);
        }
    } else if (cachingStrategy == CachingStategyType.PASSIVE) {
        compareUpdateProperty(shadowDelta, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, currentResourceShadow, oldRepoShadow);
        compareUpdateProperty(shadowDelta, SchemaConstants.PATH_ACTIVATION_VALID_FROM, currentResourceShadow, oldRepoShadow);
        compareUpdateProperty(shadowDelta, SchemaConstants.PATH_ACTIVATION_VALID_TO, currentResourceShadow, oldRepoShadow);
        compareUpdateProperty(shadowDelta, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, currentResourceShadow, oldRepoShadow);
        CachingMetadataType cachingMetadata = new CachingMetadataType();
        cachingMetadata.setRetrievalTimestamp(clock.currentTimeXMLGregorianCalendar());
        shadowDelta.addModificationReplaceProperty(ShadowType.F_CACHING_METADATA, cachingMetadata);
    } else {
        throw new ConfigurationException("Unknown caching strategy " + cachingStrategy);
    }
    if (!shadowDelta.isEmpty()) {
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Updating repo shadow {} with delta:\n{}", oldRepoShadow, shadowDelta.debugDump(1));
        }
        ConstraintsChecker.onShadowModifyOperation(shadowDelta.getModifications());
        try {
            repositoryService.modifyObject(ShadowType.class, oldRepoShadow.getOid(), shadowDelta.getModifications(), parentResult);
        } catch (ObjectAlreadyExistsException e) {
            // This should not happen for shadows
            throw new SystemException(e.getMessage(), e);
        }
        PrismObject<ShadowType> newRepoShadow = oldRepoShadow.clone();
        shadowDelta.applyTo(newRepoShadow);
        return newRepoShadow;
    } else {
        LOGGER.trace("No need to update repo shadow {} (empty delta)", oldRepoShadow);
        return oldRepoShadow;
    }
}
Also used : RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) SystemException(com.evolveum.midpoint.util.exception.SystemException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) Containerable(com.evolveum.midpoint.prism.Containerable) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) QName(javax.xml.namespace.QName) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismObject(com.evolveum.midpoint.prism.PrismObject) MatchingRule(com.evolveum.midpoint.prism.match.MatchingRule) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

MatchingRule (com.evolveum.midpoint.prism.match.MatchingRule)8 QName (javax.xml.namespace.QName)6 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)4 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)4 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)3 Containerable (com.evolveum.midpoint.prism.Containerable)3 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 PrismProperty (com.evolveum.midpoint.prism.PrismProperty)2 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)2 StringIgnoreCaseMatchingRule (com.evolveum.midpoint.prism.match.StringIgnoreCaseMatchingRule)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)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 ResultHandler (com.evolveum.midpoint.schema.ResultHandler)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)2