atg.repository.xml
Class RepositoryXMLTools

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.repository.xml.RepositoryXMLTools
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener, org.xml.sax.ErrorHandler

public class RepositoryXMLTools
extends GenericService
implements org.xml.sax.ErrorHandler

Utils class to encode/decode item-descriptors, property names and mapping files into XML compatible namespaces and identifiers. These are the encoding rules we follow. XML identifiers can only contain "_", "-", ".", letter and digit. So we encode all the other characters using hex value as _XXXX. We also encode "_" to "__" to avoid confusion with our hex representation. There is also another restraint on the starting character of XML identifier, it can only be letter or "_". So for starting character we encode everything except letter.


Field Summary
static java.lang.String CHECKOUT_TAG
          tag used to check out DocumentBuilder from the DocumentBuilder pool.
static java.lang.String CLASS_VERSION
           
static java.lang.String CONTENT_REPOSITORIES_PATH
          Path of ContentRepositories component which is used to retrive Repository corresponding to the repository name.
static java.lang.String FILE_ELEMENT_SEPARATOR
          Schema file name of item-descriptor contains repositoryname, item-descriptor name, and mapping file name& property names if exist.
static java.lang.String NAME_SPACE
          constant representing namespace prefix.
static java.lang.String NAME_SPACE_ELEMENT_SEPARATOR
          String representing separator for elements in namespace.
static java.lang.String SCHEMA_FILE_EXTENSION
          file extension of schema file.
static atg.repository.nucleus.RepositoryRegistryService sContentRepositories
          ContentRepositories component.
