com.evolveum.midpoint.prism.schema
Class SchemaRegistry

java.lang.Object
  extended by com.evolveum.midpoint.prism.schema.SchemaRegistry
All Implemented Interfaces:
Dumpable, org.w3c.dom.ls.LSResourceResolver, org.xml.sax.EntityResolver

public class SchemaRegistry
extends java.lang.Object
implements org.w3c.dom.ls.LSResourceResolver, org.xml.sax.EntityResolver, Dumpable

Registry and resolver of schema files and resources.

Author:
Radovan Semancik

Constructor Summary
SchemaRegistry()
           
 
Method Summary
<T extends Objectable>
void
applyDefinition(ObjectDelta<T> objectDelta, java.lang.Class<T> type, boolean force)
          This method will try to locate the appropriate object definition and apply it.
 void applyDefinition(PrismObject<? extends Objectable> prismObject, java.lang.Class<? extends Objectable> type)
           
 void applyDefinition(PrismObject<? extends Objectable> prismObject, java.lang.Class<? extends Objectable> type, boolean force)
          This method will try to locate the appropriate object definition and apply it.
static ItemDefinition createDefaultItemDefinition(javax.xml.namespace.QName itemName, PrismContext prismContext)
           
 java.lang.Class<?> determineCompileTimeClass(ComplexTypeDefinition complexTypeDefinition)
           
 java.lang.Class<?> determineCompileTimeClass(javax.xml.namespace.QName typeName)
           
 java.lang.Class<?> determineCompileTimeClass(javax.xml.namespace.QName elementName, ComplexTypeDefinition complexTypeDefinition)
           
 PrismObjectDefinition determineDefinitionFromClass(java.lang.Class type)
           
 java.lang.String dump()
          Show the content of the object intended for diagnostics by developer.
 ComplexTypeDefinition findComplexTypeDefinition(javax.xml.namespace.QName typeName)
           
 PrismContainerDefinition findContainerDefinitionByElementName(javax.xml.namespace.QName elementName)
           
 PrismContainerDefinition findContainerDefinitionByType(javax.xml.namespace.QName typeName)
           
 ItemDefinition findItemDefinitionByElementName(javax.xml.namespace.QName elementName)
           
<T extends Objectable>
PrismObjectDefinition<T>
findObjectDefinitionByCompileTimeClass(java.lang.Class<T> compileTimeClass)
           
<T extends Objectable>
PrismObjectDefinition<T>
findObjectDefinitionByElementName(javax.xml.namespace.QName elementName)
           
<T extends Objectable>
PrismObjectDefinition<T>
findObjectDefinitionByType(javax.xml.namespace.QName typeName)
           
 PrismPropertyDefinition findPropertyDefinitionByElementName(javax.xml.namespace.QName elementName)
           
 PrismSchema findSchemaByCompileTimeClass(java.lang.Class<? extends Objectable> compileTimeClass)
           
 PrismSchema findSchemaByNamespace(java.lang.String namespaceURI)
           
 SchemaDescription findSchemaDescriptionByNamespace(java.lang.String namespaceURI)
           
 org.xml.sax.EntityResolver getBuiltinSchemaResolver()
           
 java.util.Collection<java.lang.Package> getCompileTimePackages()
           
 javax.xml.validation.Schema getJavaxSchema()
           
 DynamicNamespacePrefixMapper getNamespacePrefixMapper()
           
 PrismSchema getObjectSchema()
          Returns a schema that contains all the object definitions augmented with extension definitions as appropriate.
 java.lang.String getObjectSchemaNamespace()
           
 PrismContext getPrismContext()
           
 PrismSchema getSchema(java.lang.String namespace)
           
 boolean hasImplicitTypeDefinition(javax.xml.namespace.QName elementName, javax.xml.namespace.QName typeName)
          Returns true if specified element has a definition that matches specified type in the known schemas.
 void initialize()
          This can be used to read additional schemas even after the registry was initialized.
