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
Modifier and TypeFieldDescriptionprotected CurrentUserProvider
The current user providerprotected ObservationManager
Observer manager.protected AmetysObjectResolver
The ametys object resolver -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
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>>
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
Update a JCR tagaddTag
(String parentId, String originalName, String title, String description, Map<String, Object> otherParameters, Map<String, Object> contextualParameters) Create a new tag regardless of user rights.createTag
(String parentId, String originalName, String title, String description, Map<String, Object> otherParameters, Map<String, Object> contextualParameters) Create a new tag from client-side.Deletes a JCR tagFind a JCR tag and return its datagetTagRootNode
(String tagProviderId, Map<String, Object> contextualParameters) Get the root node for tagsMove a JCR tagvoid
service
(ServiceManager manager) Updates a JCR tagMethods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
_resolver
The ametys object resolver -
_observationManager
Observer manager. -
_currentUserProvider
The current user provider
-
-
Constructor Details
-
AbstractJCRTagsDAO
public AbstractJCRTagsDAO()
-
-
Method Details
-
service
- 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, throws UnknownAmetysObjectException, javax.jcr.RepositoryExceptionObject> contextualParameters) 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 existjavax.jcr.RepositoryException
- if failed to create tag
-
deleteTag
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
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 ProcessingExceptionGet 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
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 javax.jcr.RepositoryExceptionGet the tag root node object- Parameters:
tagProviderId
- The tag provider idcontextualParameters
- Contextual parameters transmitted by the environment.- Returns:
- The tag root node object
- Throws:
javax.jcr.RepositoryException
- If an error occurred in the repository
-
_checkUserRight
Check if the user right to access the feature- Throws:
IllegalStateException
- if the user has no right
-
_getTagFromName
Get the tag from the name- Parameters:
name
- the namecontextualParameters
- the contextual parameters- Returns:
- the 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, throws javax.jcr.RepositoryExceptionObject> contextualParameters) 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:
javax.jcr.RepositoryException
- if an error occurred
-
_updateJCRTag
protected abstract JCRTag _updateJCRTag(String tagId, String title, String description, Map<String, Object> otherParameters) throws UnknownAmetysObjectExceptionUpdate 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
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
-