protected static char[] sHexDigits
          Hexadecimal digits
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
RepositoryXMLTools()
           
 
Method Summary
 void addItemDescToPropertyMap(java.util.Map pMap, RepositoryItemDescriptor pDescriptor, java.lang.String pPropertyName)
          This method adds the RepositoryItemDescriptor and propertyName passed to it to the Map passed to it.
 void error(org.xml.sax.SAXParseException pException)
          Implementation of the SAX ErrorHandler interface method.
 void fatalError(org.xml.sax.SAXParseException pException)
          Implementation of the SAX ErrorHandler interface method.
 atg.xml.tools.pools.DocumentBuilderPool getDocumentBuilderPool()
          Returns Pool of DocumentBuilder resource to parse the XML document.
 atg.repository.xml.ItemDescToPropertyNameInfo[] getItemDescriptorsToInclude(RepositoryItemDescriptor pDescriptor, atg.repository.databinding.ItemMappingElement pItemMappingElement)
          This method determines for a given RepositoryItemDescriptor and ItemMappingElement pair, what RepositoryItemDescriptors will be included in the data model.
 atg.repository.databinding.ItemMappingElement getItemMappingElement(RepositoryPropertyDescriptor pPropertyDesc, RepositoryItemDescriptor pItemDesc, atg.repository.databinding.ItemMappingElement pMappingElement)
          This method will obtain an ItemMappingElement that describes how the RepositoryItemDescriptor associated with the RepositoryPropertyDescriptor should be mapped.
 atg.repository.databinding.ItemMappingElement getItemMappingElement(java.lang.String pNamespaceURI)
          This method obtains the Mapping elements represented by the namesapceURI.
 atg.repository.xml.ItemDescToNSInfo[] getNSInfoForItems(RepositoryItemDescriptor pItemDescriptor, atg.repository.databinding.ItemMappingElement pItemMappingElement, java.lang.String pMappingFileName)
          This method determines for a given item-descriptor and optional ItemMappingElement what item-descriptors can be directly referenced by the pItemDescriptor parameter.
 java.lang.String getNSItemDescriptor(RepositoryItemDescriptor pItemDesc)
          Constructs the namespace URI corresponding to item-descriptor passed.
 java.lang.String getNSItemDescriptor(RepositoryItemDescriptor pItemDesc, java.lang.String pMappingFileName)
          Constructs the namespace URI corresponding to item-descriptor and mapping file passed.
 java.lang.String getNSItemDescriptor(RepositoryItemDescriptor pItemDesc, java.lang.String pMappingFileName, java.lang.String pPropertyName)
          Constructs the namespace URI corresponding to item-descriptor, mapping file and property name passed.
 java.lang.String getNSPrefix(RepositoryPropertyDescriptor pPropertyDesc, RepositoryItemDescriptor pItemDescriptor, atg.repository.databinding.ItemMappingElement pMappingElement)
          This method will determine the correct namespace prefix to use for the item-descriptor that is pointed to by the property represented by the pPropertyDesc parameter.
 java.lang.String getNSPrefixForItemDescriptor(RepositoryItemDescriptor pItemDesc)
          Constructs the prefix to use for the name space in xml schema, it will be xml encoded item-descriptor name.
 java.lang.String getNSPrefixForItemDescriptor(RepositoryItemDescriptor pItemDesc, java.lang.String pPropertyName)
          Constructs the prefix to use for the name space in xml schema, it will be xml encoded mapping file name and item-descriptor name.
 char getPropertyElementNameSeparator()
          Returns Separator Character to use in XML Schema & instance document to separate property name from itemDescriptor name
 atg.repository.databinding.PropertyMappingElement getPropertyMappingElement(atg.repository.databinding.ItemMappingElement pItemMappingElement, RepositoryPropertyDescriptor pPropertyDescriptor)
          This method will determine if there is a PropertyMappingElement on the ItemMappingElement parameter whose name corresponds to the name of the RepositoryPropertyDescriptor parameter passed to this method.
 java.lang.String getPropertyName(atg.repository.databinding.ItemMappingElement pItemMappingElement, java.lang.String pPropertyName)
          Decodes the Property Name from xml Identifier
 java.lang.String getPropertyNameForItem(java.lang.String pLocalName, atg.repository.databinding.ItemMappingElement pItemMappingElement)
          This method is associated with the getPropertyNameForXML() method.
 java.lang.String getPropertyNameForXML(RepositoryPropertyDescriptor pPropDesc, atg.repository.databinding.ItemMappingElement pItemMappingElement)
          This method will obtain the name for a property of an item-descriptor.
 java.lang.String getRepositoryIdentifier(java.lang.String pXMLIdentifier)
          Decodes XML-compatible identifier into repository property identifier This method calls the decodeFromXML() method.
 RepositoryItemDescriptor getRepositoryItemDescriptor(java.lang.String pNameSpace)
          Get the repository item-descriptor that corresponds to the namespace URI of pNamespaceURI.
 RepositoryItem[] getRepositoryItems(org.w3c.dom.Document pDocument, java.util.Map pMatchValues)
          This method will select RepositoryItems based upon information from the pDocument parameter and the pMatchValues parameter.
 RepositoryItem[] getRepositoryItems(org.w3c.dom.Document pDocument, java.lang.String[] pMatchProperties, atg.repository.databinding.ItemMappingElement pItemMappingElement)
          Retrieves the Repository items from Document object.
 RepositoryItem[] getRepositoryItems(org.xml.sax.InputSource pXML, java.util.Map pMatchValues)
          This method will select RepositoryItems based upon information from the pDocument parameter and the pMatchValues parameter.
 RepositoryItem[] getRepositoryItemsFromXML(org.xml.sax.InputSource pInputSource, java.lang.String[] pMatchProperties)
          Parses the XML string and retrieves the Repository items corresponding to the XML.
 RepositoryItem[] getRepositoryItemsFromXML(java.lang.String pXMLString, java.lang.String[] pMatchProperties)
          Parses the XML string and retrieves the Repository items corresponding to the XML.
 java.lang.String getSchemaFileName(RepositoryItemDescriptor pItemDesc)
          Returns the filename to be used to store the xml schema corresponding to the item-descriptor.
 java.lang.String getSchemaFileName(RepositoryItemDescriptor pItemDesc, java.lang.String pMappingFileName)
          Returns the filename to be used to store the xml schema corresponding to the item-descriptor and mapping file name.
 java.lang.String getSchemaFileName(RepositoryItemDescriptor pItemDesc, java.lang.String pMappingFileName, java.lang.String pPropertyName)
          Returns the filename to be used to store the xml schema corresponding to the item-descriptor and mapping file name.
