Class CommentClientSideElement
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.ui.StaticFileImportsClientSideElement
-
- org.ametys.core.ui.StaticClientSideElement
-
- org.ametys.cms.repository.comment.ui.CommentClientSideElement
-
- All Implemented Interfaces:
ClientSideElement
,LogEnabled
,PluginAware
,Configurable
,Serviceable
public class CommentClientSideElement extends StaticClientSideElement
This client site elements creates a button representing the validation state of a content's comment
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ametys.core.ui.ClientSideElement
ClientSideElement.Script, ClientSideElement.ScriptFile
-
-
Field Summary
Fields Modifier and Type Field Description protected ObservationManager
_observationManager
The observation managerprotected AmetysObjectResolver
_resolver
The Ametys object resolverprotected CurrentUserProvider
_userProvider
The current user providerstatic String
PARAMETER_AUTHOR_EMAIL
The constant for the email of the author from parametersstatic String
PARAMETER_AUTHOR_EMAILHIDDEN
The constant for the hidden status of the email of the author from parametersstatic String
PARAMETER_AUTHOR_NAME
The constant for the name of the author from parametersstatic String
PARAMETER_AUTHOR_URL
The constant for the url of the author from parametersstatic String
PARAMETER_COMMENT_ID
The constant for the comment id from parametersstatic String
PARAMETER_CONTENT_ID
The constant for the content id from parametersstatic String
PARAMETER_TEXT
The constant for the text from parameters-
Fields inherited from class org.ametys.core.ui.StaticFileImportsClientSideElement
_currentUserProvider, _dependencies, _featureName, _id, _pluginName, _rightManager, _rights, _rightsMode, _script
-
-
Constructor Summary
Constructors Constructor Description CommentClientSideElement()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
_isParentCommentAlreadyDelete(List<String> deleteCommentIds, String commentId)
True if the a parent comment of the comment id is already deletedprotected Map<String,Object>
_jsonifyComment(Comment comment, Content content)
Jsonify the comment.protected Map<String,Object>
_jsonifyContent(Content content)
Jsonify the content.Map<String,Object>
deleteComments(Map<String,List<String>> contents)
Removes commentsMap<String,Object>
editComment(Map<String,Object> parameters)
Edit a comment if connected user has sufficient rightsMap<String,Object>
getComment(String contentId, String commentId)
Get a comment propertiesprotected Map<String,Object>
getCommentParameters(Content content, Comment comment)
Get the parameters for a commentMap<String,Object>
getComments(Map<String,Object> parameters)
Return the list of comments with its validation stateprotected UserIdentity
getCurrentUser()
Get the current userprotected boolean
hasRight(String rightId, Content content)
Determines if connected user has right on contentMap<String,Object>
invalidateComments(Map<String,List<String>> contents)
Invalidates comments when it is possible.void
service(ServiceManager smanager)
Map<String,Object>
validateComments(Map<String,List<String>> contents)
Validates comments when it is possible.-
Methods inherited from class org.ametys.core.ui.StaticClientSideElement
_configureClass, _configureParameters, _configureScript, configureInitialParameters
-
Methods inherited from class org.ametys.core.ui.StaticFileImportsClientSideElement
_configureDependencies, _configureImports, _configureRights, _configureRightsMode, configure, getDependencies, getId, getPluginName, getRights, getScripts, getScripts, hasRight, setPluginInfo, toString
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
PARAMETER_AUTHOR_NAME
public static final String PARAMETER_AUTHOR_NAME
The constant for the name of the author from parameters- See Also:
- Constant Field Values
-
PARAMETER_AUTHOR_EMAIL
public static final String PARAMETER_AUTHOR_EMAIL
The constant for the email of the author from parameters- See Also:
- Constant Field Values
-
PARAMETER_AUTHOR_EMAILHIDDEN
public static final String PARAMETER_AUTHOR_EMAILHIDDEN
The constant for the hidden status of the email of the author from parameters- See Also:
- Constant Field Values
-
PARAMETER_AUTHOR_URL
public static final String PARAMETER_AUTHOR_URL
The constant for the url of the author from parameters- See Also:
- Constant Field Values
-
PARAMETER_TEXT
public static final String PARAMETER_TEXT
The constant for the text from parameters- See Also:
- Constant Field Values
-
PARAMETER_CONTENT_ID
public static final String PARAMETER_CONTENT_ID
The constant for the content id from parameters- See Also:
- Constant Field Values
-
PARAMETER_COMMENT_ID
public static final String PARAMETER_COMMENT_ID
The constant for the comment id from parameters- See Also:
- Constant Field Values
-
_resolver
protected AmetysObjectResolver _resolver
The Ametys object resolver
-
_userProvider
protected CurrentUserProvider _userProvider
The current user provider
-
_observationManager
protected ObservationManager _observationManager
The observation manager
-
-
Constructor Detail
-
CommentClientSideElement
public CommentClientSideElement()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classStaticFileImportsClientSideElement
- Throws:
ServiceException
-
getComments
public Map<String,Object> getComments(Map<String,Object> parameters)
Return the list of comments with its validation state- Parameters:
parameters
- The contents and their comments- Returns:
- The comments and their validated status
-
getComment
public Map<String,Object> getComment(String contentId, String commentId) throws IOException, ProcessingException
Get a comment properties- Parameters:
contentId
- the id of the contentcommentId
- the id of the comment. Can be null- Returns:
- results the server's response in JSON.
- Throws:
IOException
- If an error occurredProcessingException
- If an error occurred
-
editComment
public Map<String,Object> editComment(Map<String,Object> parameters)
Edit a comment if connected user has sufficient rights- Parameters:
parameters
- the JS parameters. Necessarily contains the content and comment id, and the values to edit- Returns:
- An empty map
-
deleteComments
public Map<String,Object> deleteComments(Map<String,List<String>> contents)
Removes comments- Parameters:
contents
- the contents with comments to remove- Returns:
- the JSON result with deleted comments or not
-
_isParentCommentAlreadyDelete
protected boolean _isParentCommentAlreadyDelete(List<String> deleteCommentIds, String commentId)
True if the a parent comment of the comment id is already deleted- Parameters:
deleteCommentIds
- the delete comment idscommentId
- the comment id- Returns:
- true if the a parent comment of the comment id is already deleted
-
validateComments
public Map<String,Object> validateComments(Map<String,List<String>> contents)
Validates comments when it is possible.- Parameters:
contents
- the contents with comments to validate- Returns:
- the JSON result with validated comments or not
-
invalidateComments
public Map<String,Object> invalidateComments(Map<String,List<String>> contents)
Invalidates comments when it is possible.- Parameters:
contents
- the contents with comments to invalidate- Returns:
- the JSON result with invalidated comments or not
-
_jsonifyComment
protected Map<String,Object> _jsonifyComment(Comment comment, Content content)
Jsonify the comment.- Parameters:
comment
- The commentcontent
- The content- Returns:
- commentMap the comment map
-
_jsonifyContent
protected Map<String,Object> _jsonifyContent(Content content)
Jsonify the content.- Parameters:
content
- The content- Returns:
- contentMap the content map
-
getCommentParameters
protected Map<String,Object> getCommentParameters(Content content, Comment comment)
Get the parameters for a comment- Parameters:
content
- The contentcomment
- The comment- Returns:
- The parameters
-
getCurrentUser
protected UserIdentity getCurrentUser()
Get the current user- Returns:
- The current user
-
-