001
014
015 package com.liferay.portal.kernel.comment;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.security.auth.PrincipalException;
019 import com.liferay.portal.security.permission.ActionKeys;
020
021
025 public abstract class BaseDiscussionPermission implements DiscussionPermission {
026
027 @Override
028 public void checkAddPermission(
029 long companyId, long groupId, String className, long classPK)
030 throws PortalException {
031
032 if (!hasAddPermission(companyId, groupId, className, classPK)) {
033 throw new PrincipalException.MustHavePermission(
034 0, className, classPK, ActionKeys.ADD_DISCUSSION);
035 }
036 }
037
038 @Override
039 public void checkDeletePermission(long commentId) throws PortalException {
040 if (!hasDeletePermission(commentId)) {
041 throw new PrincipalException.MustHavePermission(
042 0, ActionKeys.DELETE_DISCUSSION);
043 }
044 }
045
046 @Override
047 public void checkSubscribePermission(
048 long companyId, long groupId, String className, long classPK)
049 throws PortalException {
050
051 if (!hasSubscribePermission(companyId, groupId, className, classPK)) {
052 throw new PrincipalException();
053 }
054 }
055
056 @Override
057 public void checkUpdatePermission(long commentId) throws PortalException {
058 if (!hasUpdatePermission(commentId)) {
059 throw new PrincipalException.MustHavePermission(
060 0, ActionKeys.UPDATE_DISCUSSION);
061 }
062 }
063
064 @Override
065 public void checkViewPermission(
066 long companyId, long groupId, String className, long classPK)
067 throws PortalException {
068
069 if (!hasViewPermission(companyId, groupId, className, classPK)) {
070 throw new PrincipalException.MustHavePermission(
071 0, className, classPK, ActionKeys.VIEW);
072 }
073 }
074
075 @Override
076 public boolean hasDeletePermission(long commentId) throws PortalException {
077 return hasPermission(commentId, ActionKeys.DELETE_DISCUSSION);
078 }
079
080 @Override
081 public boolean hasUpdatePermission(long commentId) throws PortalException {
082 return hasPermission(commentId, ActionKeys.UPDATE_DISCUSSION);
083 }
084
085 }