static java.lang.String getSchemaFileName(java.lang.String pNameSpace)
           
 atg.repository.xml.XMLSchemaManager getSchemaManager()
          Returns Schema Manager
 java.lang.String getXMLIdentifier(java.lang.String pRepositoryIdentifier)
          Constructs XML-compatible identifier corresponding to the string passed This method calls the encodeToXML() method.
 java.lang.String getXMLSchemaNSURI()
          Return the value to use for the XMLSchema namespace URI.
 boolean isAddItemTypeToPropertyNames()
          This property controls whether or not elements in an instance document that correspond to a property of a Repository Item should have the item-descriptor name appended to the property name.
 boolean isElementSimpleType(java.lang.String pNamespaceURI, java.lang.String pLocalName)
          This method determines if the XML element represented by the pNamespaceURI and pLocalName parameters is a "simple" type.
 boolean isEncodeRepositoryIdAsAttr()
          This property controls where repositoryId properties appear.
 boolean isIncludeProperty(RepositoryPropertyDescriptor pDescriptor, atg.repository.databinding.ItemMappingElement pItemMappingElement)
          This method determines whether or not a single property should be included in an exported data model or not.
 boolean isPropertyMappingElement(java.lang.String pPropertyName, atg.repository.databinding.ItemMappingElement pElement)
          This method determines if there is a property mapping element whose name is the same as the name passed in as the pPropertyName.
 boolean isRepositoryIdMatchCriteria(java.lang.String[] pMatchProperties)
          Determines if there is an entry in the pMatchProperties parameter that equals the repositoryId string.
 boolean isSimpleType(java.lang.Class pType)
          Helper to identify "atomic" properties.
 atg.repository.xml.ItemDescToPropertyNameInfo[] removeDuplicateEntries(atg.repository.xml.ItemDescToPropertyNameInfo[] pItemDescToPropertyInfos)
          This method walks through the list passed to it and removes any entries within it that are equal.
 RepositoryItem[] selectRepositoryItemById(org.w3c.dom.Document pDocument, java.lang.String[] pMatchProperties)
          This method will select a repository item from the repository represented by top-level element appearing in the pDocument parameter.
 RepositoryItem[] selectRepositoryItems(RepositoryItemDescriptor pItemDescriptor, java.util.Map pPropMap)
          Constructs the RQL query from pPropMap and executes against the RepositoryItemDescriptor .
 void setAddItemTypeToPropertyNames(boolean addItemTypeToPropertyNames)
          Sets the addItemTypeToPropertyNames.
 void setDocumentBuilderPool(atg.xml.tools.pools.DocumentBuilderPool pDocumentBuilderPool)
          Sets Pool of DocumentBuilder resource to parse the XML document.
 void setEncodeRepositoryIdAsAttr(boolean encodeRepositoryIdAsAttr)
          Sets the encodeRepositoryIdAsAttr.
 void setPropertyElementNameSeparator(char pPropertyElementNameSeparator)
          Sets Separator Character to use in XML Schema & instance document to separate property name from itemDescriptor name
 void setSchemaManager(atg.repository.xml.XMLSchemaManager pSchemaManager)
          Sets Schema Manager
 void setXMLSchemaNSURI(java.lang.String pXMLSchemaNSURI)
          Set the XMLSchemaNSURI property.
 void warning(org.xml.sax.SAXParseException pException)
          Implementation of the SAX ErrorHandler interface method.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION

sHexDigits

protected static final char[] sHexDigits
Hexadecimal digits


NAME_SPACE

public static final java.lang.String NAME_SPACE
constant representing namespace prefix.

See Also:
Constant Field Values

NAME_SPACE_ELEMENT_SEPARATOR

public static final java.lang.String NAME_SPACE_ELEMENT_SEPARATOR
String representing separator for elements in namespace.

See Also:
Constant Field Values

SCHEMA_FILE_EXTENSION

public static final java.lang.String SCHEMA_FILE_EXTENSION
file extension of schema file.

See Also:
Constant Field Values

FILE_ELEMENT_SEPARATOR

public static final java.lang.String FILE_ELEMENT_SEPARATOR
Schema file name of item-descriptor contains repositoryname, item-descriptor name, and mapping file name& property names if exist. this string(+) is used to separate the elements in the filenames.

See Also:
Constant Field Values

CONTENT_REPOSITORIES_PATH

public static final java.lang.String CONTENT_REPOSITORIES_PATH
Path of ContentRepositories component which is used to retrive Repository corresponding to the repository name.

See Also:
Constant Field Values

sContentRepositories

public static atg.repository.nucleus.RepositoryRegistryService sContentRepositories
ContentRepositories component.


CHECKOUT_TAG

public static final java.lang.String CHECKOUT_TAG
tag used to check out DocumentBuilder from the DocumentBuilder pool.

See Also:
Constant Field Values
Constructor Detail

RepositoryXMLTools

public RepositoryXMLTools()
Method Detail

isEncodeRepositoryIdAsAttr

public boolean isEncodeRepositoryIdAsAttr()
This property controls where repositoryId properties appear. If this is set to true, it indicates that Ids for RepositoryItems should appear as an attribute on the XML element indicating the start of a repository item. If, this property is set to false then no special handling of repository Ids will occur. If the repository Id of an item is exposed through a property then this property will appear as just another property of the item.

If an item is being added then if the repositoryId appears in the attribute, it will be used to create a new repository item with the specified Id.

This property defaults to false.

Returns:
boolean true if repository Ids should be encoded as attributes on the top-level XML element indicating the start of an item.

setEncodeRepositoryIdAsAttr

public void setEncodeRepositoryIdAsAttr(boolean encodeRepositoryIdAsAttr)
Sets the encodeRepositoryIdAsAttr.

Parameters:
encodeRepositoryIdAsAttr - The encodeRepositoryIdAsAttr to set

isAddItemTypeToPropertyNames

public boolean isAddItemTypeToPropertyNames()
This property controls whether or not elements in an instance document that correspond to a property of a Repository Item should have the item-descriptor name appended to the property name. For example, if there is a user item-descriptor with a property named firstName then the generated XML can appear in two different forms: This property controls which form it looks like. If this property is set to true, then the first form will be used. If this property is set to false, then the second form is used.

