use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.
the class ShadowIntegrityCheckResultHandler method doFixIntent.
private void doFixIntent(ShadowCheckResult checkResult, PrismObject<ShadowType> fetchedShadow, PrismObject<ShadowType> shadow, PrismObject<ResourceType> resource, Task task, OperationResult result) {
PrismObject<ShadowType> fullShadow;
if (!checkFetch) {
fullShadow = fetchShadow(checkResult, shadow, resource, task, result);
} else {
fullShadow = fetchedShadow;
}
if (fullShadow == null) {
checkResult.recordError(Statistics.CANNOT_APPLY_FIX, new SystemException("Cannot fix missing intent, because the resource object couldn't be fetched"));
return;
}
ObjectSynchronizationType synchronizationPolicy;
try {
synchronizationPolicy = synchronizationService.determineSynchronizationPolicy(resource.asObjectable(), fullShadow, configuration, task, result);
} catch (SchemaException | ObjectNotFoundException | ExpressionEvaluationException | RuntimeException e) {
checkResult.recordError(Statistics.CANNOT_APPLY_FIX, new SystemException("Couldn't prepare fix for missing intent, because the synchronization policy couldn't be determined", e));
return;
}
if (synchronizationPolicy != null) {
if (synchronizationPolicy.getIntent() != null) {
PropertyDelta delta = PropertyDelta.createReplaceDelta(fullShadow.getDefinition(), ShadowType.F_INTENT, synchronizationPolicy.getIntent());
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Intent fix delta (not executed now) = \n{}", delta.debugDump());
}
checkResult.addFixDelta(delta, Statistics.NO_INTENT_SPECIFIED);
} else {
LOGGER.info("Synchronization policy does not contain intent: {}", synchronizationPolicy);
}
} else {
LOGGER.info("Intent couldn't be fixed, because no synchronization policy was found");
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.
the class ObjectMerger method takeProjections.
private void takeProjections(MergeStategyType strategy, List<ShadowType> mergedProjections, List<ShadowType> matchedProjections, List<ShadowType> candidateProjections, List<ShadowType> projectionsLeft, List<ShadowType> projectionsRight, ProjectionMergeConfigurationType projectionMergeConfig) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("TAKE: Evaluating situation {}, discriminator: {}", projectionMergeConfig.getSituation(), projectionMergeConfig.getProjectionDiscriminator());
}
for (ShadowType candidateProjection : candidateProjections) {
if (projectionMatches(candidateProjection, projectionsLeft, projectionsRight, projectionMergeConfig)) {
LOGGER.trace("Projection matches {}", candidateProjection);
matchedProjections.add(candidateProjection);
if (strategy == MergeStategyType.TAKE) {
mergedProjections.add(candidateProjection);
} else if (strategy == null || strategy == MergeStategyType.IGNORE) {
// Nothing to do here
} else {
throw new UnsupportedOperationException("Merge strategy " + strategy + " is not supported");
}
} else {
LOGGER.trace("Discriminator does NOT match {}", candidateProjection);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.
the class TestRefinedSchema method assertAccountShadow.
private void assertAccountShadow(PrismObject<ShadowType> accObject, PrismObject<ResourceType> resource, PrismContext prismContext) throws SchemaException, JAXBException {
ResourceType resourceType = resource.asObjectable();
QName objectClassQName = new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "AccountObjectClass");
PrismAsserts.assertPropertyValue(accObject, ShadowType.F_NAME, createPolyString("jack"));
PrismAsserts.assertPropertyValue(accObject, ShadowType.F_OBJECT_CLASS, objectClassQName);
PrismAsserts.assertPropertyValue(accObject, ShadowType.F_INTENT, SchemaConstants.INTENT_DEFAULT);
PrismContainer<?> attributes = accObject.findOrCreateContainer(SchemaConstants.C_ATTRIBUTES);
assertEquals("Wrong type of <attributes> definition in account", ResourceAttributeContainerDefinitionImpl.class, attributes.getDefinition().getClass());
ResourceAttributeContainerDefinition attrDef = (ResourceAttributeContainerDefinition) attributes.getDefinition();
assertAttributeDefs(attrDef, resourceType, null, LayerType.MODEL);
PrismAsserts.assertPropertyValue(attributes, SchemaTestConstants.ICFS_NAME, "uid=jack,ou=People,dc=example,dc=com");
PrismAsserts.assertPropertyValue(attributes, getAttrQName(resource, "cn"), "Jack Sparrow");
PrismAsserts.assertPropertyValue(attributes, getAttrQName(resource, "givenName"), "Jack");
PrismAsserts.assertPropertyValue(attributes, getAttrQName(resource, "sn"), "Sparrow");
PrismAsserts.assertPropertyValue(attributes, getAttrQName(resource, "uid"), "jack");
assertEquals("JAXB class name doesn't match (1)", ShadowType.class, accObject.getCompileTimeClass());
accObject.checkConsistence();
ShadowType accObjectType = accObject.asObjectable();
assertEquals("Wrong JAXB name", createPolyStringType("jack"), accObjectType.getName());
assertEquals("Wrong JAXB objectClass", objectClassQName, accObjectType.getObjectClass());
ShadowAttributesType attributesType = accObjectType.getAttributes();
assertNotNull("null ResourceObjectShadowAttributesType (JAXB)", attributesType);
List<Object> attributeElements = attributesType.getAny();
TestUtil.assertElement(attributeElements, SchemaTestConstants.ICFS_NAME, "uid=jack,ou=People,dc=example,dc=com");
TestUtil.assertElement(attributeElements, getAttrQName(resource, "cn"), "Jack Sparrow");
TestUtil.assertElement(attributeElements, getAttrQName(resource, "givenName"), "Jack");
TestUtil.assertElement(attributeElements, getAttrQName(resource, "sn"), "Sparrow");
TestUtil.assertElement(attributeElements, getAttrQName(resource, "uid"), "jack");
String accString = PrismTestUtil.serializeObjectToString(accObjectType.asPrismObject());
System.out.println("Result of JAXB marshalling:\n" + accString);
accObject.checkConsistence(true, true, ConsistencyCheckScope.THOROUGH);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.
the class TestRefinedSchema method testApplyAttributeDefinition.
@Test
public void testApplyAttributeDefinition() throws JAXBException, SchemaException, SAXException, IOException {
System.out.println("\n===[ testApplyAttributeDefinition ]===\n");
// GIVEN
PrismContext prismContext = createInitializedPrismContext();
PrismObject<ResourceType> resource = prismContext.parseObject(RESOURCE_COMPLEX_FILE);
RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.parse(resource, prismContext);
RefinedObjectClassDefinition defaultAccountDefinition = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT);
assertNotNull("No refined default account definition in " + rSchema, defaultAccountDefinition);
System.out.println("Refined account definition:");
System.out.println(defaultAccountDefinition.debugDump());
PrismObject<ShadowType> accObject = prismContext.parseObject(new File(TEST_DIR_NAME, "account-jack.xml"));
PrismContainer<Containerable> attributesContainer = accObject.findContainer(ShadowType.F_ATTRIBUTES);
System.out.println("Attributes container:");
System.out.println(attributesContainer.debugDump());
// WHEN
attributesContainer.applyDefinition((PrismContainerDefinition) defaultAccountDefinition.toResourceAttributeContainerDefinition(), true);
// THEN
System.out.println("Parsed account:");
System.out.println(accObject.debugDump());
assertAccountShadow(accObject, resource, prismContext);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.
the class AssociationFromLinkExpressionEvaluator method gatherAssociationsFromAbstractRole.
private void gatherAssociationsFromAbstractRole(AbstractRoleType thisRole, PrismContainer<ShadowAssociationType> output, String resourceOid, ShadowKindType kind, String intent, QName assocName, Collection<SelectorOptions<GetOperationOptions>> options, String desc, ExpressionEvaluationContext params) throws SchemaException {
for (ObjectReferenceType linkRef : thisRole.getLinkRef()) {
ShadowType shadowType;
try {
shadowType = objectResolver.resolve(linkRef, ShadowType.class, options, desc, params.getTask(), params.getResult());
} catch (ObjectNotFoundException e) {
// Linked shadow not found. This may happen e.g. if the account is deleted and model haven't got
// the chance to react yet. Just ignore such shadow.
LOGGER.trace("Ignoring shadow " + linkRef.getOid() + " linked in " + thisRole + " because it no longer exists");
continue;
}
if (ShadowUtil.matches(shadowType, resourceOid, kind, intent)) {
PrismContainerValue<ShadowAssociationType> newValue = output.createNewValue();
ShadowAssociationType shadowAssociationType = newValue.asContainerable();
shadowAssociationType.setName(assocName);
ObjectReferenceType shadowRef = new ObjectReferenceType();
shadowRef.setOid(linkRef.getOid());
shadowAssociationType.setShadowRef(shadowRef);
}
}
}
Aggregations