Package com.iplanet.ums
Class TemplateManager
- java.lang.Object
-
- com.iplanet.ums.TemplateManager
-
- All Implemented Interfaces:
Serializable
public class TemplateManager extends Object implements Serializable
The class manages a set of templates. The set of templates can be used to define what attributes to use when creating an object, or what attributes to retrieve for a particular object.Example:
TemplateManager mgr = TemplateManager.getTemplateManager(); Guid guid = new Guid("o=vortex.com"); CreationTemplate t1 = mgr.getCreationTemplate("BasicUser", guid, TemplateManager.SCOPE_ANCESTORS); CreationTemplate t2 = mgr.getCreationTemplate(User.class, guid, TemplateManager.SCOPE_ANCESTORS); SearchTemplate t3 = mgr.getSearchTemplate("BasicUserSearch", guid, TemplateManager.SCOPE_ANCESTORS);- See Also:
Template,CreationTemplate,SearchTemplate, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intSCOPE_ANCESTORSSearch scope for determining how to get the configuration data.static intSCOPE_ORGSearch scope for determining how to get the configuration data.static intSCOPE_TOPSearch scope for determining how to get the configuration data.
-
Constructor Summary
Constructors Modifier Constructor Description protectedTemplateManager()Default constructor that registers a default class resolver and accesses template configuration information.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddClassResolver(IClassResolver resolver)Registers a class that can resolve a set of attributes to a Java class.CreationTemplategetCreationTemplate(Class cls, Guid orgGuid)Given a class, gets the default creation template for the object.CreationTemplategetCreationTemplate(Class cls, Guid orgGuid, int scope)Returns default creation template of a given class.CreationTemplategetCreationTemplate(String name, Guid orgGuid)Returns a template from a supplied template name.CreationTemplategetCreationTemplate(String name, Guid orgGuid, int scope)Returns a template from a supplied template name.SetgetCreationTemplateNames(Guid orgGuid)Returns a set of known creation templates.SearchTemplategetSearchTemplate(String name, Guid orgGuid)Returns a template from a supplied template name.SearchTemplategetSearchTemplate(String name, Guid orgGuid, int scope)Returns a template from a supplied template name.SetgetSearchTemplateNames(Guid orgGuid)Returns a set of known search templates.static TemplateManagergetTemplateManager()Clients can only obtain a reference through this method.voidremoveClassResolver(IClassResolver resolver)Unregisters a class that can resolve a set of attributes to a Java class.voidreplaceCreationTemplate(CreationTemplate template, Guid orgGuid)Replaces an existing CreationTemplate with the one specified.
-
-
-
Field Detail
-
SCOPE_ORG
public static final int SCOPE_ORG
Search scope for determining how to get the configuration data. This will get the configuration data at the organization level specified.- See Also:
- Constant Field Values
-
SCOPE_ANCESTORS
public static final int SCOPE_ANCESTORS
Search scope for determining how to get the configuration data. This will get the configuration data from the nearest ancestor containing the configuration data.- See Also:
- Constant Field Values
-
SCOPE_TOP
public static final int SCOPE_TOP
Search scope for determining how to get the configuration data. This will get the configuration data at the organization level, and if not found, then at the root level.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TemplateManager
protected TemplateManager() throws UMSExceptionDefault constructor that registers a default class resolver and accesses template configuration information.- Throws:
UMSException- if an exception occurs registering the resolver or accessing configuration data.
-
-
Method Detail
-
getTemplateManager
public static TemplateManager getTemplateManager() throws UMSException
Clients can only obtain a reference through this method.- Returns:
- the one and only instance
- Throws:
UMSException- if an exception occurs while getting an instance of a template manager.
-
addClassResolver
public void addClassResolver(IClassResolver resolver)
Registers a class that can resolve a set of attributes to a Java class. The last class registered is the first to be called in the resolution chain.- Parameters:
resolver- a class that can produce a Java class instance from an ID and a set of attributes
-
removeClassResolver
public void removeClassResolver(IClassResolver resolver)
Unregisters a class that can resolve a set of attributes to a Java class.- Parameters:
resolver- A class that can produce a Java class instance from an ID and a set of attributes
-
getCreationTemplate
public CreationTemplate getCreationTemplate(Class cls, Guid orgGuid) throws UMSException
Given a class, gets the default creation template for the object. This will traverse the tree all the way to the root until the CreationTemplate is found.- Parameters:
cls- Class (instance of) to be queried for the template.orgGuid- GUID of the Organization where the config data is stored.- Returns:
- Creation template for the class or
nullif the class is not known or no template is registered for the class. - Throws:
UMSException- if an exception occurs while getting the creation template.
-
getCreationTemplate
public CreationTemplate getCreationTemplate(Class cls, Guid orgGuid, int scope) throws UMSException
Returns default creation template of a given class.- Parameters:
cls- Class (instance of) to be queried for the template.orgGuid- GUID of the Organization where the config data is stored.scope- Search scope for determining how to get the configuration data- Returns:
- Creation template for the class or
nullif the class is not known or no template is registered for the class - Throws:
UMSException- if error occurs while getting the creation template.
-
getCreationTemplate
public CreationTemplate getCreationTemplate(String name, Guid orgGuid) throws UMSException
Returns a template from a supplied template name. This will traverse the tree all the way to the root until the CreationTemplate is found.- Parameters:
name- Name of template.orgGuid- GUID of the Organization where the config data is stored.- Returns:
- CreationTemplate matching the supplied name, or
nullif there is no matching template - Throws:
UMSException- if error occurs while getting the creation template.
-
getCreationTemplate
public CreationTemplate getCreationTemplate(String name, Guid orgGuid, int scope) throws UMSException
Returns a template from a supplied template name.- Parameters:
name- Name of template.orgGuid- GUID of the Organization where the config data is stored.scope- Search scope for determining how to get the configuration data.- Returns:
- CreationTemplate matching the supplied name, or
nullif there is no matching template - Throws:
UMSException- if an exception occurs while getting the creation template.
-
getSearchTemplate
public SearchTemplate getSearchTemplate(String name, Guid orgGuid) throws UMSException
Returns a template from a supplied template name. This will traverse the tree all the way to the root till the SearchTemplate is found.- Parameters:
name- Name of template.orgGuid- GUID of the Organization where the config data is stored- Returns:
- SearchTemplate matching the supplied name, or
nullif there is no matching template - Throws:
UMSException- if error occurs while getting the search template.
-
getSearchTemplate
public SearchTemplate getSearchTemplate(String name, Guid orgGuid, int scope) throws UMSException
Returns a template from a supplied template name.- Parameters:
name- Name of Template.orgGuid- GUID of the Organization where the config data is stored.scope- Search scope for determining how to get the configuration data.- Returns:
- SearchTemplate matching the supplied name, or
nullif there is no matching template. - Throws:
UMSException- if an exception occurs while getting the search template.
-
getCreationTemplateNames
public Set getCreationTemplateNames(Guid orgGuid) throws UMSException
Returns a set of known creation templates.- Parameters:
orgGuid- GUID of the Organization where the config data is stored.- Returns:
- Names of known creation templates
- Throws:
UMSException- if an exception occurs.
-
getSearchTemplateNames
public Set getSearchTemplateNames(Guid orgGuid) throws UMSException
Returns a set of known search templates.- Parameters:
orgGuid- GUID of the Organization where the config data is stored.- Returns:
- Names of known search templates.
- Throws:
UMSException- if an exception occurs.
-
replaceCreationTemplate
public void replaceCreationTemplate(CreationTemplate template, Guid orgGuid) throws UMSException
Replaces an existing CreationTemplate with the one specified.- Parameters:
template- CreationTemplate to be modifiedorgGuid- the guid of the Organization where the config data is stored- Throws:
UMSException- if an exception occurs
-
-