This property defaults to true. Adding in the enclosing item-descriptor name allows for clarity on what properties a given item refers to (e.g. the firstName property of a User item-descriptor is separated from the firstName property of an address) but results in more verbose XML.

Returns:
boolean true if the item-descriptor name should be appended to a property name.

setAddItemTypeToPropertyNames

public void setAddItemTypeToPropertyNames(boolean addItemTypeToPropertyNames)
Sets the addItemTypeToPropertyNames.

Parameters:
addItemTypeToPropertyNames - The addItemTypeToPropertyNames to set

getXMLSchemaNSURI

public java.lang.String getXMLSchemaNSURI()
Return the value to use for the XMLSchema namespace URI. Currently, this is set to http://www.w3.org/2001/XMLSchema by default, but changing the value on this component should change the URI that is used by all components.

Returns:
namespace URI to use for XML Schema

setXMLSchemaNSURI

public void setXMLSchemaNSURI(java.lang.String pXMLSchemaNSURI)
Set the XMLSchemaNSURI property.

Parameters:
pXMLSchemaNSURI -

getPropertyElementNameSeparator

public char getPropertyElementNameSeparator()
Returns Separator Character to use in XML Schema & instance document to separate property name from itemDescriptor name

Returns:
the PropertyElementNameSeparator

setPropertyElementNameSeparator

public void setPropertyElementNameSeparator(char pPropertyElementNameSeparator)
Sets Separator Character to use in XML Schema & instance document to separate property name from itemDescriptor name

Parameters:
PropertyElementNameSeparator -

getDocumentBuilderPool

public atg.xml.tools.pools.DocumentBuilderPool getDocumentBuilderPool()
Returns Pool of DocumentBuilder resource to parse the XML document.

Returns:
the DocumentBuilderPool

setDocumentBuilderPool

public void setDocumentBuilderPool(atg.xml.tools.pools.DocumentBuilderPool pDocumentBuilderPool)
Sets Pool of DocumentBuilder resource to parse the XML document.

Parameters:
DocumentBuilderPool -

getSchemaManager

public atg.repository.xml.XMLSchemaManager getSchemaManager()
Returns Schema Manager

Returns:
the SchemaManager

setSchemaManager

public void setSchemaManager(atg.repository.xml.XMLSchemaManager pSchemaManager)
Sets Schema Manager

Parameters:
SchemaManager -

getNSItemDescriptor

public java.lang.String getNSItemDescriptor(RepositoryItemDescriptor pItemDesc)
Constructs the namespace URI corresponding to item-descriptor passed. It will be in the format of http://www.atg.com/ns/repository/item-descriptor

Parameters:
pItemDesc - a RepositoryItemDescriptor value
Returns:
the Namespace URI that should be used for the item-descriptor

getNSItemDescriptor

public java.lang.String getNSItemDescriptor(RepositoryItemDescriptor pItemDesc,
                                            java.lang.String pMappingFileName)
Constructs the namespace URI corresponding to item-descriptor and mapping file passed. It will be in the format of http://www.atg.com/ns/mappingfile/repository/item-descriptor

Parameters:
the - item-descriptor that a namespace URI will be constructed for
the - mapping file that will be used, in conjunction with the item-descriptor, to generate a namespaceURI
Returns:
a namespace URI

getNSItemDescriptor

public java.lang.String getNSItemDescriptor(RepositoryItemDescriptor pItemDesc,
                                            java.lang.String pMappingFileName,
                                            java.lang.String pPropertyName)
Constructs the namespace URI corresponding to item-descriptor, mapping file and property name passed. It will be in the format of http://www.atg.com/ns/mappingfile/repository/item-descriptor/propertyName

Parameters:
the - item-descriptor that a namespace URI will be created for
the - mapping file that will be used to create a namespace URI
the - property name that will be used to construct the namespace URI
Returns:
a namespace URI

getNSPrefixForItemDescriptor

public java.lang.String getNSPrefixForItemDescriptor(RepositoryItemDescriptor pItemDesc)
Constructs the prefix to use for the name space in xml schema, it will be xml encoded item-descriptor name.

Returns:
a namespace prefix that will identify the item-descriptor

getNSPrefixForItemDescriptor

public java.lang.String getNSPrefixForItemDescriptor(RepositoryItemDescriptor pItemDesc,
                                                     java.lang.String pPropertyName)
Constructs the prefix to use for the name space in xml schema, it will be xml encoded mapping file name and item-descriptor name. It will be in the format of itemDescriptorNamePropertyName

Parameters:
pItemDesc - the item-descriptor that will be used to create a namespace prefix
pMappingFileName - the name of a mapping file that will be used in creating a namespace prefix
Returns:
a namespace prefix

getXMLIdentifier

