com.evolveum.midpoint.prism.dom
Class PrismDomProcessor

java.lang.Object
  extended by com.evolveum.midpoint.prism.dom.PrismDomProcessor

public class PrismDomProcessor
extends Object

Author:
semancik

Constructor Summary
PrismDomProcessor(SchemaRegistry schemaRegistry)
           
 
Method Summary
<T extends Containerable>
boolean
addItemValue(Item item, Object element, PrismContainer<T> container)
          Parse the provided JAXB/DOM element and add it as a new value of the specified item.
<T extends Containerable>
boolean
deleteItemValue(Item item, Object element, PrismContainer<T> container)
          Parse the provided JAXB/DOM element and delete it from the specified item.
 String determineElementNamespace(Itemable parent, String elementDescriptionLocalName)
          Determines proper name for the element with specified local name.
 PrismContext getPrismContext()
           
<T extends Containerable>
Collection<? extends Item<?>>
parseContainerItems(PrismContainerDefinition<T> containingPcd, List<? extends Object> valueElements, QName propertyName, boolean reference)
          Used e.g.
<T extends Containerable,V extends PrismValue>
Collection<? extends Item<V>>
parseContainerItems(PrismContainerDefinition<T> containingPcd, List<Object> valueElements)
          Used e.g.
<V extends PrismValue>
Item<V>
parseItem(List<? extends Object> valueElements, QName itemName, ItemDefinition def)
          This gets definition of an unspecified type.
 Item<?> parseItem(List<? extends Object> valueElements, QName itemName, ItemDefinition def, boolean reference)
           
<T extends Objectable>
PrismObject<T>
parseObject(Element objectElement)
           
<T extends Objectable>
PrismObject<T>
parseObject(File file)
           
<T extends Objectable>
PrismObject<T>
parseObject(File file, Class<T> type)
           
<T extends Objectable>
PrismObject<T>
parseObject(Node domNode)
           
<T extends Objectable>
PrismObject<T>
parseObject(String objectString)
           
<T extends Objectable>
PrismObject<T>
parseObject(String objectString, Class<T> type)
           
 List<PrismObject<? extends Objectable>> parseObjects(File file)
          This is really stupid implementation.
<T extends Containerable>
PrismContainer<T>
parsePrismContainer(Element domElement)
           
<T extends Containerable>
PrismContainer<T>
parsePrismContainer(Element domElement, PrismContainerDefinition<T> propertyContainerDefinition)
           
<T extends Containerable>
Collection<? extends Item>
parsePrismContainerItems(List<Element> childElements, PrismContainerDefinition<T> containerDefinition)
           
protected
<T extends Containerable>
Collection<? extends Item<?>>
parsePrismContainerItems(List<Element> elements, PrismContainerDefinition<T> containerDefinition, Collection<? extends ItemDefinition> selection)
          Parses items of PRISM CONTAINER from a list of elements.
<T> PrismProperty<T>
parsePrismProperty(List<? extends Object> valueElements, QName propName, PrismPropertyDefinition propertyDefinition)
           
<T> T
parsePrismPropertyRealValue(Object valueElement, PrismPropertyDefinition propertyDefinition)
           
 PrismReference parsePrismReference(List<? extends Object> valueElements, QName propName, PrismReferenceDefinition referenceDefinition)
           
<T> PrismProperty<T>
parsePropertyFromValueElement(Element valueElement, PrismPropertyDefinition propertyDefinition)
           
 PrismReferenceValue parseReferenceValue(Element element)
           
 List<Element> serializeItemToDom(Item<?> item)
           
 List<Element> serializeItemToDom(Item<?> item, Document document)
           
 void serializeItemToDom(Item<?> item, Element parentElement)
           
<T extends Containerable>
String
serializeObjectToString(PrismContainerValue<T> object, Element parentElement)
           
<T extends Objectable>
String
serializeObjectToString(PrismObject<T> object)
           
<T extends Objectable>
String
serializeObjectToString(PrismObject<T> object, boolean serializeCompositeObjects)
           
