Class TypeProcessor

  • All Implemented Interfaces:
    JcmsConstants, TypeConstants, JaliosConstants

    public class TypeProcessor
    extends java.lang.Object
    implements TypeConstants, JcmsConstants
    This class generates all the resources (Java classes and JSPs) used by the Custom Publication Types and Custom Extension Types.

    This class replaces TypeGenerator class. It uses now a template mechanism to produces all the source code (Java and JSP)

    Since:
    jcms-3.0
    Version:
    $Revision: 119599 $
    Author:
    Olivier Dedieu
    • Field Detail

      • EMPTY_TYPEFIELDENTRY_ARRAY

        public static final TypeFieldEntry[] EMPTY_TYPEFIELDENTRY_ARRAY
      • extendedTypeList

        protected java.util.List<java.lang.String> extendedTypeList
      • extensionsTabsMap

        protected java.util.Map<java.lang.String,​java.lang.String> extensionsTabsMap
      • compilerCmdLine

        protected java.util.ArrayList<java.lang.String> compilerCmdLine
      • rt

        protected java.lang.Runtime rt
      • compileList

        protected java.util.List<java.lang.String> compileList
      • hbmList

        protected java.util.List<java.lang.Class<?>> hbmList
    • Method Detail

      • getInstance

        public static TypeProcessor getInstance()
        Returns the TypeProcessor singleton instance.
        Initialize it if it was not already done. Channel must be available!
        Returns:
        the TypeProcessor singleton instance
      • getCurrentTypeDocument

        public org.jdom.Document getCurrentTypeDocument()
        Returns:
        the jdom Document instance of the current type
        Since:
        jcms-3.0
      • getTypeDocument

        public org.jdom.Document getTypeDocument()
        Returns:
        the jdom Document containing all Types Element
        Since:
        jcms-3.0
      • getNewTypeDocument

        public org.jdom.Document getNewTypeDocument​(boolean create)
        Parameters:
        create - whether a new one should be created if it has not been created yet
        Returns:
        the Document (copy of getTypeDocument() being edited)
        Since:
        jcms-3.0
      • revertTypeDocument

        public void revertTypeDocument()
        Revert the currently edited TypeDocument.
        Since:
        jcms-3.0
      • getCustomTypeList

        public java.util.List<java.lang.Class<?>> getCustomTypeList()
        Returns:
        a list of Class
        Since:
        jcms-3.0
      • getCustomExtensionMap

        public java.util.Map<java.lang.String,​java.lang.Class<?>> getCustomExtensionMap()
        Retrieves the map of custom extension
        Returns:
        the map of string to class
        Since:
        jcms-3.0
      • getExtendedTypeList

        public java.util.List<java.lang.String> getExtendedTypeList()
        Returns all the classes which have a Data extension.
        Usually: "Category", "FileDocument", "Group", "Member", "Workspace"
        Returns:
        a List of String.
      • getExtensionsTabsMap

        public java.util.Map<java.lang.String,​java.lang.String> getExtensionsTabsMap()
      • getHbmList

        public java.util.List<java.lang.Class<?>> getHbmList()
        Returns the list of class an HBM has been generated.
        Returns:
        the list of class an HBM has been generated.
        Since:
        jcms-6.0.0
      • processTypes

        public void processTypes()
                          throws java.lang.Exception
        Generate all type's resources from the types/ directory (for old JCMS data, convert types.xml file, to the new types organization and extensions.xml file to the new extensions organization)
        Throws:
        java.lang.Exception - if an error occurs
        Since:
        jcms-3.0
      • isInGeneratedDir

        public boolean isInGeneratedDir​(java.io.File file)
        Looks if the file is under a generation files (classes/generated and types).
        Parameters:
        file - A possibly generated file
        Returns:
        true if the file is in under generated directory
        Since:
        JCMS-6.0.2
      • saveNewTypeDocument

        public void saveNewTypeDocument​(boolean restartChannel)
                                 throws java.io.IOException
        Saves the currently edited TypeDocument. Once saved, the newTypeDocument object is reset to null.
        Parameters:
        restartChannel - if true, once the new types was successfully saved, the channel is restarted
        Throws:
        java.io.IOException - if an error occurs during saving
      • applyTypeChange

        public void applyTypeChange()
                             throws java.lang.Exception
        Throws:
        java.lang.Exception - if an error occurs
        Since:
        jcms-3.0
      • getTypeChangeLevel

        public int getTypeChangeLevel()
        Returns:
        the kind of type changed occured (none/jsp/class)
        Since:
        jcms-3.0
      • getTypeEntry

        public TypeEntry getTypeEntry​(java.lang.Class<?> clazz)
        Return the TypeEntry class associated to the given Class. Return null if no TypeEntry is bound to clazz.
        Parameters:
        clazz - the Class of which to find the TypeEntry
        Returns:
        the TypeEntry associated to the given class or null if not available.
      • getTypeEntry

        public TypeEntry getTypeEntry​(java.lang.String clazzName)
        Return the TypeEntry class associated to the given Class name. Return null if no TypeEntry is bound to clazzName.
        Parameters:
        clazzName - the String representing the name the Class of which to find the TypeEntry
        Returns:
        the TypeEntry associated to the given class or null if not available.
      • getTypeFieldEntries

        public TypeFieldEntry[] getTypeFieldEntries​(java.lang.Class<?> clazz)
        Return an array of TypeFieldEntry bound to given Class.
        This array does not contain inherited TypeFieldEntry from super classes of given Class.
        Parameters:
        clazz - the Class of which to find the TypeFieldEntry.
        Returns:
        an array of TypeFieldEntry containing all Field used by Class or an empty array (never return null)
        Since:
        jcms-5.5
      • getTypeFieldEntries

        public TypeFieldEntry[] getTypeFieldEntries​(java.lang.String clazzName)
        Return an array of TypeFieldEntry bound to given Class represented by its class name.
        This array does not contain inherited TypeFieldEntry from super classes of given Class.
        Parameters:
        clazzName - the String representing the name the Class of which to find the TypeFieldEntry
        Returns:
        an array of TypeFieldEntry containing all Field used by Class or an empty array (never return null)
        Since:
        jcms-5.5
      • getAllTypeFieldEntries

        public TypeFieldEntry[] getAllTypeFieldEntries​(java.lang.Class<?> clazz)
        Return an array of TypeFieldEntry bound to given Class.
        This array does contain inherited TypeFieldEntry from super classes of given Class.
        Parameters:
        clazz - the Class of which to find the TypeFieldEntry.
        Returns:
        an array of TypeFieldEntry containing all Field used by Class or an empty array (never return null)
        Since:
        jcms-5.5
      • getAllTypeFieldEntries

        public TypeFieldEntry[] getAllTypeFieldEntries​(java.lang.String clazzName)
        Return an array of TypeFieldEntry bound to given Class represented by its class name.
        This array does contain inherited TypeFieldEntry from super classes of given Class.
        Parameters:
        clazzName - the String representing the name the Class of which to find the TypeFieldEntry
        Returns:
        an array of TypeFieldEntry containing all Field used by Class or an empty array (never return null)
        Since:
        jcms-5.5
      • getTypeLabel

        @Deprecated
        public java.lang.String getTypeLabel​(java.lang.Class<?> clazz)
        Deprecated.
        since jcms-5.7.0
        Returns the label of a given type (if TypeEntry is not null use it, otherwise return the short class name)
        Parameters:
        clazz - the class to get the label
        Returns:
        the type label
        Since:
        jcms-5.0.0
        See Also:
        getTypeLabel(Class, String)
      • getTypeLabel

        public java.lang.String getTypeLabel​(java.lang.Class<?> clazz,
                                             java.lang.String lang)
        Returns the label of a given type (class) localized for the given language.
        Parameters:
        clazz - the class
        lang - the language
        Returns:
        the type label
        Since:
        jcms-5.7.0
      • getTypeDescription

        public java.lang.String getTypeDescription​(java.lang.Class<?> clazz,
                                                   java.lang.String lang)
        Returns the description of a given type (class) localized for the given language.
        Parameters:
        clazz - the class
        lang - the language
        Returns:
        the Type description
        Since:
        jcms-5.0.0
      • markTypeAsUpdated

        public static void markTypeAsUpdated​(org.jdom.Element typeElt,
                                             boolean markSubTypes,
                                             boolean forceUpdate)
        Mark the given type as updated and also its sub-types (and their "super" field)
        Parameters:
        typeElt - the type to mark as updated
        markSubTypes - if true, marks all its sub-types as updated
        forceUpdate - if true, the type (and sub-types if 'markSubTypes' is true) will be force to be updated (i.e. regenerated)
        Since:
        jcms-4.0
      • isCompilationDone

        public boolean isCompilationDone()