public java.lang.String getXMLIdentifier(java.lang.String pRepositoryIdentifier)
Constructs XML-compatible identifier corresponding to the string passed This method calls the encodeToXML() method.

Parameters:
pRepositoryIdentifier - the name of an item-descriptor that will be encoded to an XML identifier.
Returns:
the name of the item-descriptor, encoded so that the only characters in the name are legal XML characters

getRepositoryIdentifier

public java.lang.String getRepositoryIdentifier(java.lang.String pXMLIdentifier)
Decodes XML-compatible identifier into repository property identifier This method calls the decodeFromXML() method.

Returns:
the XML name for a repository item-descriptor decoded into a repository item-descriptor name.

getSchemaFileName

public java.lang.String getSchemaFileName(RepositoryItemDescriptor pItemDesc)
Returns the filename to be used to store the xml schema corresponding to the item-descriptor.

Returns:
the file name for a XML Schema.

getSchemaFileName

public java.lang.String getSchemaFileName(RepositoryItemDescriptor pItemDesc,
                                          java.lang.String pMappingFileName)
Returns the filename to be used to store the xml schema corresponding to the item-descriptor and mapping file name.

Returns:
the file name for a XML Schema.

getSchemaFileName

public java.lang.String getSchemaFileName(RepositoryItemDescriptor pItemDesc,
                                          java.lang.String pMappingFileName,
                                          java.lang.String pPropertyName)
Returns the filename to be used to store the xml schema corresponding to the item-descriptor and mapping file name.

Returns:
the file name for a XML Schema.

getSchemaFileName

public static java.lang.String getSchemaFileName(java.lang.String pNameSpace)

getRepositoryItemDescriptor

public RepositoryItemDescriptor getRepositoryItemDescriptor(java.lang.String pNameSpace)
Get the repository item-descriptor that corresponds to the namespace URI of pNamespaceURI.

Parameters:
pNameSpace - the namespace URI that will be resolved to a specific repository item-descriptor.
Returns:
a repository item-descriptor

getItemMappingElement

public atg.repository.databinding.ItemMappingElement getItemMappingElement(java.lang.String pNamespaceURI)
                                                                    throws MappingException
This method obtains the Mapping elements represented by the namesapceURI. If no mapping file value appears within the namespaceURI then null will be returned.

Parameters:
pNamespaceURI - the namespaceURI that may contain a reference to a mapping file name
Returns:
ItemMappingElement root element of a parsed ItemMappingElement
Throws:
MappingException

getNSInfoForItems

public atg.repository.xml.ItemDescToNSInfo[] getNSInfoForItems(RepositoryItemDescriptor pItemDescriptor,
                                                               atg.repository.databinding.ItemMappingElement pItemMappingElement,
                                                               java.lang.String pMappingFileName)
                                                        throws RepositoryException
This method determines for a given item-descriptor and optional ItemMappingElement what item-descriptors can be directly referenced by the pItemDescriptor parameter. This list of item-descriptors should be populated by iterating over the properties of the pItemDescriptor and determining for each property that points to an item-descriptor, whether or not it is to be included in the exported data model. This is determined by calling the isIncludeProperty() method.

For each item-descriptor that is found to be included, we need to determine all of its possible subtypes since any one of these subtypes could be assigned as valid options.

Finally, for each item-descriptor that is found to be included determine what the namespace, namespace prefix and property name that that item-descriptor corresponds to.

Parameters:
pItemDescriptor - the item-descriptor whose properties are introspected to determine if they point to other item-descriptors and should be exported in the data model.
pItemMappingElement - optional argument, which if present will guide the decision in determining which properties should be included in the exported data model.
pMappingFileName - file name for the mapping file, the value for this is used to construct the namespace URI.
Returns:
array of ItemDescToNSInfo objects which contains a list of all itemDescriptors which will be exported in the datamodel and are directly refernced by the pItemDescriptor parameter.
Throws:
RepositoryException

removeDuplicateEntries

public atg.repository.xml.ItemDescToPropertyNameInfo[] removeDuplicateEntries(atg.repository.xml.ItemDescToPropertyNameInfo[] pItemDescToPropertyInfos)
This method walks through the list passed to it and removes any entries within it that are equal.

Parameters:
pItemDescToPropertyMapping - a Map value

getItemDescriptorsToInclude

public atg.repository.xml.ItemDescToPropertyNameInfo[] getItemDescriptorsToInclude(RepositoryItemDescriptor pDescriptor,
                                                                                   atg.repository.databinding.ItemMappingElement pItemMappingElement)
                                                                            throws RepositoryException
This method determines for a given RepositoryItemDescriptor and ItemMappingElement pair, what RepositoryItemDescriptors will be included in the data model. This means that for each property on the pDescriptor parameter passed to this method, that property will be checked to see if it references another item-descriptor. (For Maps, Sets, Lists this means if there componentItemType is another item-descriptor) If a given property does reference another item-descriptor then it is checked whether the property is to be exported by calling the isItemDescriptorIncluded() method.

