Class 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 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 UMSException
        Default 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 null if 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 null if 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 null if 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 null if 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 null if 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 null if 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 modified
        orgGuid - the guid of the Organization where the config data is stored
        Throws:
        UMSException - if an exception occurs