Package org.ametys.odf.catalog
Class CatalogsManager
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.odf.catalog.CatalogsManager
-
- All Implemented Interfaces:
LogEnabled
,PluginAware
,Component
,Contextualizable
,Serviceable
public class CatalogsManager extends AbstractLogEnabled implements Serviceable, Component, PluginAware, Contextualizable
Component to handle ODF catalogs
-
-
Constructor Summary
Constructors Constructor Description CatalogsManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Object>
canEditCatalog(String contentId)
Determines if the catalog can be modified from the given contentvoid
contextualize(Context context)
void
copyCatalog(Catalog catalog, Catalog catalogToCopy)
Copy the programs and its hierarchy from a catalog to another.Catalog
createCatalog(String name, String title)
Create a new catalogMap<String,Object>
deleteCatalog(Catalog catalog)
Delete catalogCatalog
getCatalog(String name)
Get a catalog matching with the given nameList<Catalog>
getCatalogs()
Get the list of catalogsModifiableTraversableAmetysObject
getCatalogsRootNode()
Get the root catalogs storage object.String
getContentCatalog(String contentId)
Get the name of the catalog of a ODF contentprotected int
getCopyActionId()
Get the workflow action id for copy.Catalog
getDefaultCatalog()
Returns the default catalogString
getDefaultCatalogName()
Returns the name of the default catalogAmetysObjectIterable<Content>
getProgramItems(String catalog)
Get the program's items of a catalog for all languagesAmetysObjectIterable<Program>
getPrograms(String catalog)
Get the programs of a catalog for all languagesAmetysObjectIterable<Program>
getPrograms(String catalog, String lang)
Get the programs of a catalogvoid
service(ServiceManager manager)
void
setContentCatalog(String catalog, String contentId)
Set the catalog of a content.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.-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Constructor Detail
-
CatalogsManager
public CatalogsManager()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
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
-
getCatalogs
public List<Catalog> getCatalogs()
Get the list of catalogs- Returns:
- the catalogs
-
getCatalog
public Catalog getCatalog(String name)
Get a catalog matching with the given name- Parameters:
name
- The name- Returns:
- a catalog, or null if not found
-
getDefaultCatalogName
public String getDefaultCatalogName()
Returns the name of the default catalog- Returns:
- the name of the default catalog
-
getDefaultCatalog
public Catalog getDefaultCatalog()
Returns the default catalog- Returns:
- the default catalog or null if no default catalog was defined.
-
getContentCatalog
public String getContentCatalog(String contentId)
Get the name of the catalog of a ODF content- Parameters:
contentId
- The id of content- Returns:
- The catalog's name
-
canEditCatalog
public Map<String,Object> canEditCatalog(String contentId)
Determines if the catalog can be modified from the given content- Parameters:
contentId
- The content id- Returns:
- A map with success=false if the catalog cannot be edited
-
setContentCatalog
public void setContentCatalog(String catalog, String contentId) throws com.opensymphony.workflow.WorkflowException
Set the catalog of a content. This will modify recursively the catalog of referenced children- Parameters:
catalog
- The catalogcontentId
- The id of content to edit- Throws:
com.opensymphony.workflow.WorkflowException
- if an error occurred
-
getCatalogsRootNode
public ModifiableTraversableAmetysObject getCatalogsRootNode() throws AmetysRepositoryException
Get the root catalogs storage object.- Returns:
- the root catalogs node
- Throws:
AmetysRepositoryException
- if a repository error occurs.
-
createCatalog
public Catalog createCatalog(String name, String title)
Create a new catalog- Parameters:
name
- The unique nametitle
- The title of catalog- Returns:
- the created catalog
-
getPrograms
public AmetysObjectIterable<Program> getPrograms(String catalog)
Get the programs of a catalog for all languages- Parameters:
catalog
- The code of catalog- Returns:
- The programs
-
getProgramItems
public AmetysObjectIterable<Content> getProgramItems(String catalog)
Get the program's items of a catalog for all languages- Parameters:
catalog
- The code of catalog- Returns:
- The
ProgramItem
-
getPrograms
public AmetysObjectIterable<Program> getPrograms(String catalog, String lang)
Get the programs of a catalog- Parameters:
catalog
- The code of cataloglang
- The language. Can be null to get programs for all languages- Returns:
- The programs
-
copyCatalog
public void copyCatalog(Catalog catalog, Catalog catalogToCopy) throws ProcessingException
Copy the programs and its hierarchy from a catalog to another. The referenced courses are NOT copied.- Parameters:
catalog
- The new catalog to populatecatalogToCopy
- The catalog from which we copy the programs.- Throws:
ProcessingException
- If an error occurred during copy
-
getCopyActionId
protected int getCopyActionId()
Get the workflow action id for copy.- Returns:
- The workflow action id
-
deleteCatalog
public Map<String,Object> deleteCatalog(Catalog catalog)
Delete catalog- Parameters:
catalog
- the catalog to delete- Returns:
- the result map
-
-