For each property that is to be exported in the data model, the item-descriptor that that property references and all of its subtypes (if applicable) will be determined and added to the array of RepositoryItemDescriptors to return.

Parameters:
pDescriptor - the RepositoryItemDescriptor whose properties will be searched.
pItemMappingElement - an item-mapping element that can control what properties are or are not to be included in the data model. This property is optional.
Returns:
array of RepositoryItemDescriptors that are referenced for the pDescriptor parameter and are to be included in the exported data model. If there are not RepositoryItemDescriptors then null is returned.
Throws:
RepositoryException

isPropertyMappingElement

public boolean isPropertyMappingElement(java.lang.String pPropertyName,
                                        atg.repository.databinding.ItemMappingElement pElement)
This method determines if there is a property mapping element whose name is the same as the name passed in as the pPropertyName.

Parameters:
pPropertyName - the name that a PropertyMappingElement whose name matches will be checked for.
pElement - ItemMappingElement whose PropertyMappingElements will be checked.
Returns:
true if there is a matching PropertyMappingElement whose name matches.

addItemDescToPropertyMap

public void addItemDescToPropertyMap(java.util.Map pMap,
                                     RepositoryItemDescriptor pDescriptor,
                                     java.lang.String pPropertyName)
                              throws RepositoryException
This method adds the RepositoryItemDescriptor and propertyName passed to it to the Map passed to it. It will also determine all the subtypes for the item-descriptor passed to it and add an entry for each of these to the map with the property name mapping.

Parameters:
pMap - map that the pDescriptor and all of it subtype item-descriptors should be added to with a value mapping of the pPropertyName parameter passed.
pDescriptor - item-descriptor that will be added to the map as the key entry to the map. Additionally, all subtypes for this item-descriptor will be determined and added to the map.
pPropertyName - the property name that will be used for the value mapping of the pDescriptor
Throws:
RepositoryException

isIncludeProperty

public boolean isIncludeProperty(RepositoryPropertyDescriptor pDescriptor,
                                 atg.repository.databinding.ItemMappingElement pItemMappingElement)
This method determines whether or not a single property should be included in an exported data model or not. The rules to determine this are as follows:

getItemMappingElement

public atg.repository.databinding.ItemMappingElement getItemMappingElement(RepositoryPropertyDescriptor pPropertyDesc,
                                                                           RepositoryItemDescriptor pItemDesc,
                                                                           atg.repository.databinding.ItemMappingElement pMappingElement)
This method will obtain an ItemMappingElement that describes how the RepositoryItemDescriptor associated with the RepositoryPropertyDescriptor should be mapped. That is, the RepositoryPropertyDescriptor passed as an argument to this method references another ItemDescriptor. This ItemDescriptor could have a mapping for it within the ItemMappingElement passed to this argument. If the ItemMappingElement has a PropertyMappingElement whose name corresponds to the name of the RepositoryPropertyDescriptor and the PropertyMappingElement has an ItemMappingElement whose type corresponds to the property ItemDescriptor of the RepositoryPropertyDescriptor then this ItemMappingElement is returned.

Parameters:
pPropertyDesc - RepositoryPropertyDescriptor whose property ItemDescriptor will be checked for within the passed ItemMappingElement.
pMappingElement - ItemMappingElement that may contain an enclosed PropertyMappingElement corresponding to the pPropertyDesc
Returns:
ItemMappingElement

getPropertyMappingElement

public atg.repository.databinding.PropertyMappingElement getPropertyMappingElement(atg.repository.databinding.ItemMappingElement pItemMappingElement,
                                                                                   RepositoryPropertyDescriptor pPropertyDescriptor)
This method will determine if there is a PropertyMappingElement on the ItemMappingElement parameter whose name corresponds to the name of the RepositoryPropertyDescriptor parameter passed to this method. If there is, this PropertyMappingElement is returned. If there is not, then null is returned.

Parameters:
pItemMappingElement - ItemMappingElement whose PropertyMappingElements will be examined.
pPropertyDescriptor - propertyDescriptor describing a property that a corresponding PropertyMappingElement will be searched for
Returns:
a PropertyMappingElement that corresponds to the pPropertyDescriptor. If none is found then null is returned.

getNSPrefix

public java.lang.String getNSPrefix(RepositoryPropertyDescriptor pPropertyDesc,
                                    RepositoryItemDescriptor pItemDescriptor,
                                    atg.repository.databinding.ItemMappingElement pMappingElement)
                             throws atg.repository.xml.SchemaGenerationException
This method will determine the correct namespace prefix to use for the item-descriptor that is pointed to by the property represented by the pPropertyDesc parameter.

