use of com.evolveum.prism.xml.ns._public.types_3.SchemaDefinitionType in project midpoint by Evolveum.
the class ResourceManager method createSchemaUpdateDelta.
private ContainerDelta<XmlSchemaType> createSchemaUpdateDelta(PrismObject<ResourceType> resource, ResourceSchema resourceSchema) throws SchemaException {
Document xsdDoc = null;
try {
// Convert to XSD
LOGGER.trace("Serializing XSD resource schema for {} to DOM", resource);
xsdDoc = resourceSchema.serializeToXsd();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Serialized XSD resource schema for {}:\n{}", resource, DOMUtil.serializeDOMToString(xsdDoc));
}
} catch (SchemaException e) {
throw new SchemaException("Error processing resource schema for " + resource + ": " + e.getMessage(), e);
}
Element xsdElement = DOMUtil.getFirstChildElement(xsdDoc);
if (xsdElement == null) {
throw new SchemaException("No schema was generated for " + resource);
}
CachingMetadataType cachingMetadata = MiscSchemaUtil.generateCachingMetadata();
// Store generated schema into repository (modify the original
// Resource)
LOGGER.info("Storing generated schema in resource {}", resource);
ContainerDelta<XmlSchemaType> schemaContainerDelta = ContainerDelta.createDelta(ResourceType.F_SCHEMA, ResourceType.class, prismContext);
PrismContainerValue<XmlSchemaType> cval = new PrismContainerValue<XmlSchemaType>(prismContext);
schemaContainerDelta.setValueToReplace(cval);
PrismProperty<CachingMetadataType> cachingMetadataProperty = cval.createProperty(XmlSchemaType.F_CACHING_METADATA);
cachingMetadataProperty.setRealValue(cachingMetadata);
List<QName> objectClasses = ResourceTypeUtil.getSchemaGenerationConstraints(resource);
if (objectClasses != null) {
PrismProperty<SchemaGenerationConstraintsType> generationConstraints = cval.createProperty(XmlSchemaType.F_GENERATION_CONSTRAINTS);
SchemaGenerationConstraintsType constraints = new SchemaGenerationConstraintsType();
constraints.getGenerateObjectClass().addAll(objectClasses);
generationConstraints.setRealValue(constraints);
}
PrismProperty<SchemaDefinitionType> definitionProperty = cval.createProperty(XmlSchemaType.F_DEFINITION);
ObjectTypeUtil.setXsdSchemaDefinition(definitionProperty, xsdElement);
return schemaContainerDelta;
}
use of com.evolveum.prism.xml.ns._public.types_3.SchemaDefinitionType in project midpoint by Evolveum.
the class ObjectTypeUtil method findXsdElement.
public static Element findXsdElement(PrismContainerValue<XmlSchemaType> xmlSchemaContainerValue) {
PrismProperty<SchemaDefinitionType> definitionProperty = xmlSchemaContainerValue.findProperty(XmlSchemaType.F_DEFINITION);
if (definitionProperty == null) {
return null;
}
SchemaDefinitionType schemaDefinition = definitionProperty.getValue().getValue();
if (schemaDefinition == null) {
return null;
}
return schemaDefinition.getSchema();
// List<Element> schemaElements = DOMUtil.listChildElements(definitionElement);
// for (Element e : schemaElements) {
// if (QNameUtil.compareQName(DOMUtil.XSD_SCHEMA_ELEMENT, e)) {
// DOMUtil.fixNamespaceDeclarations(e);
// return e;
// }
// }
// return null;
}
Aggregations