@Override public boolean canAdd() { if (overrideCanAdd != null) { return overrideCanAdd; } return refinedAttributeDefinition.canAdd(layer); }
@Override public boolean canModify() { if (overrideCanModify != null) { return overrideCanModify; } return refinedAttributeDefinition.canModify(layer); }
@Override public boolean canRead() { if (overrideCanRead != null) { return overrideCanRead; } return refinedAttributeDefinition.canRead(layer); }
@Override public Collection<? extends QName> getNamesOfAttributesWithOutboundExpressions() { return getAttributeDefinitions().stream() .filter(attrDef -> attrDef.getOutboundMappingType() != null) .map(attrDef -> attrDef.getName()) .collect(Collectors.toCollection(HashSet::new)); }
@Override public Collection<? extends QName> getNamesOfAttributesWithInboundExpressions() { return getAttributeDefinitions().stream() .filter(attrDef -> CollectionUtils.isNotEmpty(attrDef.getInboundMappingTypes())) .map(attrDef -> attrDef.getName()) .collect(Collectors.toCollection(HashSet::new)); }
public static <T> ValueMatcher<T> createMatcher(RefinedAttributeDefinition rAttrDef, MatchingRuleRegistry matchingRuleRegistry) throws SchemaException { QName matchingRuleQName = rAttrDef.getMatchingRuleQName(); MatchingRule<T> matchingRule; try { matchingRule = matchingRuleRegistry.getMatchingRule(matchingRuleQName, rAttrDef.getTypeName()); } catch (SchemaException e) { throw new SchemaException(e.getMessage()+", defined for attribute "+rAttrDef.getName(), e); } return new ValueMatcher<>(matchingRule); }
assertEquals(1, uidDef.getMaxOccurs()); assertEquals(0, uidDef.getMinOccurs()); assertFalse("No UID display name", StringUtils.isBlank(uidDef.getDisplayName())); assertFalse("UID has create", uidDef.canAdd()); assertFalse("UID has update",uidDef.canModify()); assertTrue("No UID read",uidDef.canRead()); assertTrue("UID definition not in identifiers", accountDef.getPrimaryIdentifiers().contains(uidDef)); assertEquals(1, nameDef.getMaxOccurs()); assertEquals(1, nameDef.getMinOccurs()); assertFalse("No NAME displayName", StringUtils.isBlank(nameDef.getDisplayName())); assertTrue("No NAME create", nameDef.canAdd()); assertTrue("No NAME update",nameDef.canModify()); assertTrue("No NAME read",nameDef.canRead()); assertTrue("NAME definition not in identifiers", accountDef.getSecondaryIdentifiers().contains(nameDef)); assertEquals(1, fullnameDef.getMaxOccurs()); assertEquals(1, fullnameDef.getMinOccurs()); assertTrue("No fullname create", fullnameDef.canAdd()); assertTrue("No fullname update", fullnameDef.canModify()); assertTrue("No fullname read", fullnameDef.canRead());
private void assertAttributeDef(Collection<? extends RefinedAttributeDefinition> attrDefs, QName name, QName typeName, int minOccurs, int maxOccurs, String displayName, Integer displayOrder, boolean hasOutbound, boolean ignore, boolean canCreate, boolean canRead, boolean canUpdate, LayerType sourceLayer, LayerType validationLayer) { for (RefinedAttributeDefinition def : attrDefs) { if (def.getName().equals(name)) { assertEquals("Attribute " + name + " ("+sourceLayer+") type mismatch", typeName, def.getTypeName()); assertEquals("Attribute " + name + " ("+sourceLayer+") minOccurs mismatch", minOccurs, def.getMinOccurs()); assertEquals("Attribute " + name + " ("+sourceLayer+") maxOccurs mismatch", maxOccurs, def.getMaxOccurs()); if (validationLayer == LayerType.MODEL || validationLayer == LayerType.PRESENTATION) { assertEquals("Attribute " + name + " ("+sourceLayer+") displayName mismatch", displayName, def.getDisplayName()); assertEquals("Attribute " + name + " ("+sourceLayer+") displayOrder mismatch", displayOrder, def.getDisplayOrder()); assertEquals("Attribute " + name + " ("+sourceLayer+") outbound mismatch", hasOutbound, def.getOutboundMappingType() != null); } assertEquals("Attribute " + name + " ("+sourceLayer+") ignored flag mismatch", ignore, def.isIgnored()); assertEquals("Attribute " + name + " ("+sourceLayer+") canCreate mismatch", canCreate, def.canAdd()); assertEquals("Attribute " + name + " ("+sourceLayer+") canRead mismatch", canRead, def.canRead()); assertEquals("Attribute " + name + " ("+sourceLayer+") canUpdate mismatch", canUpdate, def.canModify()); return; } } Assert.fail("Attribute " + name + " not found"); }
assertEquals(1, idPrimaryDef.getMaxOccurs()); assertEquals(0, idPrimaryDef.getMinOccurs()); assertFalse("UID has create", idPrimaryDef.canAdd()); assertFalse("UID has update", idPrimaryDef.canModify()); assertTrue("No UID read", idPrimaryDef.canRead()); assertTrue("UID definition not in identifiers", accountDef.getPrimaryIdentifiers().contains(idPrimaryDef)); assertEquals("Wrong "+OpenDJController.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME+" frameworkAttributeName", ProvisioningTestUtil.CONNID_UID_NAME, idPrimaryDef.getFrameworkAttributeName()); assertEquals(1, idSecondaryDef.getMaxOccurs()); assertEquals(1, idSecondaryDef.getMinOccurs()); assertTrue("No NAME create", idSecondaryDef.canAdd()); assertTrue("No NAME update", idSecondaryDef.canModify()); assertTrue("No NAME read", idSecondaryDef.canRead()); assertTrue("NAME definition not in identifiers", accountDef.getSecondaryIdentifiers().contains(idSecondaryDef)); assertEquals("Wrong NAME matching rule", PrismConstants.DISTINGUISHED_NAME_MATCHING_RULE_NAME, idSecondaryDef.getMatchingRuleQName()); assertEquals("Wrong "+OpenDJController.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME+" frameworkAttributeName", ProvisioningTestUtil.CONNID_NAME_NAME, idSecondaryDef.getFrameworkAttributeName()); assertEquals(-1, cnDef.getMaxOccurs()); assertEquals(1, cnDef.getMinOccurs()); assertTrue("No cn create", cnDef.canAdd()); assertTrue("No cn update", cnDef.canModify()); assertTrue("No cn read", cnDef.canRead()); assertEquals(1, dsDef.getMaxOccurs()); assertEquals(0, dsDef.getMinOccurs()); assertTrue("No ds-pwp-account-disabled create", dsDef.canAdd()); assertTrue("No ds-pwp-account-disabled update", dsDef.canModify()); assertTrue("No ds-pwp-account-disabled read", dsDef.canRead());
<T> T getNormalizedAttributeValue(PrismPropertyValue<T> pval, RefinedAttributeDefinition rAttrDef) throws SchemaException { MatchingRule<T> matchingRule = matchingRuleRegistry.getMatchingRule(rAttrDef.getMatchingRuleQName(), rAttrDef.getTypeName()); if (matchingRule != null) { T normalizedRealValue = matchingRule.normalize(pval.getValue()); return normalizedRealValue; } else { return pval.getValue(); } }
private void doCheckNormalization(ShadowCheckResult checkResult, RefinedAttributeDefinition<?> identifier, String value, ObjectTypeContext context) throws SchemaException { QName matchingRuleQName = identifier.getMatchingRuleQName(); if (matchingRuleQName == null) { return; matchingRule = matchingRuleRegistry.getMatchingRule(matchingRuleQName, identifier.getTypeName()); } catch (SchemaException e) { checkResult.recordError( ShadowStatistics.OTHER_FAILURE, new SchemaException("Couldn't retrieve matching rule for identifier " + identifier.getName() + " (rule name = " + matchingRuleQName + ")")); return; checkResult.recordError( ShadowStatistics.OTHER_FAILURE, new SchemaException("Normalized value is not a string, it's " + normalizedValue.getClass() + " (identifier " + identifier.getName() + ", value " + value)); return; new SchemaException("Non-normalized value of identifier " + identifier.getName() + ": " + value + " (normalized form: " + normalizedValue + ")")); PropertyDelta delta = identifier.createEmptyDelta(ItemPath.create(ShadowType.F_ATTRIBUTES, identifier.getName())); delta.setRealValuesToReplace(normalizedStringValue); checkResult.addFixDelta(delta, ShadowStatistics.NON_NORMALIZED_IDENTIFIER_VALUE);
protected void assertAttributeFlags(RefinedObjectClassDefinition rOcDef, QName attrName, boolean expectedRead, boolean expectedAdd, boolean expectedModify) { RefinedAttributeDefinition rAttrDef = rOcDef.findAttributeDefinition(attrName); assertEquals("Wrong readability flag for "+attrName, expectedRead, rAttrDef.canRead()); assertEquals("Wrong addition flag for "+attrName, expectedAdd, rAttrDef.canAdd()); assertEquals("Wrong modification flag for "+attrName, expectedModify, rAttrDef.canModify()); }
PrismProperty<Object> currentResourceAttrProperty = (PrismProperty<Object>) 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) { if (attrDef.isSingleValue()) { Object currentResourceRealValue = currentResourceAttrProperty.getRealValue(); Object currentResourceNormalizedRealValue; 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) {
squeezedAttributes != null ? (DeltaSetTriple) squeezedAttributes.get(attrName) : null; if (attributeDefinition.isIgnored(LayerType.MODEL)) { LOGGER.trace("Skipping reconciliation of attribute {} because it is ignored", attrName); return; PropertyLimitations limitations = attributeDefinition.getLimitations(LayerType.MODEL); if (limitations != null) { PropertyAccessType access = limitations.getAccess(); LOGGER.trace("Skipping reconciliation of value {} of the attribute {}: the mapping is not strong", shouldBeRealValue, attributeDefinition.getName().getLocalPart()); continue; if (attributeDefinition.isSingleValue()) {
assertTrue("ds-pwp-account-disabled not ignored", disabledAttribute.isIgnored()); displayNameAttributeDef.getName()); assertNotNull("No entitlement displayNameAttribute", entDisplayNameAttributeDef); assertEquals("Wrong entitlement displayNameAttribute", new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "dn"), entDisplayNameAttributeDef.getName());
final String intent = def(refinedDefinition.getIntent()); for (RefinedAttributeDefinition<?> attributeDefinition : attributeDefinitions) { if (attributeDefinition.isIgnored()) { continue; LOGGER.debug("Processing refined attribute definition for {}", attributeDefinition.getName()); ResourceDataItem attrItem = model.findResourceItem(resource.getOid(), kind, intent, getObjectClassName(refinedDefinition), ItemPath.create(attributeDefinition.getName())); if (attributeDefinition.getOutboundMappingType() != null) { processOutboundMapping(model, attrItem, attributeDefinition.getOutboundMappingType(), null); processInboundMappings(model, attrItem, attributeDefinition.getInboundMappingTypes());
@Override @NotNull public ItemName getName() { return refinedAttributeDefinition.getName(); }
} else { attrProperty.applyDefinition(attrDef); MatchingRule matchingRule = matchingRuleRegistry.getMatchingRule(attrDef.getMatchingRuleQName(), attrDef.getTypeName()); List<Object> valuesToAdd = null; List<Object> valuesToDelete = null; Object normalizedRealValue = matchingRule.normalize(currentRealValue); if (!normalizedRealValue.equals(currentRealValue)) { if (attrDef.isSingleValue()) { shadowDelta.addModificationReplaceProperty(attrProperty.getPath(), normalizedRealValue); break;
@Override public QName getMatchingRuleQName() { return refinedAttributeDefinition.getMatchingRuleQName(); }
@NotNull @Override public ResourceAttribute<T> instantiate() { return refinedAttributeDefinition.instantiate(); }