Parameters:
pPropertyDesc - RepositoryPropertyDescriptor that a namespace prefix is being generated for
pMappingFileName - the name of the mapping file that the pMappingElement originated from
pMappingElement - parsed contents of a mapping file
Returns:
the namespace prefix to use
Throws:
SchemaGenerationException - if an error occurs

isElementSimpleType

public boolean isElementSimpleType(java.lang.String pNamespaceURI,
                                   java.lang.String pLocalName)
This method determines if the XML element represented by the pNamespaceURI and pLocalName parameters is a "simple" type. That is, every schema has elements with the name "string", "long" etc. appended to it. These elements correspond to the simple value types.

Parameters:
pNamespaceURI - the namespace URI of the current XML element
pLocalName - the localname of the current XML element
Returns:
boolean true if the tag represents a simpletype

isSimpleType

public boolean isSimpleType(java.lang.Class pType)
Helper to identify "atomic" properties. These are Java primitives and their object equivalents.


selectRepositoryItems

public RepositoryItem[] selectRepositoryItems(RepositoryItemDescriptor pItemDescriptor,
                                              java.util.Map pPropMap)
                                       throws RepositoryException
Constructs the RQL query from pPropMap and executes against the RepositoryItemDescriptor .

Parameters:
pItemDescriptor - to execute query against. The RQL is executed for the item descriptor type found in pItemDescriptor.
pPropMap - the Map should contain the property names as the keys of the map and values of the properties to use for constructing the RQL as values.
Returns:
the items found with the given search criteria.
Throws:
RepositoryException

getRepositoryItemsFromXML

public RepositoryItem[] getRepositoryItemsFromXML(java.lang.String pXMLString,
                                                  java.lang.String[] pMatchProperties)
                                           throws MatchException
Parses the XML string and retrieves the Repository items corresponding to the XML. Uses pMatchPropeties to match against the repository items from XML. The incoming XML is treated as a Repository Item, the property names that appear in the pMatchProperties parameter will be used to extract repository items from the target repository whose values match the property values for the incoming XML.

Parameters:
pXMLString - the XML
pMatchPropeties - an array of property names that will be used to match on repository item properties.
Returns:
a matching set of repository items.
Throws:
MatchException

getRepositoryItems

public RepositoryItem[] getRepositoryItems(org.xml.sax.InputSource pXML,
                                           java.util.Map pMatchValues)
                                    throws MatchException
This method will select RepositoryItems based upon information from the pDocument parameter and the pMatchValues parameter. The type of item-descriptor to select will be based upon the item-type that corresponds to the root namespace of the element in the pDocument.

Items are then selected by calling the selectRepositoryItems method to find items.

Parameters:
pXMLString - the XML document whose namespace will be introspected to determine to the type item to select
pMatchValues - key/value pairs used to select items from the repository
Returns:
the matching repository items
Throws:
MatchException

getRepositoryItemsFromXML

public RepositoryItem[] getRepositoryItemsFromXML(org.xml.sax.InputSource pInputSource,
                                                  java.lang.String[] pMatchProperties)
                                           throws MatchException
Parses the XML string and retrieves the Repository items corresponding to the XML. Uses pMatchPropeties to match against the repository items from XML. If mapping file is used while generating the XML instance string, then that mapping file name should be passed as the paramter pMappingFileName.

Parameters:
pXMLString - the XML document whose namespace will be introspected to determine to the type item to select
pMatchValues - key/value pairs used to select items from the repository
Returns:
the matching repository items
Throws:
MatchException

getRepositoryItems

public RepositoryItem[] getRepositoryItems(org.w3c.dom.Document pDocument,
                                           java.util.Map pMatchValues)
                                    throws RepositoryException
This method will select RepositoryItems based upon information from the pDocument parameter and the pMatchValues parameter. The type of item-descriptor to select will be based upon the item-type that corresponds to the root namespace of the element in the pDocument.

Items are then selected by calling the selectRepositoryItems method to find items.

Parameters:
pDocument - the DocumentElement of this document will have it's namespace examined. This namespace is resolved to a particular type of item-descriptor. This item-descriptor is the type of repository item that is selected.
pMatchValues - set of name/value pairs. The name is a property appearing in the corresponding item-descriptor. The value is the value that selected repository items will have for the corresponding property.
Returns:
RepositoryItems of item-descriptor type that corresponds to the Namespace in the document and whose properties (the keys in the pMatchValues parameter) match the corresponding values in the pMatchValues parameter.
Throws:
RepositoryException

getRepositoryItems

public RepositoryItem[] getRepositoryItems(org.w3c.dom.Document pDocument,
                                           java.lang.String[] pMatchProperties,
                                           atg.repository.databinding.ItemMappingElement pItemMappingElement)
                                    throws RepositoryException
Retrieves the Repository items from Document object.

