001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.messageboards.comment;
016    
017    import com.liferay.portal.kernel.comment.BaseDiscussionPermission;
018    import com.liferay.portal.kernel.exception.PortalException;
019    import com.liferay.portal.security.permission.ActionKeys;
020    import com.liferay.portal.security.permission.PermissionChecker;
021    import com.liferay.portlet.messageboards.service.permission.MBDiscussionPermission;
022    
023    /**
024     * @author Adolfo P??rez
025     * @author Sergio Gonz??lez
026     */
027    public class MBDiscussionPermissionImpl extends BaseDiscussionPermission {
028    
029            public MBDiscussionPermissionImpl(PermissionChecker permissionChecker) {
030                    _permissionChecker = permissionChecker;
031            }
032    
033            @Override
034            public boolean hasAddPermission(
035                    long companyId, long groupId, String className, long classPK) {
036    
037                    return MBDiscussionPermission.contains(
038                            _permissionChecker, companyId, groupId, className, classPK,
039                            ActionKeys.ADD_DISCUSSION);
040            }
041    
042            @Override
043            public boolean hasDeletePermission(long commentId) throws PortalException {
044                    return MBDiscussionPermission.contains(
045                            _permissionChecker, commentId, ActionKeys.DELETE_DISCUSSION);
046            }
047    
048            @Override
049            public boolean hasUpdatePermission(long commentId) throws PortalException {
050                    return MBDiscussionPermission.contains(
051                            _permissionChecker, commentId, ActionKeys.UPDATE_DISCUSSION);
052            }
053    
054            @Override
055            public boolean hasViewPermission(
056                    long companyId, long groupId, String className, long classPK) {
057    
058                    return MBDiscussionPermission.contains(
059                            _permissionChecker, companyId, groupId, className, classPK,
060                            ActionKeys.VIEW);
061            }
062    
063            private final PermissionChecker _permissionChecker;
064    
065    }