<T extends Objectable>
PrismObject<T>
instantiate(java.lang.Class<T> compileTimeClass)
           
 void loadPrismSchemaFile(java.io.File file)
           
 SchemaDescription loadPrismSchemaFileDescription(java.io.File file)
           
 void loadPrismSchemaResource(java.lang.String resourcePath)
           
 void loadPrismSchemasFromDirectory(java.io.File directory)
          This can be used to read additional schemas even after the registry was initialized.
 void registerPrismDefaultSchemaResource(java.lang.String resourcePath, java.lang.String usualPrefix, java.lang.Package compileTimeClassesPackage)
          Must be called before call to initialize()
 void registerPrismSchemaFile(java.io.File file)
           
 void registerPrismSchemaResource(java.lang.String resourcePath, java.lang.String usualPrefix)
          Must be called before call to initialize()
 void registerPrismSchemaResource(java.lang.String resourcePath, java.lang.String usualPrefix, java.lang.Package compileTimeClassesPackage)
          Must be called before call to initialize()
 void registerPrismSchemaResource(java.lang.String resourcePath, java.lang.String usualPrefix, java.lang.Package compileTimeClassesPackage, boolean defaultSchema)
          Must be called before call to initialize()
 void registerPrismSchemasFromDirectory(java.io.File directory)
           
 void registerSchema(org.w3c.dom.Node node, java.lang.String sourceDescription)
          Must be called before call to initialize()
 void registerSchema(org.w3c.dom.Node node, java.lang.String sourceDescription, java.lang.String usualPrefix)
          Must be called before call to initialize()
 void registerSchemaResource(java.lang.String resourcePath, java.lang.String usualPrefix)
          Must be called before call to initialize()
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
           
 ItemDefinition resolveGlobalItemDefinition(javax.xml.namespace.QName elementQName)
          Looks for a top-level definition for the specified element name (in all schemas).
 org.w3c.dom.ls.LSInput resolveResource(java.lang.String type, java.lang.String namespaceURI, java.lang.String publicId, java.lang.String systemId, java.lang.String baseURI)
           
 org.xml.sax.InputSource resolveResourceUsingBuiltinResolver(java.lang.String type, java.lang.String namespaceURI, java.lang.String publicId, java.lang.String systemId, java.lang.String baseURI)
           
 void setBuiltinSchemaResolver(org.xml.sax.EntityResolver builtinSchemaResolver)
           
 void setNamespacePrefixMapper(DynamicNamespacePrefixMapper namespacePrefixMapper)
           
 void setObjectSchemaNamespace(java.lang.String objectSchemaNamespace)
           
 void setPrismContext(PrismContext prismContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaRegistry

public SchemaRegistry()
Method Detail

getObjectSchemaNamespace

public java.lang.String getObjectSchemaNamespace()

setObjectSchemaNamespace

public void setObjectSchemaNamespace(java.lang.String objectSchemaNamespace)

getNamespacePrefixMapper

public DynamicNamespacePrefixMapper getNamespacePrefixMapper()

setNamespacePrefixMapper

public void setNamespacePrefixMapper(DynamicNamespacePrefixMapper namespacePrefixMapper)

getPrismContext

public PrismContext getPrismContext()

setPrismContext

public void setPrismContext(PrismContext prismContext)

getBuiltinSchemaResolver

public org.xml.sax.EntityResolver getBuiltinSchemaResolver()

setBuiltinSchemaResolver

public void setBuiltinSchemaResolver(org.xml.sax.EntityResolver builtinSchemaResolver)

registerSchemaResource

public void registerSchemaResource(java.lang.String resourcePath,
                                   java.lang.String usualPrefix)
                            throws SchemaException
Must be called before call to initialize()

Throws:
SchemaException

registerPrismSchemaResource

public void registerPrismSchemaResource(java.lang.String resourcePath,
                                        java.lang.String usualPrefix)
                                 throws SchemaException
Must be called before call to initialize()

Throws:
SchemaException

registerPrismSchemaResource

public void registerPrismSchemaResource(java.lang.String resourcePath,
                                        java.lang.String usualPrefix,
                                        java.lang.Package compileTimeClassesPackage)
                                 throws SchemaException
Must be called before call to initialize()

Throws:
SchemaException

registerPrismDefaultSchemaResource

public void registerPrismDefaultSchemaResource(java.lang.String resourcePath,
                                               java.lang.String usualPrefix,
                                               java.lang.Package compileTimeClassesPackage)
                                        throws SchemaException
Must be called before call to initialize()

Throws:
SchemaException

registerPrismSchemaResource

public void registerPrismSchemaResource(java.lang.String resourcePath,
                                        java.lang.String usualPrefix,
                                        java.lang.Package compileTimeClassesPackage,
                                        boolean defaultSchema)
                                 throws SchemaException
Must be called before call to initialize()

Throws:
SchemaException

registerSchema

public void registerSchema(org.w3c.dom.Node node,
                           java.lang.String sourceDescription)
                    throws SchemaException
Must be called before call to initialize()

Parameters:
node -
Throws:
SchemaException

registerSchema

public void registerSchema(org.w3c.dom.Node node,
                           java.lang.String sourceDescription,
                           java.lang.String usualPrefix)
                    throws SchemaException
Must be called before call to initialize()

Parameters:
node -
Throws:
SchemaException

registerPrismSchemaFile

public void registerPrismSchemaFile(java.io.File file)
                             throws java.io.FileNotFoundException,
                                    SchemaException
Throws:
java.io.FileNotFoundException
SchemaException

loadPrismSchemaFileDescription

public SchemaDescription loadPrismSchemaFileDescription(java.io.File file)
                                                 throws java.io.FileNotFoundException,
                                                        SchemaException
Throws:
java.io.FileNotFoundException
SchemaException

registerPrismSchemasFromDirectory

public void registerPrismSchemasFromDirectory(java.io.File directory)
                                       throws java.io.FileNotFoundException,
                                              SchemaException
Throws:
java.io.FileNotFoundException
SchemaException

loadPrismSchemasFromDirectory

public void loadPrismSchemasFromDirectory(java.io.File directory)
                                   throws java.io.FileNotFoundException,
                                          SchemaException
This can be used to read additional schemas even after the registry was initialized.

Throws:
java.io.FileNotFoundException
SchemaException

loadPrismSchemaFile

public void loadPrismSchemaFile(java.io.File file)
                         throws java.io.FileNotFoundException,
                                SchemaException
Throws:
java.io.FileNotFoundException
SchemaException

loadPrismSchemaResource

public void loadPrismSchemaResource(java.lang.String resourcePath)
                             throws SchemaException
Throws:
SchemaException

initialize

public void initialize()
                throws org.xml.sax.SAXException,
                       java.io.IOException,
                       SchemaException
This can be used to read additional schemas even after the registry was initialized.

Throws:
org.xml.sax.SAXException
java.io.IOException
SchemaException

getJavaxSchema

public javax.xml.validation.Schema getJavaxSchema()

getSchema

public PrismSchema getSchema(java.lang.String namespace)

getObjectSchema

public PrismSchema getObjectSchema()
Returns a schema that contains all the object definitions augmented with extension definitions as appropriate. This is the method intended for common usage in the code. The returned schema is considered to be immutable. Any attempt to change it may lead to unexpected results.


getCompileTimePackages

public java.util.Collection<java.lang.Package> getCompileTimePackages()

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
                                             java.lang.String systemId)
                                      throws org.xml.sax.SAXException,
                                             java.io.IOException