<T extends Containerable>
Element
serializeToDom(PrismContainerValue<T> object, Element parentElement)
           
 Element serializeToDom(PrismObject<?> object)
          Returns "dead" DOM representation of the PrismObject.
 Element serializeToDom(PrismObject<?> object, boolean serializeCompositeObjects)
           
 void serializeValueToDom(PrismValue pval, Element parentElement)
           
 Element serializeValueToDom(PrismValue pval, QName elementName)
           
 Element serializeValueToDom(PrismValue pval, QName elementName, Document document)
           
 void setPrismContext(PrismContext prismContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrismDomProcessor

public PrismDomProcessor(SchemaRegistry schemaRegistry)
Method Detail

getPrismContext

public PrismContext getPrismContext()

setPrismContext

public void setPrismContext(PrismContext prismContext)

parseObject

public <T extends Objectable> PrismObject<T> parseObject(File file,
                                                         Class<T> type)
                                              throws SchemaException
Throws:
SchemaException

parseObject

public <T extends Objectable> PrismObject<T> parseObject(File file)
                                              throws SchemaException
Throws:
SchemaException

parseObjects

public List<PrismObject<? extends Objectable>> parseObjects(File file)
                                                     throws SchemaException
This is really stupid implementation. Parsing long files with DOM does not make much sense. But it may be OK for tests and such "lightweight" things.

Throws:
SchemaException

parseObject

public <T extends Objectable> PrismObject<T> parseObject(String objectString,
                                                         Class<T> type)
                                              throws SchemaException
Throws:
SchemaException

parseObject

public <T extends Objectable> PrismObject<T> parseObject(String objectString)
                                              throws SchemaException
Throws:
SchemaException

parseObject

public <T extends Objectable> PrismObject<T> parseObject(Node domNode)
                                              throws SchemaException
Throws:
SchemaException

parseObject

public <T extends Objectable> PrismObject<T> parseObject(Element objectElement)
                                              throws SchemaException
Throws:
SchemaException

parsePrismContainer

public <T extends Containerable> PrismContainer<T> parsePrismContainer(Element domElement)
                                                            throws SchemaException
Throws:
SchemaException

parsePrismContainer

public <T extends Containerable> PrismContainer<T> parsePrismContainer(Element domElement,
                                                                       PrismContainerDefinition<T> propertyContainerDefinition)
                                                            throws SchemaException
Throws:
SchemaException

parsePrismContainerItems

public <T extends Containerable> Collection<? extends Item> parsePrismContainerItems(List<Element> childElements,
                                                                                     PrismContainerDefinition<T> containerDefinition)
                                                    throws SchemaException
Throws:
SchemaException

parsePrismContainerItems

protected <T extends Containerable> Collection<? extends Item<?>> parsePrismContainerItems(List<Element> elements,
                                                                                           PrismContainerDefinition<T> containerDefinition,
                                                                                           Collection<? extends ItemDefinition> selection)
                                                          throws SchemaException
Parses items of PRISM CONTAINER from a list of elements.

The elements must describe properties or property container as defined by this PropertyContainerDefinition. Serializes all the elements from the provided list.

Internal parametric method. This does the real work.

min/max constraints are not checked now TODO: maybe we need to check them

Throws:
SchemaException

parsePrismProperty

public <T> PrismProperty<T> parsePrismProperty(List<? extends Object> valueElements,
                                               QName propName,
                                               PrismPropertyDefinition propertyDefinition)
                                    throws SchemaException
Throws:
SchemaException

parsePrismPropertyRealValue

public <T> T parsePrismPropertyRealValue(Object valueElement,
                                         PrismPropertyDefinition propertyDefinition)
                              throws SchemaException
Throws:
SchemaException

parsePropertyFromValueElement

public <T> PrismProperty<T> parsePropertyFromValueElement(Element valueElement,
                                                          PrismPropertyDefinition propertyDefinition)
                                               throws SchemaException
Throws:
SchemaException

parseContainerItems

public <T extends Containerable,V extends PrismValue> Collection<? extends Item<V>> parseContainerItems(PrismContainerDefinition<T> containingPcd,
                                                                                                        List<Object> valueElements)
                                                                     throws SchemaException
Used e.g. to parse values from XML representation of deltas. valueElements may contain DOM and JAXB values

Throws:
SchemaException

parseContainerItems

public <T extends Containerable> Collection<? extends Item<?>> parseContainerItems(PrismContainerDefinition<T> containingPcd,
                                                                                   List<? extends Object> valueElements,
                                                                                   QName propertyName,
                                                                                   boolean reference)
                                                  throws SchemaException
Used e.g. to parse values from XML representation of deltas. valueElements may contain DOM and JAXB values

Throws:
SchemaException

parsePrismReference

public PrismReference parsePrismReference(List<? extends Object> valueElements,
                                          QName propName,
                                          PrismReferenceDefinition referenceDefinition)
                                   throws SchemaException
Throws:
SchemaException

parseReferenceValue

public PrismReferenceValue parseReferenceValue(Element element)

parseItem

public <V extends PrismValue> Item<V> parseItem(List<? extends Object> valueElements,
                                                QName itemName,
                                                ItemDefinition def)
                                     throws SchemaException
This gets definition of an unspecified type. It has to find the right method to call. Value elements have the same element name. They may be elements of a property or a container.

Throws:
SchemaException

parseItem

public Item<?> parseItem(List<? extends Object> valueElements,
                         QName itemName,
                         ItemDefinition def,
                         boolean reference)
                  throws SchemaException
Throws:
SchemaException

addItemValue

public <T extends Containerable> boolean addItemValue(Item item,
                                                      Object element,
                                                      PrismContainer<T> container)
                     throws SchemaException
Parse the provided JAXB/DOM element and add it as a new value of the specified item.

Throws:
SchemaException

deleteItemValue

public <T extends Containerable> boolean deleteItemValue(Item item,
                                                         Object element,
                                                         PrismContainer<T> container)
                        throws SchemaException
Parse the provided JAXB/DOM element and delete it from the specified item.

Throws:
SchemaException

serializeToDom

public Element serializeToDom(PrismObject<?> object)
                       throws SchemaException
Returns "dead" DOM representation of the PrismObject. The representation is a copy of the object and does not change with the object. But the representation is fully DOM-compliant.

Throws:
SchemaException

serializeToDom

public Element serializeToDom(PrismObject<?> object,
                              boolean serializeCompositeObjects)
                       throws SchemaException
Throws:
SchemaException

serializeToDom

public <T extends Containerable> Element serializeToDom(PrismContainerValue<T> object,
                                                        Element parentElement)
                       throws SchemaException
Throws:
SchemaException

serializeObjectToString

public <T extends Objectable> String serializeObjectToString(PrismObject<T> object)
                               throws SchemaException
Throws:
SchemaException

serializeObjectToString

public <T extends Objectable> String serializeObjectToString(PrismObject<T> object,
                                                             boolean serializeCompositeObjects)
                               throws SchemaException
Throws:
SchemaException

serializeObjectToString

public <T extends Containerable> String serializeObjectToString(PrismContainerValue<T> object,
                                                                Element parentElement)
                               throws SchemaException
Throws:
SchemaException

serializeValueToDom

public Element serializeValueToDom(PrismValue pval,
                                   QName elementName)
                            throws SchemaException
Throws:
SchemaException

serializeValueToDom

public Element serializeValueToDom(PrismValue pval,
                                   QName elementName,
                                   Document document)
                            throws SchemaException
Throws:
SchemaException

serializeValueToDom

public void serializeValueToDom(PrismValue pval,
                                Element parentElement)
                         throws SchemaException
Throws:
SchemaException

serializeItemToDom

public List<Element> serializeItemToDom(Item<?> item)
                                 throws SchemaException
Throws:
SchemaException

serializeItemToDom

public List<Element> serializeItemToDom(Item<?> item,
                                        Document document)
                                 throws SchemaException
Throws:
SchemaException

serializeItemToDom

public void serializeItemToDom(Item<?> item,
                               Element parentElement)
                        throws SchemaException
Throws:
SchemaException

determineElementNamespace

public String determineElementNamespace(Itemable parent,
                                        String elementDescriptionLocalName)
Determines proper name for the element with specified local name.



Copyright © 2013 evolveum. All Rights Reserved.