List of usage examples for com.liferay.portal.kernel.comment DiscussionPermission checkUpdatePermission
public void checkUpdatePermission(long commentId) throws PortalException;
From source file:com.liferay.comment.internal.jsonws.CommentManagerJSONWS.java
License:Open Source License
public long updateComment(String className, long classPK, long commentId, String subject, String body) throws PortalException { DiscussionPermission discussionPermission = _commentManager.getDiscussionPermission(getPermissionChecker()); discussionPermission.checkUpdatePermission(commentId); return _commentManager.updateComment(getUserId(), className, classPK, commentId, subject, body, createServiceContextFunction(WorkflowConstants.ACTION_PUBLISH)); }
From source file:com.liferay.comment.taglib.internal.struts.EditDiscussionStrutsAction.java
License:Open Source License
protected long updateComment(HttpServletRequest request) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); long commentId = ParamUtil.getLong(request, "commentId"); String className = ParamUtil.getString(request, "className"); long classPK = ParamUtil.getLong(request, "classPK"); long parentCommentId = ParamUtil.getLong(request, "parentCommentId"); String subject = ParamUtil.getString(request, "subject"); String body = ParamUtil.getString(request, "body"); Function<String, ServiceContext> serviceContextFunction = new ServiceContextFunction(request); DiscussionPermission discussionPermission = _getDiscussionPermission(themeDisplay); if (commentId <= 0) { // Add message User user = null;/*ww w . j a v a2 s . co m*/ if (themeDisplay.isSignedIn()) { user = themeDisplay.getUser(); } else { String emailAddress = ParamUtil.getString(request, "emailAddress"); user = _userLocalService.fetchUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress); if ((user == null) || (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE)) { return 0; } } String name = PrincipalThreadLocal.getName(); PrincipalThreadLocal.setName(user.getUserId()); try { discussionPermission.checkAddPermission(themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId(), className, classPK); commentId = _commentManager.addComment(user.getUserId(), className, classPK, user.getFullName(), parentCommentId, subject, body, serviceContextFunction); } finally { PrincipalThreadLocal.setName(name); } } else { // Update message if (Validator.isNull(className) || (classPK == 0)) { Comment comment = _commentManager.fetchComment(commentId); if (comment != null) { className = comment.getClassName(); classPK = comment.getClassPK(); } } discussionPermission.checkUpdatePermission(commentId); commentId = _commentManager.updateComment(themeDisplay.getUserId(), className, classPK, commentId, subject, body, serviceContextFunction); } // Subscription boolean subscribe = ParamUtil.getBoolean(request, "subscribe"); if (subscribe) { _commentManager.subscribeDiscussion(themeDisplay.getUserId(), themeDisplay.getScopeGroupId(), className, classPK); } return commentId; }
From source file:com.liferay.screens.service.impl.ScreensCommentServiceImpl.java
License:Open Source License
@Override public JSONObject updateComment(long commentId, String body) throws PortalException { DiscussionPermission discussionPermission = commentManager.getDiscussionPermission(getPermissionChecker()); discussionPermission.checkUpdatePermission(commentId); Comment comment = commentManager.fetchComment(commentId); commentManager.updateComment(getUserId(), comment.getClassName(), comment.getClassPK(), commentId, StringPool.BLANK, body, createServiceContextFunction(WorkflowConstants.ACTION_PUBLISH)); comment = commentManager.fetchComment(commentId); return toJSONObject(comment, discussionPermission); }