Specified by:
resolveEntity in interface org.xml.sax.EntityResolver
Throws:
org.xml.sax.SAXException
java.io.IOException

resolveResource

public org.w3c.dom.ls.LSInput resolveResource(java.lang.String type,
                                              java.lang.String namespaceURI,
                                              java.lang.String publicId,
                                              java.lang.String systemId,
                                              java.lang.String baseURI)
Specified by:
resolveResource in interface org.w3c.dom.ls.LSResourceResolver

resolveResourceUsingBuiltinResolver

public org.xml.sax.InputSource resolveResourceUsingBuiltinResolver(java.lang.String type,
                                                                   java.lang.String namespaceURI,
                                                                   java.lang.String publicId,
                                                                   java.lang.String systemId,
                                                                   java.lang.String baseURI)

dump

public java.lang.String dump()
Description copied from interface: Dumpable
Show the content of the object intended for diagnostics by developer. The content may be multi-line, in case of hierarchical objects it may be intended. The use of this method may not be efficient. It is not supposed to be used in normal operation. However, it is very useful in tests or in case of dumping objects in severe error situations.

Specified by:
dump in interface Dumpable
Returns:
content of the object intended for diagnostics.

determineCompileTimeClass

public java.lang.Class<?> determineCompileTimeClass(javax.xml.namespace.QName elementName,
                                                    ComplexTypeDefinition complexTypeDefinition)

