Package com.jalios.jcms
Class TypeTemplateEntry
- java.lang.Object
-
- com.jalios.jcms.TypeTemplateEntry
-
- All Implemented Interfaces:
TypeConstants
,java.lang.Comparable
public class TypeTemplateEntry extends java.lang.Object implements TypeConstants, java.lang.Comparable
This class contains info about Type's template.- Since:
- jcms-6.0.0
- Author:
- Jean-Philippe Encausse
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TypeTemplateEntry.LabelComparator
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
className
protected java.util.Map<java.lang.String,java.lang.String>
descriptionMap
protected boolean
isInternal
protected boolean
isPlugged
protected java.util.Map<java.lang.String,java.lang.String>
labelMap
protected java.lang.String
name
protected java.lang.String
path
protected java.lang.String
usage
static java.lang.String
USAGE_DISPLAY_BOX
static java.lang.String
USAGE_DISPLAY_FULL
static java.lang.String
USAGE_DISPLAY_FULL_PDA
static java.lang.String
USAGE_DISPLAY_MODAL
static java.lang.String
USAGE_DISPLAY_QUERY
static java.lang.String
USAGE_DISPLAY_QUERY_PDA
static java.lang.String
USAGE_EDIT
static java.lang.String
USAGE_EDIT_FRONT
static java.lang.String
USAGE_EDIT_MODAL
static java.lang.String
USAGE_EDIT_MODAL_FULL
static java.lang.String
USAGE_EDIT_POPUP
protected org.jdom.Element
xmlElt
-
Fields inherited from interface com.jalios.jcms.TypeConstants
CHANGE_LEVEL_CLASS, CHANGE_LEVEL_JSP, CHANGE_LEVEL_NONE, DISPLAY_TPLT_TAG, EXTENSIONS_XML, FIELD_ELT, FIELD_NEW_MARK, FIELD_UPDATED_MARK, FIELDS_ELT, FILE_INDEX_LISTENER, LINK_INDEX_LISTENER, OLD_TYPES_DIR, PACKAGE_NAME, PACKAGE_NAME_SUFFIX, QUERY_TPLT_TAG, TAB_ELT, TABS_ELT, TEMPLATE_TAG, TEMPLATES_SUFFIX, TEMPLATES_TAG, TITLE_ELT, TYPE_ELT, TYPE_FORCE_UPDATE_MARK, TYPE_NEW_MARK, TYPE_UPDATED_MARK, TYPES_DIR, TYPES_XML
-
-
Constructor Summary
Constructors Constructor Description TypeTemplateEntry()
Default Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String[]
checkIntegrity()
Check the integrity of the template fieldsint
compareTo(java.lang.Object obj)
static void
convertTemplate(java.io.File tmplFile)
Convert the given File representing type's templates from JCMS 5.7.x to JCMS 6.0.xstatic void
convertTemplate(org.jdom.Element elm, boolean isPortlet)
Convert the given JDOM Element representing a template declaration from JCMS 5.7.x to JCMS 6.0.xstatic TypeTemplateEntry
decodeTemplate(java.lang.String className, org.jdom.Element xmlElt, java.lang.String folderPath)
Build a TypeTemplateEntry from the given JDom Elementstatic org.jdom.Element
encodeTemplate(TypeTemplateEntry tte)
Build a JDom Element from the given TypeTemplateEntryboolean
equals(java.lang.Object obj)
java.lang.String
getClassName()
java.lang.String
getDescription(java.lang.String userLang)
Returns the description of the template for given user languagejava.util.Map<java.lang.String,java.lang.String>
getDescriptionMap()
Returns the map of descriptions.java.lang.String
getInternalName()
Returns the full name of the template that will be stored in the store.xml.java.lang.String
getLabel(java.lang.String userLang)
Returns the label of the template for given user languagejava.util.Map<java.lang.String,java.lang.String>
getLabelMap()
Returns the map of labels.java.lang.String
getName()
Returns the name of the template (== usage + "." + internalName).java.lang.String
getPath()
Returns the path (e.g.java.lang.String
getThumbnailPath()
Returns the path to the thumbnail of this template or s.gif if it could not be found.java.lang.String
getThumbnailPath(int width, int height, java.lang.String defaultImagePath)
Retrieve the path to the thumbnail of this template in the specified dimension.java.lang.String
getUsage()
Returns the usage of the template (e.g.boolean
isInternal()
Returns true if the template entry has been generated by JCMS without parsing an existing TypeElement.boolean
isPlugged()
Returns true if the template entry has been added by pluggin mechanism.void
reloadI18N()
Reload all I18N informations for this type template entry.static TypeTemplateEntry
resolveDefaultTemplateEntry(java.util.Set<TypeTemplateEntry> tmplSet, java.lang.String defaultUsage, java.lang.String defaultPath)
Returns a default TypeTemplateEntry in the given Set otherwise return a dummy template with the defaultUsage.void
setDescription(java.lang.String userLang, java.lang.String value)
Set the description for the given user languagevoid
setDescriptionMap(java.util.Map<java.lang.String,java.lang.String> descriptionMap)
Set the descriptions for the given template.void
setInternalName(java.lang.String name)
Set the name of the template this name must be unique for the type declaration.void
setLabel(java.lang.String userLang, java.lang.String value)
Set the label for the given user languagevoid
setLabelMap(java.util.Map<java.lang.String,java.lang.String> labelMap)
Set the labels for the given template.void
setPath(java.lang.String path)
Set the path of the template.void
setPlugged(boolean plugged)
Returns true if the template entry has been added by pluggin mechanism.void
setUsage(java.lang.String usage)
Set the usage of the template (e.g.java.lang.String
toString()
-
-
-
Field Detail
-
USAGE_DISPLAY_BOX
public static final java.lang.String USAGE_DISPLAY_BOX
- See Also:
- Constant Field Values
-
USAGE_DISPLAY_FULL
public static final java.lang.String USAGE_DISPLAY_FULL
- See Also:
- Constant Field Values
-
USAGE_DISPLAY_QUERY
public static final java.lang.String USAGE_DISPLAY_QUERY
- See Also:
- Constant Field Values
-
USAGE_DISPLAY_MODAL
public static final java.lang.String USAGE_DISPLAY_MODAL
- See Also:
- Constant Field Values
-
USAGE_DISPLAY_FULL_PDA
public static final java.lang.String USAGE_DISPLAY_FULL_PDA
- See Also:
- Constant Field Values
-
USAGE_DISPLAY_QUERY_PDA
public static final java.lang.String USAGE_DISPLAY_QUERY_PDA
- See Also:
- Constant Field Values
-
USAGE_EDIT
public static final java.lang.String USAGE_EDIT
- See Also:
- Constant Field Values
-
USAGE_EDIT_FRONT
public static final java.lang.String USAGE_EDIT_FRONT
- See Also:
- Constant Field Values
-
USAGE_EDIT_MODAL
public static final java.lang.String USAGE_EDIT_MODAL
- See Also:
- Constant Field Values
-
USAGE_EDIT_POPUP
public static final java.lang.String USAGE_EDIT_POPUP
- See Also:
- Constant Field Values
-
USAGE_EDIT_MODAL_FULL
public static final java.lang.String USAGE_EDIT_MODAL_FULL
- See Also:
- Constant Field Values
-
className
protected java.lang.String className
-
xmlElt
protected org.jdom.Element xmlElt
-
name
protected java.lang.String name
-
usage
protected java.lang.String usage
-
path
protected java.lang.String path
-
labelMap
protected java.util.Map<java.lang.String,java.lang.String> labelMap
-
descriptionMap
protected java.util.Map<java.lang.String,java.lang.String> descriptionMap
-
isInternal
protected boolean isInternal
-
isPlugged
protected boolean isPlugged
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the name of the template (== usage + "." + internalName).This name must be unique for the type declaration.
- Returns:
- String the name of the template
-
getInternalName
public java.lang.String getInternalName()
Returns the full name of the template that will be stored in the store.xml.This is the name attribute value of the template's XML.
- Returns:
- String the name of the template
-
setInternalName
public void setInternalName(java.lang.String name)
Set the name of the template this name must be unique for the type declaration.- Parameters:
name
- the name of the template, eg "carousel"
-
getPath
public java.lang.String getPath()
Returns the path (e.g. jsp file) to the template. This path is not overrided by PluginPolicyFilter.- Returns:
- String the path to the template file
-
setPath
public void setPath(java.lang.String path)
Set the path of the template.- Parameters:
path
- the path of the JSP used by this template, relative to the webapp root, eg "types/PortletQueryForeach/doPortletQueryForeachCarousel.jsp"
-
getUsage
public java.lang.String getUsage()
Returns the usage of the template (e.g. full, query, pda, box, ...).- Returns:
- String the usage of the template
-
setUsage
public void setUsage(java.lang.String usage)
Set the usage of the template (e.g. full, query, pda, box, ...).- Parameters:
usage
- a template usage, e.g. "box"
-
getLabel
public java.lang.String getLabel(java.lang.String userLang)
Returns the label of the template for given user language- Parameters:
userLang
- the user language- Returns:
- String the label
-
setLabel
public void setLabel(java.lang.String userLang, java.lang.String value)
Set the label for the given user language- Parameters:
userLang
- the user languagevalue
- the label
-
getLabelMap
public java.util.Map<java.lang.String,java.lang.String> getLabelMap()
Returns the map of labels. Should only be used internally.- Returns:
- Map of labels
-
setLabelMap
public void setLabelMap(java.util.Map<java.lang.String,java.lang.String> labelMap)
Set the labels for the given template. Should only be used internally.- Parameters:
labelMap
- the Map of label
-
getDescription
public java.lang.String getDescription(java.lang.String userLang)
Returns the description of the template for given user language- Parameters:
userLang
- the user language- Returns:
- String the map description
-
setDescription
public void setDescription(java.lang.String userLang, java.lang.String value)
Set the description for the given user language- Parameters:
userLang
- the user languagevalue
- the description
-
getDescriptionMap
public java.util.Map<java.lang.String,java.lang.String> getDescriptionMap()
Returns the map of descriptions. Should only be used internally.- Returns:
- descriptions
-
setDescriptionMap
public void setDescriptionMap(java.util.Map<java.lang.String,java.lang.String> descriptionMap)
Set the descriptions for the given template. Should only be used internally.- Parameters:
descriptionMap
- the map of description
-
isInternal
public boolean isInternal()
Returns true if the template entry has been generated by JCMS without parsing an existing TypeElement.- Returns:
- true if it is generated.
-
isPlugged
public boolean isPlugged()
Returns true if the template entry has been added by pluggin mechanism.- Returns:
- true if it has been plugged.
-
setPlugged
public void setPlugged(boolean plugged)
Returns true if the template entry has been added by pluggin mechanism.- Parameters:
plugged
- set true if template was added through plugin, false othewise
-
getThumbnailPath
public java.lang.String getThumbnailPath()
Returns the path to the thumbnail of this template or s.gif if it could not be found.- Returns:
- String path to thumbnail or "s.gif"
-
getThumbnailPath
public java.lang.String getThumbnailPath(int width, int height, java.lang.String defaultImagePath)
Retrieve the path to the thumbnail of this template in the specified dimension.If the thumbnail could not be created (no preview available for this template), the defaultImagePath is returned instead.
Warning : This method create a thumbnail when it does not exists, this process can be a little time consumming, make sure you do not need immediate response time when using it.
- Parameters:
width
- the width of the thumbnail to create/reuseheight
- the height of the thumbnail to create/reusedefaultImagePath
- the default image path used if the thumbnail could not be created- Returns:
- a path relative to the webapp root (e.g. "types/PortletRSS/th-60x45-doPortletRSSFullDisplay.jpg.jpg").
-
getClassName
public java.lang.String getClassName()
-
checkIntegrity
public java.lang.String[] checkIntegrity()
Check the integrity of the template fields- Returns:
- String list of errors or ""
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
compareTo
public int compareTo(java.lang.Object obj)
- Specified by:
compareTo
in interfacejava.lang.Comparable
-
resolveDefaultTemplateEntry
public static TypeTemplateEntry resolveDefaultTemplateEntry(java.util.Set<TypeTemplateEntry> tmplSet, java.lang.String defaultUsage, java.lang.String defaultPath)
Returns a default TypeTemplateEntry in the given Set otherwise return a dummy template with the defaultUsage. Warning ! do not check the usage of provided TypeTemplateEntry- Parameters:
tmplSet
- a Set of TypeTemplateEntry (that may already refined on usage or null)defaultUsage
- the template usagedefaultPath
- null or override the path of the dummy tte- Returns:
- TypeTemplateEntry
- Since:
- jcms-6.0.1
-
convertTemplate
public static void convertTemplate(java.io.File tmplFile) throws org.jdom.JDOMException, java.io.IOException
Convert the given File representing type's templates from JCMS 5.7.x to JCMS 6.0.x- Parameters:
tmplFile
- the type's template file Type-template.xml- Throws:
org.jdom.JDOMException
- if XML of the specified file could not be parsedjava.io.IOException
- if specified file could not opened or new file could not be written
-
convertTemplate
public static void convertTemplate(org.jdom.Element elm, boolean isPortlet)
Convert the given JDOM Element representing a template declaration from JCMS 5.7.x to JCMS 6.0.x- Parameters:
elm
- JDOM Element with qname "template"isPortlet
- indicate if the template being converted is a portlet, when working with display template element, setting to true will use "box" usage, false will use "full" usage
-
decodeTemplate
public static TypeTemplateEntry decodeTemplate(java.lang.String className, org.jdom.Element xmlElt, java.lang.String folderPath)
Build a TypeTemplateEntry from the given JDom Element<template usage="PDA" name="lorem" file="doLoremDisplay.jsp"> <label xml:lang="en">Lorem</label> <label xml:lang="fr">Ipsum</label> <description xml:lang="en">Lorem ipsum dolor sit amet</description> <description xml:lang="fr">Lorem ipsum dolor sit amet</description> </template>
- Parameters:
className
- the short classname of the Type for which this template is decoded (eg Article, TestType, PortletSearch)xmlElt
- a JDom ElementfolderPath
- path to the template file- Returns:
- a new instance of TypeTemplateEntry, never return null
-
encodeTemplate
public static org.jdom.Element encodeTemplate(TypeTemplateEntry tte)
Build a JDom Element from the given TypeTemplateEntry<template usage="PDA" name="lorem" file="doLoremDisplay.jsp"> <label xml:lang="en">Lorem</label> <label xml:lang="fr">Ipsum</label> <description xml:lang="en">Lorem ipsum dolor sit amet</description> <description xml:lang="fr">Lorem ipsum dolor sit amet</description> </template>
- Parameters:
tte
- TypeTemplateEntry- Returns:
- return a new instance of JDOM "template" XML Element, never return null
-
reloadI18N
public void reloadI18N()
Reload all I18N informations for this type template entry. This includes : label and description.- Since:
- jcms-8.0.2
-
-