Parameters:
pDocument - the XML document
pMatchProperties - an aray of property names that should be used when matching existing repository items to be updated with an incoming XML document.
pItemMappingElement - the item mapping element corresponding to the mapping of the incoming XML document to Repository item-descriptors
Returns:
an array of matching repository items
Throws:
RepositoryException - if an error occurs

isRepositoryIdMatchCriteria

public boolean isRepositoryIdMatchCriteria(java.lang.String[] pMatchProperties)
Determines if there is an entry in the pMatchProperties parameter that equals the repositoryId string. If there is, then this method returns true.

Parameters:
pMatchProperties - properties to match upon for selecting items from the repository.
Returns:
boolean true if the pMatchProperties array contains an entry for the repositoryId key.

selectRepositoryItemById

public RepositoryItem[] selectRepositoryItemById(org.w3c.dom.Document pDocument,
                                                 java.lang.String[] pMatchProperties)
                                          throws RepositoryException
This method will select a repository item from the repository represented by top-level element appearing in the pDocument parameter. This selection will be by repository id. The value for the repository id will be taken from the attributes appearing on the document element of the pDocument parameter. The attribute should be named repositoryId.

This method will return a single selected item in the array.

Parameters:
pDocument - the document whose document element contains a repository id.
pMatchProperties - properties to select items on
Returns:
RepositoryItem[] the selected items
Throws:
RepositoryException - if an error occurs

getPropertyName

public java.lang.String getPropertyName(atg.repository.databinding.ItemMappingElement pItemMappingElement,
                                        java.lang.String pPropertyName)
Decodes the Property Name from xml Identifier

Parameters:
pItemMappingElement - the itemMappingElement that indicates what property for an incoming XML document maps to what property on a RepositoryItemDescriptor
pPropertyName - the name of the property that a specific mapping should be obtained for
Returns:
the RepositoryItemDescriptor property name that corresponds to the XML property name pPropertyName.

getPropertyNameForXML

public java.lang.String getPropertyNameForXML(RepositoryPropertyDescriptor pPropDesc,
                                              atg.repository.databinding.ItemMappingElement pItemMappingElement)
This method will obtain the name for a property of an item-descriptor. The resulting name will be used for the name of an element in an instance document. For example, if the "firstName" property of the user item-descriptor is encountered, this method determines how this property should appear in a given instance document. This implementation allows the property to be either the item-descriptor name, followed by the propertyElementNameSeparator character, followed by the propertyName. Or, the only the property name can be returned without the prefixed item-descriptor name. The addItemTypeToPropertyNames property defined on this class controls this behavior.

If a propertyMappingElement exists for this property, and a target name is defined, then the target name will always be used by itself.

Parameters:
pPropDesc - the property descriptor that the XML element name is being generated for.
pItemMappingElement - the ItemMappingElement that controls how this property is mapped. This ItemMappingElement might contain a PropertyMappingElement that corresponds to the property described by the pPropDesc parameter
pItemDescriptorName - the name of the item-descriptor on which this property descriptor is defined
Returns:
String the name of a property element that should appear in a XML instance document.

getPropertyNameForItem

public java.lang.String getPropertyNameForItem(java.lang.String pLocalName,
                                               atg.repository.databinding.ItemMappingElement pItemMappingElement)
This method is associated with the getPropertyNameForXML() method. The difference is in the direction this method works for. Instead of generating a XML element name for a RepositoryPropertyDescriptor it will determine the name of a property on an item-descriptor for a property appearing in an instance document.

Parameters:
pLocalName - the localName of the element that appeared in an instance document
pItemMappingElement - the ItemMappingelement that controls how an instance document is mapped into a repository item.
Returns:
String the name of the property for a repository item.
See Also:
#addItemTypePropertyNames

warning

public void warning(org.xml.sax.SAXParseException pException)
Implementation of the SAX ErrorHandler interface method. If an warning occurs during the processing of an instance document this method will be called. The ParseException will be logged to the warning log.

This class is registered on the SAXParser as the ErrorHandler.

Specified by:
warning in interface org.xml.sax.ErrorHandler
Parameters:
pException - SAXParseException that occured during the processing of an instance document.

error

public void error(org.xml.sax.SAXParseException pException)
Implementation of the SAX ErrorHandler interface method. If an error occurs during the processing of an instance document this method will be called. The ParseException will be logged to the error log.

This class is registered on the SAXParser as the ErrorHandler.

Specified by:
error in interface org.xml.sax.ErrorHandler
Parameters:
pException - SAXParseException that occured during the processing of an instance document.

fatalError

public void fatalError(org.xml.sax.SAXParseException pException)
Implementation of the SAX ErrorHandler interface method. If an error occurs during the processing of an instance document this method will be called. The ParseException will be logged to the error log.

This class is registered on the SAXParser as the ErrorHandler.

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Parameters:
pException - SAXParseException that occured during the processing of an instance document.