@NotNull private Class<?> getAttributeValueClass(ProvisioningContext ctx, ShadowType shadow, ResourceAttribute<?> attribute, @NotNull ActivationStatusCapabilityType capActStatus) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException { ResourceAttributeDefinition attributeDefinition = attribute.getDefinition(); Class<?> attributeValueClass = attributeDefinition != null ? attributeDefinition.getTypeClassIfKnown() : null; if (attributeValueClass == null) { LOGGER.warn("No definition for simulated administrative status attribute {} for shadow {} on {}, assuming String", attribute, shadow, ctx.getResource()); attributeValueClass = String.class; } return attributeValueClass; }
private ResourceAttributeDefinition getNameDefinition(ResourceObjectIdentification identification) throws SchemaException { ResourceAttribute<String> secondaryIdentifier = identification.getSecondaryIdentifier(); if (secondaryIdentifier == null) { // fallback, compatibility for (ResourceAttribute<?> attr : identification.getAllIdentifiers()) { if (attr.getElementName().equals(SchemaConstants.ICFS_NAME)) { return attr.getDefinition(); } } return null; } return secondaryIdentifier.getDefinition(); }
private ResourceAttributeDefinition getUidDefinition(ResourceObjectIdentification identification) throws SchemaException { ResourceAttribute<String> primaryIdentifier = identification.getPrimaryIdentifier(); if (primaryIdentifier == null) { // fallback, compatibility for (ResourceAttribute<?> attr : identification.getAllIdentifiers()) { if (attr.getElementName().equals(SchemaConstants.ICFS_UID)) { return attr.getDefinition(); } } return null; } return primaryIdentifier.getDefinition(); }
public static ResourceAttribute<?> getSecondaryIdentifier(ObjectClassComplexTypeDefinition objectClassDefinition, Collection<? extends ResourceAttribute<?>> identifiers) throws SchemaException { if (identifiers == null) { return null; } ResourceAttribute<?> secondaryIdentifier = null; for (ResourceAttribute<?> identifier: identifiers) { if (identifier.getDefinition().isSecondaryIdentifier(objectClassDefinition)) { if (secondaryIdentifier != null) { throw new SchemaException("More than one secondary identifier in "+objectClassDefinition); } secondaryIdentifier = identifier; } } return secondaryIdentifier; }
private String getNameValue(ResourceObjectIdentification resourceObjectIdentification) throws SchemaException { Collection<? extends ResourceAttribute<?>> secondaryIdentifiers = resourceObjectIdentification.getSecondaryIdentifiers(); if (secondaryIdentifiers == null) { return null; } if (secondaryIdentifiers.size() == 1) { return (String) secondaryIdentifiers.iterator().next().getRealValue(); } else if (secondaryIdentifiers.size() > 1) { for (ResourceAttribute<?> secondaryIdentifier : secondaryIdentifiers) { ResourceAttributeDefinition<?> definition = secondaryIdentifier.getDefinition(); if (definition != null) { if (Name.NAME.equals(definition.getFrameworkAttributeName())) { return (String) secondaryIdentifier.getRealValue(); } } } throw new SchemaException("More than one secondary indentifier in "+resourceObjectIdentification+", cannot detemine ConnId __NAME__"); } return null; }
public String convertAttributeNameToConnId(ResourceAttribute<?> attribute, ObjectClassComplexTypeDefinition ocDef) throws SchemaException { ResourceAttributeDefinition attrDef = attribute.getDefinition(); if (attrDef == null) { attrDef = ocDef.findAttributeDefinition(attribute.getElementName()); if (attrDef == null) { throw new SchemaException("No attribute "+attribute.getElementName()+" in object class "+ocDef.getTypeName()); } } return convertAttributeNameToConnId(attrDef); }
private <T> ObjectFilter createAttributeEqualFilter(ProvisioningContext ctx, ResourceAttribute<T> secondaryIdentifier) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException { return prismContext.queryFor(ShadowType.class) .item(secondaryIdentifier.getPath(), secondaryIdentifier.getDefinition()) .eq(getNormalizedValue(secondaryIdentifier, ctx.getObjectClassDefinition())) .buildFilter(); }
public static void assertAttributeDefinition(ResourceAttribute<?> attr, QName expectedType, int minOccurs, int maxOccurs, boolean canRead, boolean canCreate, boolean canUpdate, Class<?> expectedAttributeDefinitionClass) { ResourceAttributeDefinition definition = attr.getDefinition(); QName attrName = attr.getElementName(); assertNotNull("No definition for attribute "+attrName, definition); //assertEquals("Wrong class of definition for attribute"+attrName, expetcedAttributeDefinitionClass, definition.getClass()); assertTrue("Wrong class of definition for attribute"+attrName+" (expected: " + expectedAttributeDefinitionClass + ", real: " + definition.getClass() + ")", expectedAttributeDefinitionClass.isAssignableFrom(definition.getClass())); assertEquals("Wrong type in definition for attribute"+attrName, expectedType, definition.getTypeName()); assertEquals("Wrong minOccurs in definition for attribute"+attrName, minOccurs, definition.getMinOccurs()); assertEquals("Wrong maxOccurs in definition for attribute"+attrName, maxOccurs, definition.getMaxOccurs()); assertEquals("Wrong canRead in definition for attribute"+attrName, canRead, definition.canRead()); assertEquals("Wrong canCreate in definition for attribute"+attrName, canCreate, definition.canAdd()); assertEquals("Wrong canUpdate in definition for attribute"+attrName, canUpdate, definition.canModify()); }
private PropertyModificationOperation convertToSimulatedActivationLockoutStatusAttribute(ProvisioningContext ctx, PropertyDelta activationDelta, ShadowType shadow, LockoutStatusType status, ActivationCapabilityType activationCapability, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException { ActivationLockoutStatusCapabilityType capActStatus = getActivationLockoutStatusFromSimulatedActivation(ctx, activationCapability, shadow, result); if (capActStatus == null){ throw new SchemaException("Attempt to modify lockout on "+ctx.getResource()+" which does not have activation lockout capability"); } ResourceAttribute<?> activationAttribute = getSimulatedActivationLockoutStatusAttribute(ctx, shadow, capActStatus, result); if (activationAttribute == null){ return null; } PropertyDelta<?> lockoutAttributeDelta = null; if (status == null && activationDelta.isDelete()){ LOGGER.trace("deleting activation property."); lockoutAttributeDelta = prismContext.deltaFactory().property().createModificationDeleteProperty(ItemPath.create(ShadowType.F_ATTRIBUTES, activationAttribute.getElementName()), activationAttribute.getDefinition(), activationAttribute.getRealValue()); } else if (status == LockoutStatusType.NORMAL) { String normalValue = getLockoutNormalValue(capActStatus); lockoutAttributeDelta = createActivationPropDelta(activationAttribute.getElementName(), activationAttribute.getDefinition(), normalValue); } else { String lockedValue = getLockoutLockedValue(capActStatus); lockoutAttributeDelta = createActivationPropDelta(activationAttribute.getElementName(), activationAttribute.getDefinition(), lockedValue); } PropertyModificationOperation attributeChange = new PropertyModificationOperation(lockoutAttributeDelta); return attributeChange; }
LOGGER.trace("- updating identifier {} value of {}", attributeName, attribute.getValues()); rv.add(prismContext.deltaFor(ShadowType.class) .item(ItemPath.create(ShadowType.F_ATTRIBUTES, attributeName), attribute.getDefinition()).replace(valuesToReplace) .asItemDelta()); QNameUtil.remove(outstandingInRepo, attributeName);
private PropertyModificationOperation convertToSimulatedActivationAdministrativeStatusAttribute(ProvisioningContext ctx, PropertyDelta activationDelta, ShadowType shadow, ActivationStatusType status, ActivationCapabilityType activationCapabilityType, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException { ResourceType resource = ctx.getResource(); ActivationStatusCapabilityType capActStatus = getActivationAdministrativeStatusFromSimulatedActivation(ctx, activationCapabilityType, shadow, result); if (capActStatus == null){ throw new SchemaException("Attempt to modify activation on "+resource+" which does not have activation capability"); } ResourceAttribute<?> simulatedAttribute = getSimulatedActivationAdministrativeStatusAttribute(ctx, shadow, capActStatus, result); if (simulatedAttribute == null) { return null; } Class<?> simulatedAttrValueClass = getAttributeValueClass(ctx, shadow, simulatedAttribute, capActStatus); PropertyDelta<?> simulatedAttrDelta; if (status == null && activationDelta.isDelete()){ LOGGER.trace("deleting activation property."); simulatedAttrDelta = prismContext.deltaFactory().property().createModificationDeleteProperty( ItemPath.create(ShadowType.F_ATTRIBUTES, simulatedAttribute.getElementName()), simulatedAttribute.getDefinition(), simulatedAttribute.getRealValue()); } else if (status == ActivationStatusType.ENABLED) { Object enableValue = getEnableValue(capActStatus, simulatedAttrValueClass); simulatedAttrDelta = createActivationPropDelta(simulatedAttribute.getElementName(), simulatedAttribute.getDefinition(), enableValue); } else { Object disableValue = getDisableValue(capActStatus, simulatedAttrValueClass); simulatedAttrDelta = createActivationPropDelta(simulatedAttribute.getElementName(), simulatedAttribute.getDefinition(), disableValue); } PropertyModificationOperation attributeChange = new PropertyModificationOperation(simulatedAttrDelta); return attributeChange; }
private <TV,TA> ObjectQuery createQuery(RefinedAssociationDefinition assocDefType, RefinedAttributeDefinition<TA> assocAttrDef, ResourceAttribute<TV> valueAttr) throws SchemaException{ MatchingRule<TA> matchingRule = matchingRuleRegistry.getMatchingRule(assocDefType.getResourceObjectAssociationType().getMatchingRule(), assocAttrDef.getTypeName()); if (valueAttr.size() > 1) { throw new IllegalStateException("Attributes with more than 1 values are not supported here"); } PrismPropertyValue<TA> converted = PrismUtil.convertPropertyValue(valueAttr.getAnyValue(), valueAttr.getDefinition(), assocAttrDef, prismContext); TA normalizedRealValue = matchingRule.normalize(converted.getValue()); PrismPropertyValue<TA> normalized = prismContext.itemFactory().createPropertyValue(normalizedRealValue); LOGGER.trace("Converted entitlement filter value: {} ({}) def={}", normalized, normalized.getValue().getClass(), assocAttrDef); ObjectQuery query = prismContext.queryFor(ShadowType.class) .item(ItemPath.create(ShadowType.F_ATTRIBUTES, assocAttrDef.getName()), assocAttrDef).eq(normalized) .build(); query.setAllowPartialResults(true); return query; }
q = q.item(secondaryIdentifier.getPath(), secondaryIdentifier.getDefinition()) .eq(getNormalizedValue(secondaryIdentifier, ctx.getObjectClassDefinition())) .or();
ResourceAttributeDefinition<String> fullNameAttrDef = fullNameAttr.getDefinition(); display("attribute fullname definition", fullNameAttrDef); PrismAsserts.assertDefinition(fullNameAttrDef, dummyResourceCtl.getAttributeFullnameQName(),