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
_contentWorkflowHelper
private Context
_context
private CopyCatalogUpdaterExtensionPoint
_copyUpdaterEP
private ContentTypeExtensionPoint
_cTypeEP
private Catalog
_defaultCatalog
private ObservationManager
_observationManager
private ODFHelper
_odfHelper
private String
_pluginName
private AmetysObjectResolver
_resolver
private SolrIndexer
_solrIndexer
private CurrentUserProvider
_userProvider
static String
ROLE
Avalon 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 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 catalogvoid
deleteCatalog(String id)
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<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 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.(package private) void
updateDefaultCatalog()
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
-
_defaultCatalog
private Catalog _defaultCatalog
-
-
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.
-
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:
AmetysRepositoryException
com.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
-
-