public class MappingManager extends GenericService implements org.xml.sax.ErrorHandler
ItemMappingElementItemMappingElements
and
PropertyMappingElementPropertyMappingElements
.
The mapping files are expected to conform to the itemDescriptorMapping
DTD.
As an example, if a user wanted to specify a mapping file for the
Profile item-descriptor that lives in the
/atg/userprofiling/ProfileAdapterRepository and declare that the "scenarios"
property should not be included in the datamodel to be exported then the
following would be done.
#getMapping(String)getMapping()
method on this class,
passing in the name of the mapping file as the argument, i.e. ProfileMapping.
This component would then return the contents of the file parsed as set
of Java objects. The top level object returned would be an instance of
the ItemMappingElement class.ItemMappingElement
,
PropertyMappingElement
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION |
static java.lang.String |
DEFAULT_INCLUDE_ATTR
Whether or not properties should be included in the exported data
model by default.
|
static java.lang.String |
INCLUDE_ATTR
Name of the property that controls whether or not a property should
be included in a particular data model.
|
static java.lang.String |
ITEM_DESC_NAME
Name of the attribute property that indicates the name of the item-desc
|
static java.lang.String |
ITEM_DESC_TAG_NAME
Identifier for the item-descriptor tag that appears in a mapping file
|
static java.lang.String |
NAME_ATTR
The attribute property that indicates the property for the
item-descriptor
|
static java.lang.String |
PROPERTY_TAG_NAME
Identifier for the property tag that appears in a mapping file
|
static java.lang.String |
REPOSITORY_PATH
Name of the attribute property that points to the path of a repository
|
static java.lang.String |
TARGET_NAME_ATTR
The attribute property that indicates the property for the
remote data model.
|
SERVICE_INFO_KEY
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
MappingManager() |
Modifier and Type | Method and Description |
---|---|
atg.repository.databinding.ItemMappingElement |
buildItemMappingElement(org.w3c.dom.Element pItemElement,
RepositoryItemDescriptor pDescriptor)
This method will build a single node in the mapping configuration
tree.
|
atg.repository.databinding.PropertyMappingElement |
buildPropertyMappingElement(org.w3c.dom.Element pPropertyElement,
RepositoryItemDescriptor pDescriptor)
This method will build a single
PropertyMappingElement
object which reflects all of the information contained within the
pPropertyElement parameter. |
void |
clearCache()
This method can be used to clear the cache that is maintained internally
by this class.
|
void |
doStartService()
This method will determine if the mapping files pointed to by this
component should be parsed on start-up.
|
void |
error(org.xml.sax.SAXParseException pException)
Register this class to handle parse exceptions during a mapping file.
|
void |
fatalError(org.xml.sax.SAXParseException pException)
Register this class to handle parse exceptions during a mapping file.
|
protected org.w3c.dom.Document |
getDocumentObject(java.io.InputStream pInputStream)
Utility method which will return the inputstream as a Document
object to us.
|
protected RepositoryItemDescriptor |
getItemDescriptor(org.w3c.dom.Element pElement)
This method returns the item-descriptor that is referred to
by the top-level item-descriptor mapping element.
|
RepositoryItemDescriptor |
getItemDescriptor(Repository pRepository,
org.w3c.dom.Element pElement)
This method will retrieve the item-descriptor that is specified
on the
element passed to this method that is defined
in the repository passed to this method. |
atg.repository.databinding.ItemMappingElement |
getMapping(java.lang.String pMappingFileName)
This method will retrieve a parsed tree of mapping file information
for a given mapping file.
|
java.io.File[] |
getMappingFileDirectories()
A set of directories can be specified that mapping files will be obtained
from.
|
java.io.File |
getMappingFileDirectory()
Deprecated.
This property has been deprecated, the
mappingFileDirectories property should be used instead
since it allows the user to specify multiple directories. |
java.lang.String |
getMappingFileExtension()
The extension that is expected to be on mapping files.
|
java.lang.String[] |
getMappingFileNames()
Rturns a list of the mapping files that this component points to.
|
protected java.io.InputStream |
getMappingInputStream(java.lang.String pMappingFileName)
This method returns the input stream that is associated with the specified
mapping file.
|
Repository |
getRepository(org.w3c.dom.Element pElement)
Given an element, try to extract the path to a Nucleus repository
component.
|
boolean |
isItemDescriptorValidForProperty(RepositoryItemDescriptor pItemDescriptor,
java.lang.String pPropertyName,
RepositoryItemDescriptor pMapElementItemDescriptor)
This method determines if the item-descriptor which was specified
in the mapping file refers to an item-descriptor type that is valid
for the target property on the item-descriptor defined in the repository.
|
boolean |
isParseMappingsOnStartup()
Whether or not the mapping files that this component points to should
be parsed on start-up.
|
atg.repository.databinding.ItemMappingElement |
newItemMappingElement()
Creates a new ItemMappingElement object.
|
atg.repository.databinding.PropertyMappingElement |
newPropertyMappingElement()
This method creates a new PropertyMappingElement.
|
void |
parseAllFiles()
Parse all the mapping files that are pointed to by this component.
|
void |
populateItemMappingProperties(atg.repository.databinding.ItemMappingElement pItemMapping,
org.w3c.dom.Element pItemElement,
RepositoryItemDescriptor pDescriptor)
This method populates the ItemMappingElement object passed
to it with two properties
the repository defined on the
pElement
the item-descriptor defined on the pElement
If the repository or item-descriptor is not defined on the
pElement passed to this method then the values will
be set to null. |
void |
populatePropertyMappingProperties(atg.repository.databinding.PropertyMappingElement pPropertyMapping,
org.w3c.dom.Element pElement)
This method populates the PropertyMappingElement object passed
to it with three properties
the include information from the
pElement That is,
whether or not the property associated with this object should
be included in the externalized data-model
the property name as it should appear in the item-descriptor
(name)
the property name as it should appear in the target datamodel
Any values not specified in the xml mapping file will be set
to null. |
void |
setMappingFileDirectories(java.io.File[] pMappingFileDirectories)
Sets property MappingFileDirectories
|
void |
setMappingFileDirectory(java.io.File pMappingFileDirectory)
Set the mappingFileDirectory property.
|
void |
setMappingFileExtension(java.lang.String mappingFileExtension)
Sets the mappingFileExtension.
|
void |
setParseMappingsOnStartup(boolean pParseMappingsOnStartup)
Set the parseMappingsOnStartup property.
|
void |
warning(org.xml.sax.SAXParseException pException)
Register this class to handle parse exceptions during a mapping file.
|
addLogListener, createAdminServlet, 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
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
public static java.lang.String CLASS_VERSION
public static final java.lang.String ITEM_DESC_TAG_NAME
public static final java.lang.String PROPERTY_TAG_NAME
public static final java.lang.String REPOSITORY_PATH
public static final java.lang.String ITEM_DESC_NAME
public static final java.lang.String NAME_ATTR
public static final java.lang.String TARGET_NAME_ATTR
public static final java.lang.String INCLUDE_ATTR
public static final java.lang.String DEFAULT_INCLUDE_ATTR
public java.lang.String getMappingFileExtension()
public void setMappingFileExtension(java.lang.String mappingFileExtension)
mappingFileExtension
- The mappingFileExtension to setpublic boolean isParseMappingsOnStartup()
public void setParseMappingsOnStartup(boolean pParseMappingsOnStartup)
pParseMappingsOnStartup
- public java.io.File[] getMappingFileDirectories()
mappingFileDirectory
because of the ability to specify
multiple directories.
If values for this property are specified in addition to the
mappingFileDirectory
, then files will be obtained from
both the directories associated with the mappingFileDirectories
as well as the mappingFileDirectory property.public void setMappingFileDirectories(java.io.File[] pMappingFileDirectories)
pMappingFileDirectories
- public java.io.File getMappingFileDirectory()
mappingFileDirectories
property should be used instead
since it allows the user to specify multiple directories.public void setMappingFileDirectory(java.io.File pMappingFileDirectory)
pMappingFileDirectory
- public void doStartService() throws ServiceException
getMapping()
method with the file
name thus placing them in the cache.
The list of files that are pointed to by this component is determined
by invoking the getMappingFileNames()
method.doStartService
in class GenericService
ServiceException
- if an error occurspublic atg.repository.databinding.ItemMappingElement getMapping(java.lang.String pMappingFileName) throws MappingException
mappingFileDirectory
property
on this class.
This method will check for a mapping file that lives in the cache
keyed by pMappingFileName
parameter. If no entry is found
in the cache then this method will resolve the file and parse it into
a configuration tree.pMappingFileName
- the name of the mapping file to parse relative
to the mappingFileDirectory parameter.java.io.IOException
- if an error occursMappingException
- if an error occurs during the processing
of a mapping file.public atg.repository.databinding.ItemMappingElement buildItemMappingElement(org.w3c.dom.Element pItemElement, RepositoryItemDescriptor pDescriptor) throws MappingException, RepositoryException
pItemElement
parameter. It will call the
populateItemMappingProperties()
method to populate all
of the properties from the pItemElement to the ItemMappingElement.
Finally, it will iterator over all the child element tags of
pItemElement
. For each child element which is a property
tag it will ensure that property referred to by this child element is
a legal property on the item-descriptor that the pItemElement
referred to. If a legal property element is found, the
buildPropertyMappingElement()
method is called. The
buildPropertyMappingElement()
can recursively call the
buildItemMappingElement()
method thus allowing the creation
of the entire mapping configuration tree.
When this method completes, a tree of objects that will be generated
which reflects all of the mapping information from the mapping elements
and the properties pointed to by each item-descriptor element
will be verified to exist on the actual item-descriptor in the repository.pItemElement
- XML element from mapping configuration filepDescriptor
- item-descriptor referred to by the
pItemElement
pItemElement
.MappingException
- if an error occursRepositoryException
public atg.repository.databinding.PropertyMappingElement buildPropertyMappingElement(org.w3c.dom.Element pPropertyElement, RepositoryItemDescriptor pDescriptor) throws MappingException, RepositoryException
PropertyMappingElement
object which reflects all of the information contained within the
pPropertyElement
parameter.
This method will create a new PropertyMappingElement and then call
the populatePropertyMappingProperties()
method to
copy properties from the pPropertyElement to the create
PropertyMappingElement.
It will then walk all children element tags defined from the
pPropertyElement
. For each child tag, it will first ensure
that the item-descriptor type mentioned in the element tag is assignable
to the property. If it is, then the buildItemMappingElement method will
be called.pPropertyElement
- the property element from the mapping config filepDescriptor
- the item-descriptor that the property referred to by
the pPropertyElement
refers topPropertyElement
MappingException
RepositoryException
protected java.io.InputStream getMappingInputStream(java.lang.String pMappingFileName) throws MappingException, java.io.IOException
pMappingFileName
- the name of the mapping file to return the
InputStream to. This filename is resolved relative to the
mappingFileDirectory
.MappingException
- if an error occured while trying to access
the mappingInputStream.java.io.IOException
public void clearCache()
protected org.w3c.dom.Document getDocumentObject(java.io.InputStream pInputStream) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException
pInputStream
- input stream that contains a mapping instance documentjavax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
java.io.IOException
protected RepositoryItemDescriptor getItemDescriptor(org.w3c.dom.Element pElement) throws MappingException, RepositoryException
pElement
- the element which is an item-descriptor
element from a mapping fileMappingException
RepositoryException
public atg.repository.databinding.ItemMappingElement newItemMappingElement()
ItemMappingElement
public atg.repository.databinding.PropertyMappingElement newPropertyMappingElement()
PropertyMappingElement
public void populateItemMappingProperties(atg.repository.databinding.ItemMappingElement pItemMapping, org.w3c.dom.Element pItemElement, RepositoryItemDescriptor pDescriptor) throws MappingException, RepositoryException
pElement
pElement
pElement
passed to this method then the values will
be set to null.pItemMapping
- an ItemMappingElement
valuepElement
- an Element
valuepDescriptor
- the RepositoryItemDescriptor that the
ItemMappingElement backs.MappingException
RepositoryException
public void populatePropertyMappingProperties(atg.repository.databinding.PropertyMappingElement pPropertyMapping, org.w3c.dom.Element pElement)
pElement
That is,
whether or not the property associated with this object should
be included in the externalized data-model
pItemMapping
- an ItemMappingElement
valuepElement
- an Element
valuepublic Repository getRepository(org.w3c.dom.Element pElement) throws MappingException
pElement
parameter passed to this method is expected
to have an attribute on it whose name matches the
repository path
constant defined
on this class.pElement
- the element that a repository path will be extracted
fromMappingException
- if an error occurspublic RepositoryItemDescriptor getItemDescriptor(Repository pRepository, org.w3c.dom.Element pElement) throws MappingException, RepositoryException
element
passed to this method that is defined
in the repository
passed to this method.
The pElement
parameter passed to this method is expected
to have an attribute on it whose name matches the
item-descriptor name
constant defined
on this class.pRepository
- the repository that the item-descriptor is defined inpElement
- the element that contains the item-descriptor nameMappingException
- if an error occursRepositoryException
public boolean isItemDescriptorValidForProperty(RepositoryItemDescriptor pItemDescriptor, java.lang.String pPropertyName, RepositoryItemDescriptor pMapElementItemDescriptor) throws RepositoryException
pItemDescriptor
- the item-descriptor defined in a repository whose
property is currently being operated onpPropertyName
- the property that is being modified in some waypMapElementItemDescriptor
- the item-descriptor that comes
from the mapping fileRepositoryException
public java.lang.String[] getMappingFileNames() throws MappingException
MappingException
public void error(org.xml.sax.SAXParseException pException)
error
in interface org.xml.sax.ErrorHandler
pException
- the exceptionpublic void warning(org.xml.sax.SAXParseException pException)
warning
in interface org.xml.sax.ErrorHandler
pException
- the exceptionpublic void fatalError(org.xml.sax.SAXParseException pException)
fatalError
in interface org.xml.sax.ErrorHandler
pException
- the exceptionpublic void parseAllFiles() throws RepositoryException, MappingException, java.io.IOException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
clearCache()
method should be
invoked.RepositoryException
- if an error occursMappingException
- if an error occursjava.io.IOException
- if an error occursjavax.xml.parsers.ParserConfigurationException
- if an error occursorg.xml.sax.SAXException
- if an error occurs