public class ThreadDAO extends AbstractLogEnabled implements Serviceable, Component
Modifier and Type | Field and Description |
---|---|
static String |
__RIGHTS_POST_ADD
Right to add a post
|
static String |
__RIGHTS_POST_DELETE
Right to delete a post
|
static String |
__RIGHTS_POST_EDIT
Right to edit a post
|
static String |
__RIGHTS_THREAD_ADD
Right to add a thread
|
static String |
__RIGHTS_THREAD_DELETE
Right to delete a thread
|
static String |
__RIGHTS_THREAD_EDIT
Right to edit a thread
|
protected CurrentUserProvider |
_currentUserProvider
The current user provider.
|
protected ExplorerResourcesDAO |
_explorerResourcesDAO
Explorer resources DAO
|
protected ObservationManager |
_observationManager
Observer manager.
|
private SAXParser |
_parser |
protected AmetysObjectResolver |
_resolver
Ametys resolver
|
protected RightManager |
_rightManager
The rights manager
|
protected UserHelper |
_userHelper
The user helper
|
protected UserManager |
_userManager
User manager
|
static String |
ROLE
Avalon Role
|
Constructor and Description |
---|
ThreadDAO() |
Modifier and Type | Method and 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 collection
|
Map<String,Object> |
addPost(String threadId,
String inputContent)
Add a post
|
Map<String,Object> |
addThread(String id,
String inputName,
String inputDescription)
Add a thread
|
protected boolean |
canDelete(JCRPost post)
Determines if the post can be deleted by current user
|
protected boolean |
canEdit(JCRPost post)
Determines if the post can be edited by current user
|
String |
convertPostToString(JCRPost post)
Convert the content of a post to a string (removing HTML tags)
|
Map<String,Object> |
deletePost(String id)
Delete a post
|
Map<String,Object> |
deleteThread(String id)
Delete a thread
|
Map<String,Object> |
editPost(String id,
String inputContent)
Edit a post
|
Map<String,Object> |
editThread(String id,
String inputName,
String inputDescription)
Edit a thread
|
protected String |
getPostContent(JCRPost post)
Get the content of a post as a String
|
protected String |
getPostContentForEditing(JCRPost post)
Get the content of a post to edit as a String
|
Map<String,Object> |
getPostData(JCRPost post,
boolean fullInfo,
boolean isEdition)
Get post info
|
Map<String,Object> |
getPostDataById(String id,
boolean fullInfo,
boolean isEdition)
Get post info
|
List<Map<String,Object>> |
getPostsData(List<JCRPost> posts,
boolean fullInfo,
boolean isEdition)
Get post info
|
List<Map<String,Object>> |
getPostsDataByIds(List<String> ids,
boolean fullInfo,
boolean isEdition)
Get post info
|
Map<String,Object> |
getThreadData(JCRThread thread,
boolean includeChildren)
Get thread info
|
Map<String,Object> |
getThreadData(String id,
boolean includeChildren)
Get thread info
|
Map<String,Object> |
markAsRead(String id)
Mark a thread as read by the current user
|
Map<String,Object> |
renameThread(String id,
String name)
Rename a thread
|
void |
service(ServiceManager manager) |
protected void |
setPostContent(JCRPost post,
String content)
Update the content of a post
|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
public static final String __RIGHTS_THREAD_ADD
public static final String __RIGHTS_THREAD_EDIT
public static final String __RIGHTS_THREAD_DELETE
public static final String __RIGHTS_POST_ADD
public static final String __RIGHTS_POST_EDIT
public static final String __RIGHTS_POST_DELETE
protected ExplorerResourcesDAO _explorerResourcesDAO
protected AmetysObjectResolver _resolver
protected ObservationManager _observationManager
protected CurrentUserProvider _currentUserProvider
protected UserManager _userManager
protected RightManager _rightManager
protected UserHelper _userHelper
public ThreadDAO()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public Map<String,Object> getThreadData(String id, boolean includeChildren)
id
- The thread idincludeChildren
- True to also include childrenpublic Map<String,Object> getThreadData(JCRThread thread, boolean includeChildren)
thread
- The threadincludeChildren
- True to also include childrenprotected String _formatAuthor(UserIdentity userIdentity)
userIdentity
- The authorpublic List<Map<String,Object>> getPostsDataByIds(List<String> ids, boolean fullInfo, boolean isEdition)
ids
- The post idsfullInfo
- true to include full info (rights, parent id, etc...)isEdition
- true to get the content in edit modepublic List<Map<String,Object>> getPostsData(List<JCRPost> posts, boolean fullInfo, boolean isEdition)
posts
- The postsfullInfo
- true to include full info (rights, parent id, etc...)isEdition
- true to get the content in edit modepublic Map<String,Object> getPostDataById(String id, boolean fullInfo, boolean isEdition)
id
- The post idfullInfo
- true to include full info (rights, parent id, etc...)isEdition
- true to get the content in edit modepublic Map<String,Object> getPostData(JCRPost post, boolean fullInfo, boolean isEdition)
post
- The postfullInfo
- true to include full info (rights, parent id, etc...)isEdition
- true to get the content in edit modeprotected boolean canEdit(JCRPost post)
post
- The postprotected boolean canDelete(JCRPost post)
post
- The postpublic String convertPostToString(JCRPost post)
post
- The postprotected Map<String,Object> _getPostDataFullInfo(JCRPost post)
post
- The postprotected Set<String> _getUserRights(ExplorerNode node)
node
- The explorer nodepublic Map<String,Object> addThread(String id, String inputName, String inputDescription) throws IllegalAccessException
id
- The identifier of the parent in which the thread will be addedinputName
- The desired name for the threadinputDescription
- The thread descriptionIllegalAccessException
- If the user has no sufficient rightspublic Map<String,Object> editThread(String id, String inputName, String inputDescription) throws IllegalAccessException
id
- The identifier of the threadinputName
- The new nameinputDescription
- The new descriptionIllegalAccessException
- If the user has no sufficient rightspublic Map<String,Object> renameThread(String id, String name) throws IllegalAccessException
id
- The id of the threadname
- The thread nameIllegalAccessException
- If the user has no sufficient rightspublic Map<String,Object> deleteThread(String id) throws IllegalAccessException
id
- The id of the threadIllegalAccessException
- If the user has no sufficient rightspublic Map<String,Object> addPost(String threadId, String inputContent) throws IllegalAccessException, IOException
threadId
- The identifier of the thread in which the post will be addedinputContent
- The post contentIllegalAccessException
- If the user has no sufficient rightsIOException
- If an error occursprotected void setPostContent(JCRPost post, String content)
post
- The post to updatecontent
- The content as stringprotected String getPostContent(JCRPost post) throws AmetysRepositoryException
post
- the postAmetysRepositoryException
- if failed to parse contentprotected String getPostContentForEditing(JCRPost post) throws AmetysRepositoryException
post
- the postAmetysRepositoryException
- if failed to parse contentpublic Map<String,Object> editPost(String id, String inputContent) throws IllegalAccessException, IOException
id
- The identifier of the postinputContent
- The post contentIllegalAccessException
- If the user has no sufficient rightsIOException
- If an error occurspublic Map<String,Object> deletePost(String id) throws IllegalAccessException
id
- The id of the postIllegalAccessException
- If the user has no sufficient rightspublic Map<String,Object> markAsRead(String id)
id
- The thread id