Class JCRCategoryProvider
- java.lang.Object
-
- org.ametys.plugins.newsletter.category.JCRCategoryProvider
-
- All Implemented Interfaces:
CategoryProvider
,PluginAware
,Configurable
,LogEnabled
,Serviceable
public class JCRCategoryProvider extends Object implements LogEnabled, CategoryProvider, Serviceable, Configurable, PluginAware
Class representing a JCR categories provider
-
-
Field Summary
Fields Modifier and Type Field Description protected I18nizableText
_description
The descriptionprotected String
_featureName
The feature nameprotected String
_id
The idprotected I18nizableText
_label
The labelprotected Logger
_logger
The Loggerprotected String
_pluginName
The plugin nameprivate AmetysObjectResolver
_resolver
private SiteManager
_siteManager
-
Constructor Summary
Constructors Constructor Description JCRCategoryProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private TraversableAmetysObject
_getRootNode(String sitename, String lang)
protected void
addCategories(Set<Category> categories, TraversableAmetysObject parentObject, String siteName, String lang)
Recursively findJCRCategory
objects in the given TraversableAmetysObject.void
configure(Configuration configuration)
protected I18nizableText
configureDescription(Configuration configuration)
Configure description from the passed configurationprotected I18nizableText
configureLabel(Configuration configuration)
Configure label from the passed configurationvoid
enableLogging(Logger logger)
Collection<Category>
getAllCategories(String siteName, String lang)
Returns all the provider's categories, recursively.Collection<String>
getAutomaticIds(String categoryId)
Get automatic property.List<Category>
getCategories(String categoryID)
Get the sub-categories of a categoryList<Category>
getCategories(String siteName, String lang)
Returns the provider's root categories.Category
getCategory(String categoryID)
Returns the provider's category.I18nizableText
getDescription()
Returns the provider's description.String
getId()
Returns the provider's id.I18nizableText
getLabel()
Returns the provider's label.AmetysObjectIterable<Content>
getNewsletters(String categoryID, String siteName, String lang)
Get the newsletter contents linked to a categoryString
getPluginName()
Get the plugin nameString
getRootId(String siteName, String lang)
Get the root idboolean
hasCategory(String categoryID)
Determines if the category exists.boolean
hasChildren(String categoryID)
Determines if the category has sub-categoriesboolean
hasNewsletters(String categoryID, String siteName, String lang)
Determines if a category has categories linked withboolean
isWritable()
Determines if the categories can be modifiedvoid
service(ServiceManager serviceManager)
void
setAutomatic(String categoryId, Collection<String> automaticNewsletterIds)
Set automatic property.void
setPluginInfo(String pluginName, String featureName, String id)
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.void
setTemplate(Category category, String templateName)
Affect a template to category
-
-
-
Field Detail
-
_label
protected I18nizableText _label
The label
-
_description
protected I18nizableText _description
The description
-
_pluginName
protected String _pluginName
The plugin name
-
_featureName
protected String _featureName
The feature name
-
_resolver
private AmetysObjectResolver _resolver
-
_siteManager
private SiteManager _siteManager
-
-
Constructor Detail
-
JCRCategoryProvider
public JCRCategoryProvider()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
enableLogging
public void enableLogging(Logger logger)
- Specified by:
enableLogging
in interfaceLogEnabled
-
isWritable
public boolean isWritable()
Description copied from interface:CategoryProvider
Determines if the categories can be modified- Specified by:
isWritable
in interfaceCategoryProvider
- Returns:
- true if the categories can be modified
-
getCategories
public List<Category> getCategories(String siteName, String lang)
Description copied from interface:CategoryProvider
Returns the provider's root categories.- Specified by:
getCategories
in interfaceCategoryProvider
- Parameters:
siteName
- The site name. Can be null for all siteslang
- The languages. Can be null for all languages- Returns:
- the provider's root categories.
-
getAllCategories
public Collection<Category> getAllCategories(String siteName, String lang)
Description copied from interface:CategoryProvider
Returns all the provider's categories, recursively.- Specified by:
getAllCategories
in interfaceCategoryProvider
- Parameters:
siteName
- The site name.lang
- The languages.- Returns:
- all the provider's categories.
-
addCategories
protected void addCategories(Set<Category> categories, TraversableAmetysObject parentObject, String siteName, String lang)
Recursively findJCRCategory
objects in the given TraversableAmetysObject.- Parameters:
categories
- the Set to fill with categories.parentObject
- the parentTraversableAmetysObject
.siteName
- the site name.lang
- the language.
-
getCategory
public Category getCategory(String categoryID)
Description copied from interface:CategoryProvider
Returns the provider's category.- Specified by:
getCategory
in interfaceCategoryProvider
- Parameters:
categoryID
- The category id- Returns:
- the provider's category.
-
setTemplate
public void setTemplate(Category category, String templateName)
Description copied from interface:CategoryProvider
Affect a template to category- Specified by:
setTemplate
in interfaceCategoryProvider
- Parameters:
category
- The categorytemplateName
- The template name
-
getAutomaticIds
public Collection<String> getAutomaticIds(String categoryId)
Description copied from interface:CategoryProvider
Get automatic property.- Specified by:
getAutomaticIds
in interfaceCategoryProvider
- Parameters:
categoryId
- The category id.- Returns:
- the list of automatic newsletter IDs.
-
setAutomatic
public void setAutomatic(String categoryId, Collection<String> automaticNewsletterIds)
Description copied from interface:CategoryProvider
Set automatic property.- Specified by:
setAutomatic
in interfaceCategoryProvider
- Parameters:
categoryId
- The category id.automaticNewsletterIds
- The automatic newsletter IDs or empty to set non-automatic.
-
hasCategory
public boolean hasCategory(String categoryID)
Description copied from interface:CategoryProvider
Determines if the category exists.- Specified by:
hasCategory
in interfaceCategoryProvider
- Parameters:
categoryID
- The category id- Returns:
- true if the category exists.
-
getCategories
public List<Category> getCategories(String categoryID)
Description copied from interface:CategoryProvider
Get the sub-categories of a category- Specified by:
getCategories
in interfaceCategoryProvider
- Parameters:
categoryID
- The category id- Returns:
- the sub-categories
-
hasChildren
public boolean hasChildren(String categoryID)
Description copied from interface:CategoryProvider
Determines if the category has sub-categories- Specified by:
hasChildren
in interfaceCategoryProvider
- Parameters:
categoryID
- The category id- Returns:
- true if the category have sub-categories
-
getNewsletters
public AmetysObjectIterable<Content> getNewsletters(String categoryID, String siteName, String lang)
Description copied from interface:CategoryProvider
Get the newsletter contents linked to a category- Specified by:
getNewsletters
in interfaceCategoryProvider
- Parameters:
categoryID
- The category idsiteName
- The site namelang
- The language name- Returns:
- the newsletter contents
-
hasNewsletters
public boolean hasNewsletters(String categoryID, String siteName, String lang)
Description copied from interface:CategoryProvider
Determines if a category has categories linked with- Specified by:
hasNewsletters
in interfaceCategoryProvider
- Parameters:
categoryID
- The category idsiteName
- The site namelang
- The language name- Returns:
- if a category has categories linked with
-
getLabel
public I18nizableText getLabel()
Description copied from interface:CategoryProvider
Returns the provider's label.- Specified by:
getLabel
in interfaceCategoryProvider
- Returns:
- the provider's label.
-
getDescription
public I18nizableText getDescription()
Description copied from interface:CategoryProvider
Returns the provider's description.- Specified by:
getDescription
in interfaceCategoryProvider
- Returns:
- the provider's description.
-
getId
public String getId()
Description copied from interface:CategoryProvider
Returns the provider's id.- Specified by:
getId
in interfaceCategoryProvider
- Returns:
- the provider's id.
-
configureLabel
protected I18nizableText configureLabel(Configuration configuration) throws ConfigurationException
Configure label from the passed configuration- Parameters:
configuration
- The configuration- Returns:
- The label
- Throws:
ConfigurationException
- If an error occurred
-
configureDescription
protected I18nizableText configureDescription(Configuration configuration) throws ConfigurationException
Configure description from the passed configuration- Parameters:
configuration
- The configuration- Returns:
- The description
- Throws:
ConfigurationException
- If an error occurred
-
setPluginInfo
public void setPluginInfo(String pluginName, String featureName, String id)
Description copied from interface:PluginAware
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfo
in interfacePluginAware
- Parameters:
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this component
-
getPluginName
public String getPluginName()
Get the plugin name- Returns:
- the plugin name
-
getRootId
public String getRootId(String siteName, String lang)
Description copied from interface:CategoryProvider
Get the root id- Specified by:
getRootId
in interfaceCategoryProvider
- Parameters:
siteName
- The site namelang
- The language name- Returns:
- the root id
-
_getRootNode
private TraversableAmetysObject _getRootNode(String sitename, String lang) throws RepositoryException
- Throws:
RepositoryException
-
-