Class ThreadDAO
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.plugins.explorer.threads.actions.ThreadDAO
-
- All Implemented Interfaces:
Component,LogEnabled,Serviceable
- Direct Known Subclasses:
WorkspaceThreadDAO
public class ThreadDAO extends AbstractLogEnabled implements Serviceable, Component
Thread DAO
-
-
Field Summary
Fields Modifier and Type Field Description static String__RIGHTS_POST_ADDRight to add a poststatic String__RIGHTS_POST_DELETERight to delete a poststatic String__RIGHTS_POST_EDITRight to edit a poststatic String__RIGHTS_THREAD_ADDRight to add a threadstatic String__RIGHTS_THREAD_DELETERight to delete a threadstatic String__RIGHTS_THREAD_EDITRight to edit a threadprotected CurrentUserProvider_currentUserProviderThe current user provider.protected ExplorerResourcesDAO_explorerResourcesDAOExplorer resources DAOprotected ServiceManager_managerAvalon service managerprotected ObservationManager_observationManagerObserver manager.protected AmetysObjectResolver_resolverAmetys resolverprotected RightManager_rightManagerThe rights managerprotected UserHelper_userHelperThe user helperprotected UserManager_userManagerUser managerstatic StringROLEAvalon Role
-
Constructor Summary
Constructors Constructor Description ThreadDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String_formatAuthor(UserIdentity userIdentity)Return the author of a thread in a formatted version ready to be displayed to the end user.protected Map<String,Object>_getPostDataFullInfo(JCRPost post)Retrieves the post additional info (rights, parent id, etc...)protected Set<String>_getUserRights(ExplorerNode node)Get the user rights on the resource collectionMap<String,Object>addPost(String threadId, String inputContent)Add a postMap<String,Object>addThread(String id, String inputName, String inputDescription)Add a threadprotected booleancanDelete(JCRPost post)Determines if the post can be deleted by current userprotected booleancanEdit(JCRPost post)Determines if the post can be edited by current userStringconvertPostToString(JCRPost post)Convert the content of a post to a string (removing HTML tags)Map<String,Object>deletePost(String id)Delete a postMap<String,Object>deleteThread(String id)Delete a threadMap<String,Object>editPost(String id, String inputContent)Edit a postMap<String,Object>editThread(String id, String inputName, String inputDescription)Edit a threadprotected StringgetPostContent(JCRPost post)Get the content of a post as a Stringprotected StringgetPostContentForEditing(JCRPost post)Get the content of a post to edit as a StringMap<String,Object>getPostData(JCRPost post, boolean fullInfo, boolean isEdition)Get post infoMap<String,Object>getPostDataById(String id, boolean fullInfo, boolean isEdition)Get post infoList<Map<String,Object>>getPostsData(List<JCRPost> posts, boolean fullInfo, boolean isEdition)Get post infoList<Map<String,Object>>getPostsDataByIds(List<String> ids, boolean fullInfo, boolean isEdition)Get post infoMap<String,Object>getThreadData(String id, boolean includeChildren)Get thread infoMap<String,Object>getThreadData(JCRThread thread, boolean includeChildren)Get thread infoMap<String,Object>markAsRead(String id)Mark a thread as read by the current userMap<String,Object>renameThread(String id, String name)Rename a threadvoidservice(ServiceManager manager)protected voidsetPostContent(JCRPost post, String content)Update the content of a post-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
__RIGHTS_THREAD_ADD
public static final String __RIGHTS_THREAD_ADD
Right to add a thread- See Also:
- Constant Field Values
-
__RIGHTS_THREAD_EDIT
public static final String __RIGHTS_THREAD_EDIT
Right to edit a thread- See Also:
- Constant Field Values
-
__RIGHTS_THREAD_DELETE
public static final String __RIGHTS_THREAD_DELETE
Right to delete a thread- See Also:
- Constant Field Values
-
__RIGHTS_POST_ADD
public static final String __RIGHTS_POST_ADD
Right to add a post- See Also:
- Constant Field Values
-
__RIGHTS_POST_EDIT
public static final String __RIGHTS_POST_EDIT
Right to edit a post- See Also:
- Constant Field Values
-
__RIGHTS_POST_DELETE
public static final String __RIGHTS_POST_DELETE
Right to delete a post- See Also:
- Constant Field Values
-
_explorerResourcesDAO
protected ExplorerResourcesDAO _explorerResourcesDAO
Explorer resources DAO
-
_resolver
protected AmetysObjectResolver _resolver
Ametys resolver
-
_observationManager
protected ObservationManager _observationManager
Observer manager.
-
_currentUserProvider
protected CurrentUserProvider _currentUserProvider
The current user provider.
-
_userManager
protected UserManager _userManager
User manager
-
_rightManager
protected RightManager _rightManager
The rights manager
-
_userHelper
protected UserHelper _userHelper
The user helper
-
_manager
protected ServiceManager _manager
Avalon service manager
-
-
Constructor Detail
-
ThreadDAO
public ThreadDAO()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
getThreadData
public Map<String,Object> getThreadData(String id, boolean includeChildren)
Get thread info- Parameters:
id- The thread idincludeChildren- True to also include children- Returns:
- the thread data in a map
-
getThreadData
public Map<String,Object> getThreadData(JCRThread thread, boolean includeChildren)
Get thread info- Parameters:
thread- The threadincludeChildren- True to also include children- Returns:
- the thread data in a map
-
_formatAuthor
protected String _formatAuthor(UserIdentity userIdentity)
Return the author of a thread in a formatted version ready to be displayed to the end user.- Parameters:
userIdentity- The author- Returns:
- The formatted string
-
getPostsDataByIds
public List<Map<String,Object>> getPostsDataByIds(List<String> ids, boolean fullInfo, boolean isEdition)
Get post info- Parameters:
ids- The post idsfullInfo- true to include full info (rights, parent id, etc...)isEdition- true to get the content in edit mode- Returns:
- the list of post data
-
getPostsData
public List<Map<String,Object>> getPostsData(List<JCRPost> posts, boolean fullInfo, boolean isEdition)
Get post info- Parameters:
posts- The postsfullInfo- true to include full info (rights, parent id, etc...)isEdition- true to get the content in edit mode- Returns:
- the list of post data
-
getPostDataById
public Map<String,Object> getPostDataById(String id, boolean fullInfo, boolean isEdition)
Get post info- Parameters:
id- The post idfullInfo- true to include full info (rights, parent id, etc...)isEdition- true to get the content in edit mode- Returns:
- the post data in a map
-
getPostData
public Map<String,Object> getPostData(JCRPost post, boolean fullInfo, boolean isEdition)
Get post info- Parameters:
post- The postfullInfo- true to include full info (rights, parent id, etc...)isEdition- true to get the content in edit mode- Returns:
- the post data in a map
-
canEdit
protected boolean canEdit(JCRPost post)
Determines if the post can be edited by current user- Parameters:
post- The post- Returns:
- true if the post can be edited
-
canDelete
protected boolean canDelete(JCRPost post)
Determines if the post can be deleted by current user- Parameters:
post- The post- Returns:
- true if the post can be deleted
-
convertPostToString
public String convertPostToString(JCRPost post)
Convert the content of a post to a string (removing HTML tags)- Parameters:
post- The post- Returns:
- the content of the post as string.
-
_getPostDataFullInfo
protected Map<String,Object> _getPostDataFullInfo(JCRPost post)
Retrieves the post additional info (rights, parent id, etc...)- Parameters:
post- The post- Returns:
- the post additional info (rights, parent id, etc...) in a map
-
_getUserRights
protected Set<String> _getUserRights(ExplorerNode node)
Get the user rights on the resource collection- Parameters:
node- The explorer node- Returns:
- The user's rights
-
addThread
public Map<String,Object> addThread(String id, String inputName, String inputDescription) throws IllegalAccessException
Add a thread- Parameters:
id- The identifier of the parent in which the thread will be addedinputName- The desired name for the threadinputDescription- The thread description- Returns:
- The result map with id, parentId and name keys
- Throws:
IllegalAccessException- If the user has no sufficient rights
-
editThread
public Map<String,Object> editThread(String id, String inputName, String inputDescription) throws IllegalAccessException
Edit a thread- Parameters:
id- The identifier of the threadinputName- The new nameinputDescription- The new description- Returns:
- The result map with id and name keys
- Throws:
IllegalAccessException- If the user has no sufficient rights
-
renameThread
public Map<String,Object> renameThread(String id, String name) throws IllegalAccessException
Rename a thread- Parameters:
id- The id of the threadname- The thread name- Returns:
- The result map with id, name and message keys
- Throws:
IllegalAccessException- If the user has no sufficient rights
-
deleteThread
public Map<String,Object> deleteThread(String id) throws IllegalAccessException
Delete a thread- Parameters:
id- The id of the thread- Returns:
- The result map with id, parent id and message keys
- Throws:
IllegalAccessException- If the user has no sufficient rights
-
addPost
public Map<String,Object> addPost(String threadId, String inputContent) throws IllegalAccessException, IOException
Add a post- Parameters:
threadId- The identifier of the thread in which the post will be addedinputContent- The post content- Returns:
- The result map with id, parentId and message keys
- Throws:
IllegalAccessException- If the user has no sufficient rightsIOException- If an error occurs
-
setPostContent
protected void setPostContent(JCRPost post, String content)
Update the content of a post- Parameters:
post- The post to updatecontent- The content as string
-
getPostContent
protected String getPostContent(JCRPost post) throws AmetysRepositoryException
Get the content of a post as a String- Parameters:
post- the post- Returns:
- The content as String
- Throws:
AmetysRepositoryException- if failed to parse content
-
getPostContentForEditing
protected String getPostContentForEditing(JCRPost post) throws AmetysRepositoryException
Get the content of a post to edit as a String- Parameters:
post- the post- Returns:
- The content as String
- Throws:
AmetysRepositoryException- if failed to parse content
-
editPost
public Map<String,Object> editPost(String id, String inputContent) throws IllegalAccessException, IOException
Edit a post- Parameters:
id- The identifier of the postinputContent- The post content- Returns:
- The result map with id, parentId and message keys
- Throws:
IllegalAccessException- If the user has no sufficient rightsIOException- If an error occurs
-
deletePost
public Map<String,Object> deletePost(String id) throws IllegalAccessException
Delete a post- Parameters:
id- The id of the post- Returns:
- The result map with id, parent id and message keys
- Throws:
IllegalAccessException- If the user has no sufficient rights
-
markAsRead
public Map<String,Object> markAsRead(String id)
Mark a thread as read by the current user- Parameters:
id- The thread id- Returns:
- The result map with id, parent id and message keys
-
-