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
-
-
Field Summary
Fields Modifier and Type Field Description private ContentWorkflowHelper_contentWorkflowHelperprivate Context_contextprivate CopyCatalogUpdaterExtensionPoint_copyUpdaterEPprivate ContentTypeExtensionPoint_cTypeEPprivate String_defaultCatalogIdprivate ObservationManager_observationManagerprivate ODFHelper_odfHelperprivate String_pluginNameprivate AmetysObjectResolver_resolverprivate SolrIndexer_solrIndexerprivate CurrentUserProvider_userProviderstatic StringROLEAvalon Role
-
Constructor Summary
Constructors Constructor Description CatalogsManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void_addCopyStep(Collection<String> contentIds)private void_applyChanges(WorkflowAwareContent content)private ModifiableTraversableAmetysObject_getOrCreateNode(ModifiableTraversableAmetysObject parentNode, String nodeName, String nodeType)private boolean_hasSharedContent(ProgramItem rootProgramItem, ProgramItem programItem)private boolean_isPartOfSameStructure(ProgramItem rootProgramItem, List<ProgramItem> programItems)private boolean_isReferenced(Content content)private boolean_isShared(ProgramItem rootProgramItem, ProgramItem programItem)private void_setCatalog(Content content, String catalogName)private void_setCatalogToChildren(Content content, String catalogName)Map<String,Object>canEditCatalog(String contentId)Determines if the catalog can be modified from the given contentvoidcontextualize(Context context)voidcopyCatalog(Catalog catalog, Catalog catalogToCopy)Copy the programs and its hierarchy from a catalog to another.CatalogcreateCatalog(String name, String title)Create a new catalogvoiddeleteCatalog(String id)Delete catalogCataloggetCatalog(String name)Get a catalog matching with the given nameList<Catalog>getCatalogs()Get the list of catalogsModifiableTraversableAmetysObjectgetCatalogsRootNode()Get the root catalogs storage object.StringgetContentCatalog(String contentId)Get the name of the catalog of a ODF contentprotected intgetCopyActionId()Get the workflow action id for copy.CataloggetDefaultCatalog()Returns the default catalogStringgetDefaultCatalogName()Returns the name of the default catalogAmetysObjectIterable<ProgramItem>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 catalogvoidservice(ServiceManager manager)voidsetContentCatalog(String catalog, String contentId)Set the catalog of a content.voidsetPluginInfo(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.(package private) voidupdateDefaultCatalog()Updates the default catalog (if it's null or if the user has updated it).-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_resolver
private AmetysObjectResolver _resolver
-
_copyUpdaterEP
private CopyCatalogUpdaterExtensionPoint _copyUpdaterEP
-
_observationManager
private ObservationManager _observationManager
-
_userProvider
private CurrentUserProvider _userProvider
-
_contentWorkflowHelper
private ContentWorkflowHelper _contentWorkflowHelper
-
_pluginName
private String _pluginName
-
_odfHelper
private ODFHelper _odfHelper
-
_cTypeEP
private ContentTypeExtensionPoint _cTypeEP
-
_solrIndexer
private SolrIndexer _solrIndexer
-
_defaultCatalogId
private String _defaultCatalogId
-
-
Constructor Detail
-
CatalogsManager
public CatalogsManager()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
setPluginInfo
public void setPluginInfo(String pluginName, String featureName, String id)
Description copied from interface:PluginAwareSets 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:
setPluginInfoin 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.
-
updateDefaultCatalog
void updateDefaultCatalog()
Updates the default catalog (if it's null or if the user has updated it).
-
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
-
_isReferenced
private boolean _isReferenced(Content content)
-
_hasSharedContent
private boolean _hasSharedContent(ProgramItem rootProgramItem, ProgramItem programItem)
-
_isShared
private boolean _isShared(ProgramItem rootProgramItem, ProgramItem programItem)
-
_isPartOfSameStructure
private boolean _isPartOfSameStructure(ProgramItem rootProgramItem, List<ProgramItem> programItems)
-
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
-
_setCatalog
private void _setCatalog(Content content, String catalogName) throws com.opensymphony.workflow.WorkflowException
- Throws:
com.opensymphony.workflow.WorkflowException
-
_setCatalogToChildren
private void _setCatalogToChildren(Content content, String catalogName) throws com.opensymphony.workflow.WorkflowException
- Throws:
com.opensymphony.workflow.WorkflowException
-
_applyChanges
private void _applyChanges(WorkflowAwareContent content) throws com.opensymphony.workflow.WorkflowException
- Throws:
com.opensymphony.workflow.WorkflowException
-
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<ProgramItem> 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
-
_addCopyStep
private void _addCopyStep(Collection<String> contentIds) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
- Throws:
AmetysRepositoryExceptioncom.opensymphony.workflow.WorkflowException
-
getCopyActionId
protected int getCopyActionId()
Get the workflow action id for copy.- Returns:
- The workflow action id
-
deleteCatalog
public void deleteCatalog(String id)
Delete catalog- Parameters:
id- the id of catalog
-
_getOrCreateNode
private ModifiableTraversableAmetysObject _getOrCreateNode(ModifiableTraversableAmetysObject parentNode, String nodeName, String nodeType) throws AmetysRepositoryException
- Throws:
AmetysRepositoryException
-
-