public static String getResourceOid(PrismObject<ShadowType> shadow) { PrismReference resourceRef = shadow.findReference(ShadowType.F_RESOURCE_REF); if (resourceRef == null) { return null; } return resourceRef.getOid(); }
public static void checkConsistence(PrismObject<? extends ShadowType> shadow, String desc) { PrismReference resourceRef = shadow.findReference(ShadowType.F_RESOURCE_REF); if (resourceRef == null) { throw new IllegalStateException("No resourceRef in "+shadow+" in "+desc); } if (StringUtils.isBlank(resourceRef.getOid())) { throw new IllegalStateException("Null or empty OID in resourceRef in "+desc); } ShadowType shadowType = shadow.asObjectable(); if (shadowType.getObjectClass() == null) { throw new IllegalStateException("Null objectClass in "+desc); } PrismContainer<ShadowAttributesType> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); if (attributesContainer != null) { if (!(attributesContainer instanceof ResourceAttributeContainer)) { throw new IllegalStateException("The attributes element expected to be ResourceAttributeContainer but it is " +attributesContainer.getClass()+" instead in "+desc); } checkConsistency(attributesContainer.getDefinition(), " container definition in "+desc); } PrismContainerDefinition<ShadowAttributesType> attributesDefinition = shadow.getDefinition().findContainerDefinition((ItemPath) ShadowType.F_ATTRIBUTES); checkConsistency(attributesDefinition, " object definition in "+desc); }
if (projCtx.getEntitlementMap().containsKey(shadowRef.getOid())) { shadowRef.getValue().setObject(projCtx.getEntitlementMap().get(shadowRef.getOid())); } else { try { PrismObject<ShadowType> entitlement = provisioningService.getObject(ShadowType.class, shadowRef.getOid(), null, task, result); projCtx.getEntitlementMap().put(entitlement.getOid(), entitlement);
PrismObject<UserType> resolveOwnerRef(OperationResult result) throws SchemaException { PrismReference ownerRef = taskPrism.findReference(TaskType.F_OWNER_REF); if (ownerRef == null) { throw new SchemaException("Task " + getOid() + " does not have an owner (missing ownerRef)"); } try { PrismObject<UserType> owner = repositoryService.getObject(UserType.class, ownerRef.getOid(), null, result); ownerRef.getValue().setObject(owner); return owner; } catch (ObjectNotFoundException e) { LoggingUtils.logExceptionAsWarning(LOGGER, "The owner of task {} cannot be found (owner OID: {})", e, getOid(), ownerRef.getOid()); return null; } }
private void resolveEntitlement(PrismContainerValue<ShadowAssociationType> value, LensProjectionContext projContext, ExpressionVariables variables) { LOGGER.trace("Producing value {} ", value); PrismObject<ShadowType> entitlement = projContext.getEntitlementMap().get(value.findReference(ShadowAssociationType.F_SHADOW_REF).getOid()); LOGGER.trace("Resolved entitlement {}", entitlement); if (variables.containsKey(ExpressionConstants.VAR_ENTITLEMENT)) { variables.replaceVariableDefinition(ExpressionConstants.VAR_ENTITLEMENT, entitlement); } else { variables.addVariableDefinition(ExpressionConstants.VAR_ENTITLEMENT, entitlement); } }
@Override public int compare(PrismContainerValue<ShadowAssociationType> o1, PrismContainerValue<ShadowAssociationType> o2) { if (o1 == null && o2 == null){ LOGGER.trace("Comparing {} and {}: 0 (A)", o1, o2); return 0; } if (o1 == null || o2 == null){ LOGGER.trace("Comparing {} and {}: 2 (B)", o1, o2); return 1; } PrismReference ref1 = o1.findReference(ShadowAssociationType.F_SHADOW_REF); PrismReference ref2 = o2.findReference(ShadowAssociationType.F_SHADOW_REF); // We do not want to compare references in details. Comparing OIDs suffices. // Otherwise we get into problems, as one of the references might be e.g. without type, // causing unpredictable behavior (MID-2368) String oid1 = ref1 != null ? ref1.getOid() : null; String oid2 = ref2 != null ? ref2.getOid() : null; if (ObjectUtils.equals(oid1, oid2)) { LOGGER.trace("Comparing {} and {}: 0 (C)", o1, o2); return 0; } LOGGER.trace("Comparing {} and {}: 1 (D)", o1, o2); return 1; } };
PrismObject<T> object = repositoryService.getObject(type, objectRef.getOid(), null, result); objectRef.getValue().setObject(object); result.recordSuccess();
private void assertJackAccountShadow(LensContext<UserType> context) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { Collection<LensProjectionContext> accountContexts = context.getProjectionContexts(); assertEquals(1, accountContexts.size()); LensProjectionContext accContext = accountContexts.iterator().next(); String accountOid = accContext.getOid(); assertNotNull("No OID in account context "+accContext); PrismObject<ShadowType> newAccount = getShadowModel(accountOid); assertEquals(DEFAULT_INTENT, newAccount.findProperty(ShadowType.F_INTENT).getRealValue()); assertEquals(new QName(ResourceTypeUtil.getResourceNamespace(getDummyResourceType()), "AccountObjectClass"), newAccount.findProperty(ShadowType.F_OBJECT_CLASS).getRealValue()); PrismReference resourceRef = newAccount.findReference(ShadowType.F_RESOURCE_REF); assertEquals(getDummyResourceType().getOid(), resourceRef.getOid()); PrismContainer<?> attributes = newAccount.findContainer(ShadowType.F_ATTRIBUTES); assertEquals("jack", attributes.findProperty(SchemaTestConstants.ICFS_NAME).getRealValue()); assertEquals("Jack Sparrow", attributes.findProperty(new ItemName(ResourceTypeUtil.getResourceNamespace(getDummyResourceType()), "fullname")).getRealValue()); }
accountToAddPrimary.findProperty(ShadowType.F_OBJECT_CLASS).getRealValue()); PrismReference resourceRef = accountToAddPrimary.findReference(ShadowType.F_RESOURCE_REF); assertEquals(getDummyResourceObject().getOid(), resourceRef.getOid());
accountToAddPrimary.findProperty(ShadowType.F_OBJECT_CLASS).getRealValue()); PrismReference resourceRef = accountToAddPrimary.findReference(ShadowType.F_RESOURCE_REF); assertEquals(getDummyResourceType().getOid(), resourceRef.getOid()); accountToAddPrimary.checkConsistence();
accountToAddPrimary.findProperty(ShadowType.F_OBJECT_CLASS).getRealValue()); PrismReference resourceRef = accountToAddPrimary.findReference(ShadowType.F_RESOURCE_REF); assertEquals(getDummyResourceObject().getOid(), resourceRef.getOid());
accountToAddPrimary.findProperty(ShadowType.F_OBJECT_CLASS).getRealValue()); PrismReference resourceRef = accountToAddPrimary.findReference(ShadowType.F_RESOURCE_REF); assertEquals(getDummyResourceType().getOid(), resourceRef.getOid()); accountToAddPrimary.checkConsistence();