The ATG platform includes two classes that help identify the appropriate mapping file for each item descriptor that you want to use with the repository2xml data binding facility. These classes are used by Web service clients:
atg.repository.xml.ItemDescriptorMapping
atg.repository.xml.ItemDescriptorMappingManager
ItemDescriptorMapping
An ItemDescriptorMapping
is a simple bean that holds information about relationships between repository item descriptors and mapping files. The mapping files describe what properties are to be exposed when an item from that item descriptor is to be transformed into XML. Each ItemDescriptorMapping
pertains to exactly one repository: for example, you would have a UserProfileItemDescriptorMapping
, or a PromotionItemDescriptorMapping
component, each of which would provide a list of item descriptor names from the corresponding repository and their corresponding mapping files.
An ItemDescriptorMapping
contains only three properties:
Property Name | Type | Description |
---|---|---|
|
| The path to the repository supported by this |
|
| The path to the repository supported by this |
|
| A map where the keys are item descriptor names and the values are locations of mapping files, relative to the configuration path, which provide rules for how an item of the keyed item descriptor name appears in XML format |
Here is an example properties file for an ItemDescriptorMapping
that supports the profile repository:
$class=atg.repository.xml.ItemDescriptorMapping repository=/atg/userprofiling/ProfileAdapterRepository itemDescriptorMapping=\ user=/atg/userprofiling/userMapping.xml,\ contactInfo=/atg/userprofiling/contactInfoMapping.xml
Here we see the there are two entries in the itemDescriptorMapping
property, one for the user
item descriptor, and one for the contactInfo
item descriptor.
Whenever an entry is added to the itemDescriptorMapping
property, whether through a properties file, or directly in code, the ItemDescriptorMapping
checks to make sure that the key of the entry, the item descriptor name, resolves to an actual item descriptor of the repository this service is configured to support. If any item descriptor name does not resolve, a RepositoryException
is thrown.
By themselves, ItemDescriptorMappings
don’t do any work. They simply hold state. In order to put them to work, you must add them to the ItemDescriptorMappingManager
, described below.
ItemDescriptorMappingManager
Class: atg.repository.xml.ItemDescriptorMappingManager
Component: /atg/repository/xml/ItemDescriptorMappingManager
Module: DAS
The ItemDescriptorMappingManager
serves as a registry of ItemDescriptorMappings
. It is through this service that you obtain mapping files for all repository and item descriptor combinations. The mapping files are registered in the itemDescriptorMappings
property of the ItemDescriptorMappingManager
component:
Property Name | Type | Description |
---|---|---|
|
| An array of |
Here is an example properties file:
$class=atg.repository.xml.ItemDescriptorMappingManager itemDescriptorMappings=\ /atg/userprofiling/UserProfileItemMapping,\ /atg/userprofiling/ContactInfoItemMapping
The following ItemDescriptorMappingManager
methods can be used to retrieve mapping files:
getMappingFileName(String pRepositoryPath, String pItemDescriptorName)
Using the given repository path and item descriptor name, returns the mapping file for that given path:name combination, or null if none exists.
getMappingFileName(Repository pRepository, String pItemDescriptorName)
Using the given repository and item descriptor name, returns the mapping file for that given repository:name combination, or null if none exists.
When you use the atg.repository.xml.GetService
to get repository items in XML form, you can pass along a mapping file name using these ItemDescriptorMappingManager
methods. Using the ItemDescriptorMappingManager
, you can centralize all mapping files in one component for all item descriptors, and just call that to determine which mapping file to use for a given item descriptor.