public void applyDefinition(D def, boolean force) throws SchemaException { if (itemNew != null) { itemNew.applyDefinition(def, force); } if (itemOld != null) { itemOld.applyDefinition(def, force); } if (delta != null) { delta.applyDefinition(def, force); } }
public void applyDefinition(PrismObjectDefinition<O> objectDefinition, boolean force) throws SchemaException { if (objectToAdd != null) { objectToAdd.applyDefinition(objectDefinition, force); } for (ItemDelta modification: modifications) { ItemPath path = modification.getPath(); ItemDefinition itemDefinition = objectDefinition.findItemDefinition(path); modification.applyDefinition(itemDefinition, force); } }
public static void applyDefinitionIfPresent(Collection<? extends ItemDelta> deltas, PrismObjectDefinition definition, boolean tolerateNoDefinition) throws SchemaException { for (ItemDelta itemDelta : deltas) { ItemPath path = itemDelta.getPath(); ItemDefinition itemDefinition = ((ItemDefinition) definition).findItemDefinition(path, ItemDefinition.class); if (itemDefinition != null) { itemDelta.applyDefinition(itemDefinition); } else if (!tolerateNoDefinition) { throw new SchemaException("Object type " + definition.getTypeName() + " doesn't contain definition for path " + path); } } }
public static void applyConfigurationDefinition(PrismObject<ReportType> report, ObjectDelta delta, PrismContext prismContext) throws SchemaException { PrismSchema schema = ReportTypeUtil.parseReportConfigurationSchema(report, prismContext); PrismContainerDefinition<ReportConfigurationType> definition = ReportTypeUtil.findReportConfigurationDefinition(schema); if (definition == null) { //no definition found for container throw new SchemaException("Couldn't find definitions for report type " + report + "."); } Collection<ItemDelta> modifications = delta.getModifications(); for (ItemDelta itemDelta : modifications){ if (itemDelta.hasCompleteDefinition()){ continue; } ItemDefinition def = definition.findItemDefinition(itemDelta.getPath().rest()); if (def != null){ itemDelta.applyDefinition(def); } } } }
ItemDefinition<?> def = objectDefinition.findItemDefinition(itemDelta.getPath()); if (def != null) { itemDelta.applyDefinition(def);
private <V extends PrismValue, D extends ItemDefinition> void applyItemDefinition(ItemDelta<V,D> itemDelta, PrismContainerDefinition<ConnectorConfigurationType> configContainerDef, OperationResult objectResult) throws SchemaException { if (itemDelta.getParentPath() == null){ LOGGER.trace("No parent path defined for item delta {}", itemDelta); return; } QName first = itemDelta.getParentPath().firstToNameOrNull(); if (first == null) { return; } if (itemDelta.getDefinition() == null && (ResourceType.F_CONNECTOR_CONFIGURATION.equals(first) || ResourceType.F_SCHEMA.equals(first))){ ItemPath path = itemDelta.getPath().rest(); D itemDef = configContainerDef.findItemDefinition(path); if (itemDef == null){ LOGGER.warn("No definition found for item {}. Check your namespaces?", path); objectResult.recordWarning("No definition found for item delta: " + itemDelta +". Check your namespaces?" ); // throw new SchemaException("No definition found for item " + path+ ". Check your namespaces?" ); return; } itemDelta.applyDefinition(itemDef); } }
private <V extends PrismValue, D extends ItemDefinition> void applyAttributeDefinition( ProvisioningContext ctx, ObjectDelta<ShadowType> delta, ItemDelta<V, D> itemDelta) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException { if (!SchemaConstants.PATH_ATTRIBUTES.equivalent(itemDelta.getParentPath())) { // just to be sure return; } D itemDef = itemDelta.getDefinition(); if (itemDef == null || !(itemDef instanceof ResourceAttributeDefinition)) { QName attributeName = itemDelta.getElementName(); ResourceAttributeDefinition attributeDefinition = ctx.getObjectClassDefinition() .findAttributeDefinition(attributeName); if (attributeDefinition == null) { throw new SchemaException( "No definition for attribute " + attributeName + " in object delta " + delta); } if (itemDef != null) { // We are going to rewrite the definition anyway. Let's just do // some basic checks first if (!QNameUtil.match(itemDef.getTypeName(), attributeDefinition.getTypeName())) { throw new SchemaException("The value of type " + itemDef.getTypeName() + " cannot be applied to attribute " + attributeName + " which is of type " + attributeDefinition.getTypeName()); } } itemDelta.applyDefinition((D) attributeDefinition); } }