Class ThreadDAO
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.plugins.explorer.threads.actions.ThreadDAO
- All Implemented Interfaces:
Component,LogEnabled,Serviceable
Thread DAO
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringRight to add a poststatic final StringRight to delete a poststatic final StringRight to edit a poststatic final StringRight to add a threadstatic final StringRight to delete a threadstatic final StringRight to edit a threadprotected CurrentUserProviderThe current user provider.protected ExplorerResourcesDAOExplorer resources DAOprotected ServiceManagerAvalon service managerprotected ObservationManagerObserver manager.protected AmetysObjectResolverAmetys resolverprotected RightManagerThe rights managerprotected UserHelperThe user helperprotected UserManagerUser managerstatic final StringAvalon Role -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String_formatAuthor(UserIdentity userIdentity) Return the author of a thread in a formatted version ready to be displayed to the end user._getPostDataFullInfo(JCRPost post) Retrieves the post additional info (rights, parent id, etc...)_getUserRights(ExplorerNode node) Get the user rights on the resource collectionAdd a postAdd a threadprotected booleanDetermines if the post can be deleted by current userprotected booleanDetermines if the post can be edited by current userconvertPostToString(JCRPost post) Convert the content of a post to a string (removing HTML tags)deletePost(String id) Delete a postdeleteThread(String id) Delete a threadEdit a posteditThread(String id, String inputName, String inputDescription) Edit a threadprotected StringgetPostContent(JCRPost post) Get the content of a post as a Stringprotected StringGet the content of a post to edit as a StringgetPostData(JCRPost post, boolean fullInfo, boolean isEdition) Get post infogetPostDataById(String id, boolean fullInfo, boolean isEdition) Get post infogetPostsData(List<JCRPost> posts, boolean fullInfo, boolean isEdition) Get post infogetPostsDataByIds(List<String> ids, boolean fullInfo, boolean isEdition) Get post infogetThreadData(String id, boolean includeChildren) Get thread infogetThreadData(JCRThread thread, boolean includeChildren) Get thread infomarkAsRead(String id) Mark a thread as read by the current userrenameThread(String id, String name) Rename a threadvoidservice(ServiceManager manager) protected voidsetPostContent(JCRPost post, String content) Update the content of a postMethods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
ROLE
Avalon Role -
__RIGHTS_THREAD_ADD
Right to add a thread- See Also:
-
__RIGHTS_THREAD_EDIT
Right to edit a thread- See Also:
-
__RIGHTS_THREAD_DELETE
Right to delete a thread- See Also:
-
__RIGHTS_POST_ADD
Right to add a post- See Also:
-
__RIGHTS_POST_EDIT
Right to edit a post- See Also:
-
__RIGHTS_POST_DELETE
Right to delete a post- See Also:
-
_explorerResourcesDAO
Explorer resources DAO -
_resolver
Ametys resolver -
_observationManager
Observer manager. -
_currentUserProvider
The current user provider. -
_userManager
User manager -
_rightManager
The rights manager -
_userHelper
The user helper -
_manager
Avalon service manager
-
-
Constructor Details
-
ThreadDAO
public ThreadDAO()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
getThreadData
Get thread info- Parameters:
id- The thread idincludeChildren- True to also include children- Returns:
- the thread data in a map
-
getThreadData
Get thread info- Parameters:
thread- The threadincludeChildren- True to also include children- Returns:
- the thread data in a map
-
_formatAuthor
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
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
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
Determines if the post can be edited by current user- Parameters:
post- The post- Returns:
- true if the post can be edited
-
canDelete
Determines if the post can be deleted by current user- Parameters:
post- The post- Returns:
- true if the post can be deleted
-
convertPostToString
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
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
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
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
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
Update the content of a post- Parameters:
post- The post to updatecontent- The content as string
-
getPostContent
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
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
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
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
-