Package com.evolveum.midpoint.prism.impl
Class PrismContextImpl
- java.lang.Object
-
- com.evolveum.midpoint.prism.impl.PrismContextImpl
-
- All Implemented Interfaces:
ProtectorCreator
,PrismContext
public final class PrismContextImpl extends Object implements PrismContext
- Author:
- semancik
-
-
Field Summary
-
Fields inherited from interface com.evolveum.midpoint.prism.PrismContext
LANG_JSON, LANG_XML, LANG_YAML
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
adopt(Containerable containerable)
<T extends Objectable>
voidadopt(ObjectDelta<T> delta)
void
adopt(Objectable objectable)
<C extends Containerable>
voidadopt(PrismContainer<C> container)
<C extends Containerable>
voidadopt(PrismContainer<C> container, Class<C> declaredType)
Set up the specified object with prism context instance and schema definition.void
adopt(PrismContainerValue value)
<C extends Containerable,O extends Objectable>
voidadopt(PrismContainerValue<C> prismContainerValue, Class<O> type, ItemPath path)
<C extends Containerable,O extends Objectable>
voidadopt(PrismContainerValue<C> prismContainerValue, QName typeName, ItemPath path)
<C extends Containerable,O extends Objectable>
voidadopt(C containerable, Class<O> type, ItemPath path)
boolean
canSerialize(Object value)
TODOvoid
configurePolyStringNormalizer(PolyStringNormalizerConfigurationType configuration)
static PrismContextImpl
create(SchemaRegistryImpl schemaRegistry)
CanonicalItemPath
createCanonicalItemPath(ItemPath itemPath)
TemporaryCanonicalItemPath
createCanonicalItemPath(ItemPath itemPath, Class<? extends Containerable> clazz)
Temporarystatic PrismContextImpl
createEmptyContext(SchemaRegistryImpl schemaRegistry)
KeyStoreBasedProtector
createInitializedProtector(KeyStoreBasedProtectorBuilder builder)
Creates initialized KeyStoreBasedProtector according to configured KeyStoreBasedProtectorBuilder object.<O extends Objectable>
PrismObject<O>createKnownObject(Class<O> clazz)
Creates a new PrismObject of a given static type.<O extends Objectable>
OcreateKnownObjectable(Class<O> clazz)
Creates a new Objectable of a given static type.<T extends Objectable>
PrismObject<T>createObject(Class<T> clazz)
Creates a new PrismObject of a given type.<T extends Objectable>
TcreateObjectable(Class<T> clazz)
Creates a new Objectable of a given type.ParsingContext
createParsingContextForAllowMissingRefTypes()
ParsingContext
createParsingContextForCompatibilityMode()
KeyStoreBasedProtector
createProtector(KeyStoreBasedProtectorBuilder builder)
Creates uninitialized KeyStoreBasedProtector according to configured KeyStoreBasedProtectorBuilder object.DefinitionFactory
definitionFactory()
DeltaFactory
deltaFactory()
<C extends Containerable>
S_ItemEntrydeltaFor(Class<C> objectClass)
String
detectLanguage(File file)
PrismSerializer<Element>
domSerializer()
Creates a serializer for DOM.UniformItemPath
emptyPath()
BeanMarshaller
getBeanMarshaller()
WARNING! This is not really public method.BeanUnmarshaller
getBeanUnmarshaller()
ParsingContext
getDefaultParsingContext()
PolyStringNormalizer
getDefaultPolyStringNormalizer()
Returns the default PolyString normalizer.Protector
getDefaultProtector()
Returns the default protector.QName
getDefaultReferenceTypeName()
Type name for serialization of Referencable that's not of XML type (e.g.QName
getDefaultRelation()
If defined, it is considered to be the same as the relation of 'null'.SchemaDefinitionFactory
getDefinitionFactory()
XmlEntityResolver
getEntityResolver()
Do not use.JaxbDomHack
getJaxbDomHack()
TODO eliminate this methodLexicalProcessorRegistry
getLexicalProcessorRegistry()
PrismMonitor
getMonitor()
QName
getObjectsElementName()
If defined, marks the 'multiple objects' element.DomLexicalProcessor
getParserDom()
WARNING! This is not really public method.ParsingMigrator
getParsingMigrator()
PrismMarshaller
getPrismMarshaller()
PrismUnmarshaller
getPrismUnmarshaller()
WARNING! This is not really public method.QueryConverter
getQueryConverter()
SchemaRegistry
getSchemaRegistry()
Returns the schema registry.Hacks
hacks()
void
initialize()
Initializes the prism context, e.g.static boolean
isAllowSchemalessSerialization()
boolean
isDefaultRelation(QName relation)
static boolean
isExtraValidation()
ItemFactory
itemFactory()
ItemPathParser
itemPathParser()
PrismSerializer<String>
jsonSerializer()
Creates a serializer for JSON language.PrismParserNoIO
parserFor(RootXNode xnode)
Creates a parser ready to process data from the given XNode tree.PrismParser
parserFor(File file)
Creates a parser ready to process the given file.PrismParser
parserFor(InputStream stream)
Creates a parser ready to process data from the given input stream.PrismParserNoIO
parserFor(String data)
Creates a parser ready to process data from the given string.PrismParserNoIO
parserFor(Element data)
Deprecated.UniformItemPath
path(Object... namesOrIdsOrSegments)
QueryFactory
queryFactory()
S_FilterEntryOrEmpty
queryFor(Class<? extends Containerable> queryClass)
boolean
relationMatches(List<QName> relationQuery, QName relation)
Returns true of any of the relation in the relationQuery list matches specified relation.boolean
relationMatches(QName relationQuery, QName relation)
boolean
relationsEquivalent(QName relation1, QName relation2)
SchemaFactory
schemaFactory()
<O extends Objectable>
StringserializeObjectToString(PrismObject<O> object, String language)
PrismSerializer<String>
serializerFor(String language)
Creates a serializer for the given language.static void
setAllowSchemalessSerialization(boolean allowSchemalessSerialization)
void
setDefaultProtector(Protector defaultProtector)
void
setDefaultReferenceTypeName(QName defaultReferenceTypeName)
void
setDefaultRelation(QName defaultRelation)
void
setDefinitionFactory(SchemaDefinitionFactory schemaDefinitionFactory)
void
setExtraValidation(boolean value)
void
setMonitor(PrismMonitor monitor)
void
setObjectsElementName(QName objectsElementName)
void
setParsingMigrator(ParsingMigrator parsingMigrator)
UniformItemPath
toUniformPath(ItemPath path)
TemporaryUniformItemPath
toUniformPath(ItemPathType path)
UniformItemPath
toUniformPathKeepNull(ItemPath path)
PrismSerializer<String>
xmlSerializer()
Creates a serializer for XML language.XNodeFactory
xnodeFactory()
XNodeMutator
xnodeMutator()
PrismSerializer<RootXNode>
xnodeSerializer()
Creates a serializer for XNode.PrismSerializer<String>
yamlSerializer()
Creates a serializer for YAML language.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.evolveum.midpoint.prism.PrismContext
parseObject, parseObject, toPath
-
-
-
-
Method Detail
-
create
public static PrismContextImpl create(@NotNull SchemaRegistryImpl schemaRegistry)
-
createEmptyContext
public static PrismContextImpl createEmptyContext(@NotNull SchemaRegistryImpl schemaRegistry)
-
initialize
public void initialize() throws SchemaException, SAXException, IOException
Description copied from interface:PrismContext
Initializes the prism context, e.g. loads and parses all the schemas.- Specified by:
initialize
in interfacePrismContext
- Throws:
SchemaException
SAXException
IOException
-
configurePolyStringNormalizer
public void configurePolyStringNormalizer(PolyStringNormalizerConfigurationType configuration) throws ClassNotFoundException, InstantiationException, IllegalAccessException
- Specified by:
configurePolyStringNormalizer
in interfacePrismContext
- Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException
-
isAllowSchemalessSerialization
public static boolean isAllowSchemalessSerialization()
-
setAllowSchemalessSerialization
public static void setAllowSchemalessSerialization(boolean allowSchemalessSerialization)
-
isExtraValidation
public static boolean isExtraValidation()
-
getEntityResolver
public XmlEntityResolver getEntityResolver()
Description copied from interface:PrismContext
Do not use.- Specified by:
getEntityResolver
in interfacePrismContext
-
getSchemaRegistry
@NotNull public SchemaRegistry getSchemaRegistry()
Description copied from interface:PrismContext
Returns the schema registry.- Specified by:
getSchemaRegistry
in interfacePrismContext
-
getPrismUnmarshaller
public PrismUnmarshaller getPrismUnmarshaller()
WARNING! This is not really public method. It should NOT not used outside the prism implementation.
-
getPrismMarshaller
@NotNull public PrismMarshaller getPrismMarshaller()
-
getParserDom
public DomLexicalProcessor getParserDom()
WARNING! This is not really public method. It should NOT not used outside the prism implementation.
-
getBeanMarshaller
@NotNull public BeanMarshaller getBeanMarshaller()
WARNING! This is not really public method. It should NOT not used outside the prism implementation.
-
getBeanUnmarshaller
@NotNull public BeanUnmarshaller getBeanUnmarshaller()
-
getJaxbDomHack
@NotNull public JaxbDomHack getJaxbDomHack()
Description copied from interface:PrismContext
TODO eliminate this method- Specified by:
getJaxbDomHack
in interfacePrismContext
-
getDefinitionFactory
@NotNull public SchemaDefinitionFactory getDefinitionFactory()
-
setDefinitionFactory
public void setDefinitionFactory(SchemaDefinitionFactory schemaDefinitionFactory)
-
getDefaultPolyStringNormalizer
@NotNull public PolyStringNormalizer getDefaultPolyStringNormalizer()
Description copied from interface:PrismContext
Returns the default PolyString normalizer.- Specified by:
getDefaultPolyStringNormalizer
in interfacePrismContext
-
getDefaultProtector
public Protector getDefaultProtector()
Description copied from interface:PrismContext
Returns the default protector. (TODO)- Specified by:
getDefaultProtector
in interfacePrismContext
-
setDefaultProtector
public void setDefaultProtector(Protector defaultProtector)
-
getQueryConverter
@NotNull public QueryConverter getQueryConverter()
- Specified by:
getQueryConverter
in interfacePrismContext
-
getMonitor
public PrismMonitor getMonitor()
- Specified by:
getMonitor
in interfacePrismContext
-
setMonitor
public void setMonitor(PrismMonitor monitor)
- Specified by:
setMonitor
in interfacePrismContext
-
getDefaultRelation
public QName getDefaultRelation()
Description copied from interface:PrismContext
If defined, it is considered to be the same as the relation of 'null'. Currently in midPoint, it is the value of org:default.- Specified by:
getDefaultRelation
in interfacePrismContext
-
setDefaultRelation
public void setDefaultRelation(QName defaultRelation)
- Specified by:
setDefaultRelation
in interfacePrismContext
-
getObjectsElementName
public QName getObjectsElementName()
Description copied from interface:PrismContext
If defined, marks the 'multiple objects' element.- Specified by:
getObjectsElementName
in interfacePrismContext
-
setObjectsElementName
public void setObjectsElementName(QName objectsElementName)
-
getDefaultReferenceTypeName
public QName getDefaultReferenceTypeName()
Description copied from interface:PrismContext
Type name for serialization of Referencable that's not of XML type (e.g. DefaultReferencableImpl). In midPoint it's c:ObjectReferenceType. VERY EXPERIMENTAL. Maybe we should simply use t:ObjectReferenceType in such cases.- Specified by:
getDefaultReferenceTypeName
in interfacePrismContext
-
setDefaultReferenceTypeName
public void setDefaultReferenceTypeName(QName defaultReferenceTypeName)
-
parserFor
@NotNull public PrismParser parserFor(@NotNull File file)
Description copied from interface:PrismContext
Creates a parser ready to process the given file.- Specified by:
parserFor
in interfacePrismContext
- Parameters:
file
- File to be parsed.- Returns:
- Parser that can be invoked to retrieve the (parsed) content of the file.
-
parserFor
@NotNull public PrismParser parserFor(@NotNull InputStream stream)
Description copied from interface:PrismContext
Creates a parser ready to process data from the given input stream.- Specified by:
parserFor
in interfacePrismContext
- Parameters:
stream
- Input stream to be parsed.- Returns:
- Parser that can be invoked to retrieve the (parsed) content of the input stream.
-
parserFor
@NotNull public PrismParserNoIO parserFor(@NotNull String data)
Description copied from interface:PrismContext
Creates a parser ready to process data from the given string.- Specified by:
parserFor
in interfacePrismContext
- Parameters:
data
- String with the data to be parsed. It has be in UTF-8 encoding. (For other encodings please use InputStream or File source.)- Returns:
- Parser that can be invoked to retrieve the (parsed) content.
-
parserFor
@NotNull public PrismParserNoIO parserFor(@NotNull RootXNode xnode)
Description copied from interface:PrismContext
Creates a parser ready to process data from the given XNode tree.- Specified by:
parserFor
in interfacePrismContext
- Parameters:
xnode
- XNode tree with the data to be parsed.- Returns:
- Parser that can be invoked to retrieve the (parsed) content.
-
parserFor
@NotNull @Deprecated public PrismParserNoIO parserFor(@NotNull Element data)
Deprecated.Description copied from interface:PrismContext
Creates a parser ready to process data from the given DOM element.- Specified by:
parserFor
in interfacePrismContext
- Parameters:
data
- Element with the data to be parsed.- Returns:
- Parser that can be invoked to retrieve the (parsed) content.
-
detectLanguage
@NotNull public String detectLanguage(@NotNull File file) throws IOException
- Specified by:
detectLanguage
in interfacePrismContext
- Throws:
IOException
-
getParsingMigrator
public ParsingMigrator getParsingMigrator()
- Specified by:
getParsingMigrator
in interfacePrismContext
-
setParsingMigrator
public void setParsingMigrator(ParsingMigrator parsingMigrator)
- Specified by:
setParsingMigrator
in interfacePrismContext
-
adopt
public <C extends Containerable> void adopt(PrismContainer<C> container, Class<C> declaredType) throws SchemaException
Set up the specified object with prism context instance and schema definition.- Specified by:
adopt
in interfacePrismContext
- Throws:
SchemaException
-
adopt
public <C extends Containerable> void adopt(PrismContainer<C> container) throws SchemaException
- Specified by:
adopt
in interfacePrismContext
- Throws:
SchemaException
-
adopt
public void adopt(Objectable objectable) throws SchemaException
- Specified by:
adopt
in interfacePrismContext
- Throws:
SchemaException
-
adopt
public void adopt(Containerable containerable) throws SchemaException
- Specified by:
adopt
in interfacePrismContext
- Throws:
SchemaException
-
adopt
public void adopt(PrismContainerValue value) throws SchemaException
- Specified by:
adopt
in interfacePrismContext
- Throws:
SchemaException
-
adopt
public <T extends Objectable> void adopt(ObjectDelta<T> delta) throws SchemaException
- Specified by:
adopt
in interfacePrismContext
- Throws:
SchemaException
-
adopt
public <C extends Containerable,O extends Objectable> void adopt(C containerable, Class<O> type, ItemPath path) throws SchemaException
- Specified by:
adopt
in interfacePrismContext
- Throws:
SchemaException
-
adopt
public <C extends Containerable,O extends Objectable> void adopt(PrismContainerValue<C> prismContainerValue, Class<O> type, ItemPath path) throws SchemaException
- Specified by:
adopt
in interfacePrismContext
- Throws:
SchemaException
-
adopt
public <C extends Containerable,O extends Objectable> void adopt(PrismContainerValue<C> prismContainerValue, QName typeName, ItemPath path) throws SchemaException
- Specified by:
adopt
in interfacePrismContext
- Throws:
SchemaException
-
serializeObjectToString
public <O extends Objectable> String serializeObjectToString(PrismObject<O> object, String language) throws SchemaException
- Specified by:
serializeObjectToString
in interfacePrismContext
- Throws:
SchemaException
-
serializerFor
@NotNull public PrismSerializer<String> serializerFor(@NotNull String language)
Description copied from interface:PrismContext
Creates a serializer for the given language.- Specified by:
serializerFor
in interfacePrismContext
- Parameters:
language
- Language (like xml, json, yaml).- Returns:
- The serializer.
-
xmlSerializer
@NotNull public PrismSerializer<String> xmlSerializer()
Description copied from interface:PrismContext
Creates a serializer for XML language.- Specified by:
xmlSerializer
in interfacePrismContext
- Returns:
- The serializer.
-
jsonSerializer
@NotNull public PrismSerializer<String> jsonSerializer()
Description copied from interface:PrismContext
Creates a serializer for JSON language.- Specified by:
jsonSerializer
in interfacePrismContext
- Returns:
- The serializer.
-
yamlSerializer
@NotNull public PrismSerializer<String> yamlSerializer()
Description copied from interface:PrismContext
Creates a serializer for YAML language.- Specified by:
yamlSerializer
in interfacePrismContext
- Returns:
- The serializer.
-
domSerializer
@NotNull public PrismSerializer<Element> domSerializer()
Description copied from interface:PrismContext
Creates a serializer for DOM. The difference from XML serializer is that XML produces String output whereas this one produces a DOM Element.- Specified by:
domSerializer
in interfacePrismContext
- Returns:
- The serializer.
-
xnodeSerializer
@NotNull public PrismSerializer<RootXNode> xnodeSerializer()
Description copied from interface:PrismContext
Creates a serializer for XNode. The output of this serializer is intermediate XNode representation.- Specified by:
xnodeSerializer
in interfacePrismContext
- Returns:
- The serializer.
-
canSerialize
public boolean canSerialize(Object value)
Description copied from interface:PrismContext
TODO- Specified by:
canSerialize
in interfacePrismContext
- Returns:
-
createObject
@NotNull public <T extends Objectable> PrismObject<T> createObject(@NotNull Class<T> clazz) throws SchemaException
Description copied from interface:PrismContext
Creates a new PrismObject of a given type.- Specified by:
createObject
in interfacePrismContext
- Parameters:
clazz
- Static type of the object to be created.- Returns:
- New PrismObject.
- Throws:
SchemaException
- If a definition for the given class couldn't be found.
-
createObjectable
@NotNull public <T extends Objectable> T createObjectable(@NotNull Class<T> clazz) throws SchemaException
Description copied from interface:PrismContext
Creates a new Objectable of a given type.- Specified by:
createObjectable
in interfacePrismContext
- Parameters:
clazz
- Static type of the object to be created.- Returns:
- New PrismObject's objectable content.
- Throws:
SchemaException
- If a definition for the given class couldn't be found.
-
createKnownObject
@NotNull public <O extends Objectable> PrismObject<O> createKnownObject(@NotNull Class<O> clazz)
Description copied from interface:PrismContext
Creates a new PrismObject of a given static type. It is expected that the type exists, so any SchemaExceptions will be thrown as run-time exception.- Specified by:
createKnownObject
in interfacePrismContext
- Parameters:
clazz
- Static type of the object to be created.- Returns:
- New PrismObject.
-
createKnownObjectable
@NotNull public <O extends Objectable> O createKnownObjectable(@NotNull Class<O> clazz)
Description copied from interface:PrismContext
Creates a new Objectable of a given static type. It is expected that the type exists, so any SchemaExceptions will be thrown as run-time exception.- Specified by:
createKnownObjectable
in interfacePrismContext
- Parameters:
clazz
- Static type of the object to be created.- Returns:
- New PrismObject's objectable content.
-
getLexicalProcessorRegistry
@NotNull public LexicalProcessorRegistry getLexicalProcessorRegistry()
-
isDefaultRelation
public boolean isDefaultRelation(QName relation)
- Specified by:
isDefaultRelation
in interfacePrismContext
-
relationsEquivalent
public boolean relationsEquivalent(QName relation1, QName relation2)
- Specified by:
relationsEquivalent
in interfacePrismContext
-
relationMatches
public boolean relationMatches(QName relationQuery, QName relation)
- Specified by:
relationMatches
in interfacePrismContext
-
relationMatches
public boolean relationMatches(@NotNull List<QName> relationQuery, QName relation)
Description copied from interface:PrismContext
Returns true of any of the relation in the relationQuery list matches specified relation.- Specified by:
relationMatches
in interfacePrismContext
-
getDefaultParsingContext
public ParsingContext getDefaultParsingContext()
- Specified by:
getDefaultParsingContext
in interfacePrismContext
-
createParsingContextForAllowMissingRefTypes
public ParsingContext createParsingContextForAllowMissingRefTypes()
- Specified by:
createParsingContextForAllowMissingRefTypes
in interfacePrismContext
-
createParsingContextForCompatibilityMode
public ParsingContext createParsingContextForCompatibilityMode()
- Specified by:
createParsingContextForCompatibilityMode
in interfacePrismContext
-
emptyPath
public UniformItemPath emptyPath()
- Specified by:
emptyPath
in interfacePrismContext
-
path
public UniformItemPath path(Object... namesOrIdsOrSegments)
- Specified by:
path
in interfacePrismContext
-
hacks
public Hacks hacks()
- Specified by:
hacks
in interfacePrismContext
-
xnodeFactory
public XNodeFactory xnodeFactory()
- Specified by:
xnodeFactory
in interfacePrismContext
-
xnodeMutator
public XNodeMutator xnodeMutator()
- Specified by:
xnodeMutator
in interfacePrismContext
-
createInitializedProtector
public KeyStoreBasedProtector createInitializedProtector(KeyStoreBasedProtectorBuilder builder)
Description copied from interface:ProtectorCreator
Creates initialized KeyStoreBasedProtector according to configured KeyStoreBasedProtectorBuilder object.- Specified by:
createInitializedProtector
in interfaceProtectorCreator
-
createProtector
public KeyStoreBasedProtector createProtector(KeyStoreBasedProtectorBuilder builder)
Description copied from interface:ProtectorCreator
Creates uninitialized KeyStoreBasedProtector according to configured KeyStoreBasedProtectorBuilder object.- Specified by:
createProtector
in interfaceProtectorCreator
-
toUniformPath
@NotNull public UniformItemPath toUniformPath(ItemPath path)
Description copied from interface:PrismContext
Temporary- Specified by:
toUniformPath
in interfacePrismContext
-
toUniformPathKeepNull
public UniformItemPath toUniformPathKeepNull(ItemPath path)
- Specified by:
toUniformPathKeepNull
in interfacePrismContext
-
toUniformPath
public UniformItemPath toUniformPath(ItemPathType path)
- Specified by:
toUniformPath
in interfacePrismContext
-
createCanonicalItemPath
public CanonicalItemPath createCanonicalItemPath(ItemPath itemPath, Class<? extends Containerable> clazz)
Description copied from interface:PrismContext
Temporary- Specified by:
createCanonicalItemPath
in interfacePrismContext
-
createCanonicalItemPath
public CanonicalItemPath createCanonicalItemPath(ItemPath itemPath)
Description copied from interface:PrismContext
Temporary- Specified by:
createCanonicalItemPath
in interfacePrismContext
-
deltaFor
public <C extends Containerable> S_ItemEntry deltaFor(Class<C> objectClass) throws SchemaException
- Specified by:
deltaFor
in interfacePrismContext
- Throws:
SchemaException
-
queryFor
public S_FilterEntryOrEmpty queryFor(Class<? extends Containerable> queryClass)
- Specified by:
queryFor
in interfacePrismContext
-
deltaFactory
@NotNull public DeltaFactory deltaFactory()
- Specified by:
deltaFactory
in interfacePrismContext
-
queryFactory
@NotNull public QueryFactory queryFactory()
- Specified by:
queryFactory
in interfacePrismContext
-
itemFactory
@NotNull public ItemFactory itemFactory()
- Specified by:
itemFactory
in interfacePrismContext
-
definitionFactory
@NotNull public DefinitionFactory definitionFactory()
- Specified by:
definitionFactory
in interfacePrismContext
-
itemPathParser
@NotNull public ItemPathParser itemPathParser()
- Specified by:
itemPathParser
in interfacePrismContext
-
setExtraValidation
public void setExtraValidation(boolean value)
- Specified by:
setExtraValidation
in interfacePrismContext
-
schemaFactory
@NotNull public SchemaFactory schemaFactory()
- Specified by:
schemaFactory
in interfacePrismContext
-
-