Package org.ametys.cms.tag.jcr
Class AbstractJCRTagsDAO
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.cms.tag.jcr.AbstractJCRTagsDAO
-
- All Implemented Interfaces:
Component
,LogEnabled
,Serviceable
- Direct Known Subclasses:
CategoryJCRDAO
,JCRTagsDAO
,JCRThemesDAO
,KeywordJCRDAO
,ProjectJCRTagsDAO
public abstract class AbstractJCRTagsDAO extends AbstractLogEnabled implements Serviceable, Component
Component for operations on JCR tags
-
-
Field Summary
Fields Modifier and Type Field Description protected CurrentUserProvider
_currentUserProvider
The current user providerprotected ObservationManager
_observationManager
Observer manager.protected AmetysObjectResolver
_resolver
The ametys object resolver
-
Constructor Summary
Constructors Constructor Description AbstractJCRTagsDAO()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
_checkUserRight()
Check if the user right to access the featureprotected abstract JCRTag
_createJCRTag(String parentId, String name, String title, String description, Map<String,Object> otherParameters, Map<String,Object> contextualParameters)
Create a JCR tag under his parentprotected String
_findUniqueName(String originalName, Map<String,Object> contextualParameters)
Find a unique name for the tagprotected abstract Tag
_getTagFromName(String name, Map<String,Object> contextualParameters)
Get the tag from the nameprotected abstract Set<TagProvider<? extends Tag>>
_getTagProviders()
Get all tag's providersabstract ModifiableTraversableAmetysObject
_getTagRootObject(String tagProviderId, Map<String,Object> contextualParameters)
Get the tag root node objectprotected boolean
_hasTag(Set<TagProvider<? extends Tag>> providers, String name, Map<String,Object> contextualParameters)
Determines if a tag with given name already existsprotected abstract JCRTag
_updateJCRTag(String tagId, String title, String description, Map<String,Object> otherParameters)
Update a JCR tagJCRTag
addTag(String parentId, String originalName, String title, String description, Map<String,Object> otherParameters, Map<String,Object> contextualParameters)
Create a new tag regardless of user rights.Map<String,Object>
createTag(String parentId, String originalName, String title, String description, Map<String,Object> otherParameters, Map<String,Object> contextualParameters)
Create a new tag from client-side.Map<String,Object>
deleteTag(String tagId, Map<String,Object> contextualParameters)
Deletes a JCR tagMap<String,Object>
getTag(String tagId)
Find a JCR tag and return its dataMap<String,Object>
getTagRootNode(String tagProviderId, Map<String,Object> contextualParameters)
Get the root node for tagsMap<String,Object>
moveTags(String targetId, List<String> ids)
Move a JCR tagvoid
service(ServiceManager manager)
Map<String,Object>
updateTag(String tagId, String title, String description, Map<String,Object> otherParameters)
Updates a JCR tag-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
_resolver
protected AmetysObjectResolver _resolver
The ametys object resolver
-
_observationManager
protected ObservationManager _observationManager
Observer manager.
-
_currentUserProvider
protected CurrentUserProvider _currentUserProvider
The current user provider
-
-
Constructor Detail
-
AbstractJCRTagsDAO
public AbstractJCRTagsDAO()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
createTag
public Map<String,Object> createTag(String parentId, String originalName, String title, String description, Map<String,Object> otherParameters, Map<String,Object> contextualParameters)
Create a new tag from client-side. User rights are checked.- Parameters:
parentId
- The id of parent tagoriginalName
- The original nametitle
- The tag's titledescription
- The tag's descriptionotherParameters
- the other parameterscontextualParameters
- Contextual parameters transmitted by the environment.- Returns:
- The result map
-
addTag
public JCRTag addTag(String parentId, String originalName, String title, String description, Map<String,Object> otherParameters, Map<String,Object> contextualParameters) throws UnknownAmetysObjectException, RepositoryException
Create a new tag regardless of user rights.- Parameters:
parentId
- The id of parent tagoriginalName
- The original nametitle
- The tag's titledescription
- The tag's descriptionotherParameters
- the other parameterscontextualParameters
- Contextual parameters transmitted by the environment.- Returns:
- The created JCR tag
- Throws:
UnknownAmetysObjectException
- if the parent does not existRepositoryException
- if failed to create tag
-
deleteTag
public Map<String,Object> deleteTag(String tagId, Map<String,Object> contextualParameters)
Deletes a JCR tag- Parameters:
tagId
- The tag's idcontextualParameters
- Contextual parameters transmitted by the environment.- Returns:
- the result map
-
updateTag
public Map<String,Object> updateTag(String tagId, String title, String description, Map<String,Object> otherParameters)
Updates a JCR tag- Parameters:
tagId
- The tag's idtitle
- The tag's titledescription
- The tag's descriptionotherParameters
- the other parameters- Returns:
- The result map
-
moveTags
public Map<String,Object> moveTags(String targetId, List<String> ids) throws ProcessingException
Move a JCR tag- Parameters:
targetId
- The tag where to move toids
- The ids of tag to move- Returns:
- the result map
- Throws:
ProcessingException
- If an error occurred
-
getTagRootNode
public Map<String,Object> getTagRootNode(String tagProviderId, Map<String,Object> contextualParameters) throws ProcessingException
Get the root node for tags- Parameters:
tagProviderId
- The tag provider idcontextualParameters
- Contextual parameters transmitted by the environment.- Returns:
- The root node in key "id"
- Throws:
ProcessingException
- If an error occurred in the repository
-
getTag
public Map<String,Object> getTag(String tagId)
Find a JCR tag and return its data- Parameters:
tagId
- The tag's id- Returns:
- The result map
-
_getTagRootObject
public abstract ModifiableTraversableAmetysObject _getTagRootObject(String tagProviderId, Map<String,Object> contextualParameters) throws RepositoryException
Get the tag root node object- Parameters:
tagProviderId
- The tag provider idcontextualParameters
- Contextual parameters transmitted by the environment.- Returns:
- The tag root node object
- Throws:
RepositoryException
- If an error occurred in the repository
-
_checkUserRight
protected abstract void _checkUserRight() throws IllegalStateException
Check if the user right to access the feature- Throws:
IllegalStateException
- if the user has no right
-
_getTagFromName
protected abstract Tag _getTagFromName(String name, Map<String,Object> contextualParameters)
Get the tag from the name- Parameters:
name
- the namecontextualParameters
- the contextual parameters- Returns:
- the tag
-
_getTagProviders
protected abstract Set<TagProvider<? extends Tag>> _getTagProviders()
Get all tag's providers- Returns:
- the providers
-
_createJCRTag
protected abstract JCRTag _createJCRTag(String parentId, String name, String title, String description, Map<String,Object> otherParameters, Map<String,Object> contextualParameters) throws RepositoryException
Create a JCR tag under his parent- Parameters:
parentId
- the parent idname
- the nametitle
- the titledescription
- the descriptionotherParameters
- the other parameterscontextualParameters
- Contextual parameters transmitted by the environment.- Returns:
- the created JCR tag
- Throws:
RepositoryException
- if an error occurred
-
_updateJCRTag
protected abstract JCRTag _updateJCRTag(String tagId, String title, String description, Map<String,Object> otherParameters) throws UnknownAmetysObjectException
Update a JCR tag- Parameters:
tagId
- the tag id to updatetitle
- the titledescription
- the descriptionotherParameters
- the other parameters- Returns:
- return the updated JCR tag
- Throws:
UnknownAmetysObjectException
- if an error occurred
-
_findUniqueName
protected String _findUniqueName(String originalName, Map<String,Object> contextualParameters)
Find a unique name for the tag- Parameters:
originalName
- The requested namecontextualParameters
- Contextual parameters transmitted by the environment.- Returns:
- A unique name
-
_hasTag
protected boolean _hasTag(Set<TagProvider<? extends Tag>> providers, String name, Map<String,Object> contextualParameters)
Determines if a tag with given name already exists- Parameters:
providers
- The tag providersname
- The name of the tagcontextualParameters
- Contextual parameters transmitted by the environment.- Returns:
- true if the tag exists
-
-