public static <T> ResourceAttribute<T> getAttribute(PrismObject<? extends ShadowType> shadow, QName attrName) { return getAttributesContainer(shadow).findAttribute(attrName); }
public static <T> Collection<T> getAttributeValues(ShadowType shadow, QName attributeQname, Class<T> type) { ResourceAttributeContainer attributesContainer = getAttributesContainer(shadow); if (attributesContainer == null) { return null; } ResourceAttribute<T> attribute = attributesContainer.findAttribute(attributeQname); if (attribute == null) { return null; } return attribute.getRealValues(type); }
public static void assertProvisioningShadow(PrismObject<ShadowType> account, ResourceType resourceType, Class<?> expetcedAttributeDefinitionClass, QName objectClass) { // Check attribute definition PrismContainer attributesContainer = account.findContainer(ShadowType.F_ATTRIBUTES); PrismAsserts.assertClass("Wrong attributes container class", ResourceAttributeContainer.class, attributesContainer); ResourceAttributeContainer rAttributesContainer = (ResourceAttributeContainer)attributesContainer; PrismContainerDefinition attrsDef = attributesContainer.getDefinition(); assertNotNull("No attributes container definition", attrsDef); assertTrue("Wrong attributes definition class "+attrsDef.getClass().getName(), attrsDef instanceof ResourceAttributeContainerDefinition); ResourceAttributeContainerDefinition rAttrsDef = (ResourceAttributeContainerDefinition)attrsDef; ObjectClassComplexTypeDefinition objectClassDef = rAttrsDef.getComplexTypeDefinition(); assertNotNull("No object class definition in attributes definition", objectClassDef); assertEquals("Wrong object class in attributes definition", objectClass, objectClassDef.getTypeName()); ResourceAttributeDefinition primaryIdDef = objectClassDef.getPrimaryIdentifiers().iterator().next(); ResourceAttribute<?> primaryIdAttr = rAttributesContainer.findAttribute(primaryIdDef.getName()); assertNotNull("No primary ID "+primaryIdDef.getName()+" in "+account, primaryIdAttr); assertAttributeDefinition(primaryIdAttr, DOMUtil.XSD_STRING, 0, 1, true, false, false, expetcedAttributeDefinitionClass); ResourceAttributeDefinition secondaryIdDef = objectClassDef.getSecondaryIdentifiers().iterator().next(); ResourceAttribute<Object> secondaryIdAttr = rAttributesContainer.findAttribute(secondaryIdDef.getName()); assertNotNull("No secondary ID "+secondaryIdDef.getName()+" in "+account, secondaryIdAttr); assertAttributeDefinition(secondaryIdAttr, DOMUtil.XSD_STRING, 1, 1, true, true, true, expetcedAttributeDefinitionClass); }
ResourceAttribute<String> nameAttribute = attributesContainer.findAttribute(SchemaConstants.ICFS_NAME); if (nameAttribute == null) { throw new SchemaException("Could not determine shadow name.");
@SuppressWarnings({ "rawtypes", "unchecked" }) private void applyAfterOperationAttributes(PrismObject<ShadowType> shadow, Collection<ResourceAttribute<?>> resourceAttributesAfterAdd) throws SchemaException { if (resourceAttributesAfterAdd == null) { return; } ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(shadow); for (ResourceAttribute attributeAfter : resourceAttributesAfterAdd) { ResourceAttribute attributeBefore = attributesContainer.findAttribute(attributeAfter.getElementName()); if (attributeBefore != null) { attributesContainer.remove(attributeBefore); } if (!attributesContainer.contains(attributeAfter)) { attributesContainer.add(attributeAfter.clone()); } } }
ResourceAttributeContainer resObj = ShadowUtil.getAttributesContainer(shadow); AssertJUnit.assertNull(resObj.findAttribute(new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "givenName"))); .findAttribute(new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "employeeNumber")).getValue(String.class) .getValue(); String changedSn = resObj.findAttribute(new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "sn")) .getValues(String.class).iterator().next().getValue(); String addedStreet = resObj.findAttribute(new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "street")) .getValues(String.class).iterator().next().getValue();
protected void assertSyncOldShadow(PrismObject<? extends ShadowType> oldShadow, String repoName, Integer expectedNumberOfAttributes) { assertNotNull("Old shadow missing", oldShadow); assertNotNull("Old shadow does not have an OID", oldShadow.getOid()); PrismAsserts.assertClass("old shadow", ShadowType.class, oldShadow); ShadowType oldShadowType = oldShadow.asObjectable(); ResourceAttributeContainer attributesContainer = ShadowUtil .getAttributesContainer(oldShadowType); assertNotNull("No attributes container in old shadow", attributesContainer); Collection<ResourceAttribute<?>> attributes = attributesContainer.getAttributes(); assertFalse("Attributes container is empty", attributes.isEmpty()); if (expectedNumberOfAttributes != null) { assertEquals("Unexpected number of attributes", (int)expectedNumberOfAttributes, attributes.size()); } ResourceAttribute<?> icfsNameAttribute = attributesContainer.findAttribute(SchemaConstants.ICFS_NAME); assertNotNull("No ICF name attribute in old shadow", icfsNameAttribute); assertEquals("Wrong value of ICF name attribute in old shadow", repoName, icfsNameAttribute.getRealValue()); }
ResourceAttribute<?> simulatedStatusAttribute = null; if (statusCapabilityType.getAttribute() != null) { simulatedStatusAttribute = attributesContainer.findAttribute(statusCapabilityType.getAttribute());
ResourceAttribute<?> activationProperty = null; if (statusCapabilityType.getAttribute() != null) { activationProperty = attributesContainer.findAttribute(statusCapabilityType.getAttribute());
/** * Set a null value to the (native) dummy attribute. The UCF layer should filter that out. */ @Test public void test129NullAttributeValue() throws Exception { final String TEST_NAME = "test129NullAttributeValue"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); syncServiceMock.reset(); DummyAccount willDummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid); willDummyAccount.replaceAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, null); // WHEN displayWhen(TEST_NAME); PrismObject<ShadowType> accountWill = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); // THEN displayThen(TEST_NAME); assertSuccess(result); ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(accountWill); ResourceAttribute<Object> titleAttribute = attributesContainer.findAttribute(new QName(ResourceTypeUtil.getResourceNamespace(resourceType), DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME)); assertNull("Title attribute sneaked in", titleAttribute); accountWill.checkConsistence(); assertSteadyResource(); }
throw new SchemaException("Association attribute '"+assocAttrName+"'defined in entitlement association '"+associationName+"' was not found in schema for "+resourceType); ResourceAttribute<T> assocAttr = attributesContainer.findAttribute(assocAttrName); if (assocAttr == null || assocAttr.isEmpty()) {
throw new SchemaException("No value attribute defined in entitlement association '"+associationName+"' in "+resourceType); ResourceAttribute<T> valueAttr = attributesContainer.findAttribute(valueAttrName); if (valueAttr == null || valueAttr.isEmpty()) { LOGGER.trace("Ignoring association {} because subject does not have any value in attribute {}", associationName, valueAttrName);
if (associationDef.getResourceObjectAssociationType().getDirection() == ResourceObjectAssociationDirectionType.OBJECT_TO_SUBJECT) { QName valueAttributeName = associationDef.getResourceObjectAssociationType().getValueAttribute(); if (repoAttributesContainer.findAttribute(valueAttributeName) == null) { ResourceAttribute<Object> valueAttribute = attributesContainer.findAttribute(valueAttributeName); if (valueAttribute != null) { repoAttributesContainer.add(valueAttribute.clone());
assertFalse("Attributes container is empty", attributes.isEmpty()); assertEquals("Unexpected number of attributes", 3, attributes.size()); ResourceAttribute<?> fullnameAttribute = attributesContainer.findAttribute(new QName(ResourceTypeUtil .getResourceNamespace(resourceType), "fullname")); assertNotNull("No fullname attribute in current shadow", fullnameAttribute);
assertFalse("No identifiers (empty) in attributes container in "+accountJackOid, identifiers.isEmpty()); ResourceAttribute<String> fullNameAttr = attributesContainer.findAttribute(dummyResourceCtl.getAttributeFullnameQName()); PrismAsserts.assertPropertyValue(fullNameAttr, ACCOUNT_JACK_DUMMY_FULLNAME); ResourceAttributeDefinition<String> fullNameAttrDef = fullNameAttr.getDefinition();
throw new SchemaException("No value attribute defined in entitlement association '"+associationName+"' in "+subjectCtx.getResource()); final ResourceAttribute<T> valueAttr = subjectAttributesContainer.findAttribute(valueAttrName); if (valueAttr == null || valueAttr.isEmpty()) {