determineCompileTimeClass

public java.lang.Class<?> determineCompileTimeClass(ComplexTypeDefinition complexTypeDefinition)

determineCompileTimeClass

public java.lang.Class<?> determineCompileTimeClass(javax.xml.namespace.QName typeName)

findSchemaByCompileTimeClass

public PrismSchema findSchemaByCompileTimeClass(java.lang.Class<? extends Objectable> compileTimeClass)

findObjectDefinitionByCompileTimeClass

public <T extends Objectable> PrismObjectDefinition<T> findObjectDefinitionByCompileTimeClass(java.lang.Class<T> compileTimeClass)

applyDefinition

public void applyDefinition(PrismObject<? extends Objectable> prismObject,
                            java.lang.Class<? extends Objectable> type)
                     throws SchemaException
Throws:
SchemaException

applyDefinition

public void applyDefinition(PrismObject<? extends Objectable> prismObject,
                            java.lang.Class<? extends Objectable> type,
                            boolean force)
                     throws SchemaException
This method will try to locate the appropriate object definition and apply it.

Throws:
SchemaException

applyDefinition

public <T extends Objectable> void applyDefinition(ObjectDelta<T> objectDelta,
                                                   java.lang.Class<T> type,
                                                   boolean force)
                     throws SchemaException
This method will try to locate the appropriate object definition and apply it.

Throws:
SchemaException

findObjectDefinitionByType

public <T extends Objectable> PrismObjectDefinition<T> findObjectDefinitionByType(javax.xml.namespace.QName typeName)

findObjectDefinitionByElementName

public <T extends Objectable> PrismObjectDefinition<T> findObjectDefinitionByElementName(javax.xml.namespace.QName elementName)

findContainerDefinitionByType

public PrismContainerDefinition findContainerDefinitionByType(javax.xml.namespace.QName typeName)

findContainerDefinitionByElementName

public PrismContainerDefinition findContainerDefinitionByElementName(javax.xml.namespace.QName elementName)

findItemDefinitionByElementName

public ItemDefinition findItemDefinitionByElementName(javax.xml.namespace.QName elementName)

findPropertyDefinitionByElementName

public PrismPropertyDefinition findPropertyDefinitionByElementName(javax.xml.namespace.QName elementName)

findComplexTypeDefinition

public ComplexTypeDefinition findComplexTypeDefinition(javax.xml.namespace.QName typeName)

findSchemaByNamespace

public PrismSchema findSchemaByNamespace(java.lang.String namespaceURI)

findSchemaDescriptionByNamespace

public SchemaDescription findSchemaDescriptionByNamespace(java.lang.String namespaceURI)

determineDefinitionFromClass

public PrismObjectDefinition determineDefinitionFromClass(java.lang.Class type)

hasImplicitTypeDefinition

public boolean hasImplicitTypeDefinition(javax.xml.namespace.QName elementName,
                                         javax.xml.namespace.QName typeName)
Returns true if specified element has a definition that matches specified type in the known schemas.


createDefaultItemDefinition

public static ItemDefinition createDefaultItemDefinition(javax.xml.namespace.QName itemName,
                                                         PrismContext prismContext)

resolveGlobalItemDefinition

public ItemDefinition resolveGlobalItemDefinition(javax.xml.namespace.QName elementQName)
                                           throws SchemaException
Looks for a top-level definition for the specified element name (in all schemas).

Throws:
SchemaException

instantiate

public <T extends Objectable> PrismObject<T> instantiate(java.lang.Class<T> compileTimeClass)
                                              throws SchemaException
Throws:
SchemaException


Copyright © 2012 evolveum. All Rights Reserved.