/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.portlet.expando.service.permission; import com.liferay.expando.kernel.model.ExpandoColumn; import com.liferay.expando.kernel.service.ExpandoColumnLocalServiceUtil; import com.liferay.expando.kernel.service.permission.ExpandoColumnPermission; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.security.auth.PrincipalException; import com.liferay.portal.kernel.security.permission.PermissionChecker; /** * @author Raymond Augé */ public class ExpandoColumnPermissionImpl implements ExpandoColumnPermission { @Override public void check( PermissionChecker permissionChecker, ExpandoColumn column, String actionId) throws PortalException { if (!contains(permissionChecker, column, actionId)) { throw new PrincipalException.MustHavePermission( permissionChecker, ExpandoColumn.class.getName(), column.getColumnId(), actionId); } } @Override public void check( PermissionChecker permissionChecker, long columnId, String actionId) throws PortalException { if (!contains(permissionChecker, columnId, actionId)) { throw new PrincipalException.MustHavePermission( permissionChecker, ExpandoColumn.class.getName(), columnId, actionId); } } @Override public void check( PermissionChecker permissionChecker, long companyId, String className, String tableName, String columnName, String actionId) throws PortalException { ExpandoColumn column = ExpandoColumnLocalServiceUtil.getColumn( companyId, className, tableName, columnName); check(permissionChecker, column, actionId); } @Override public boolean contains( PermissionChecker permissionChecker, ExpandoColumn column, String actionId) { return permissionChecker.hasPermission( null, ExpandoColumn.class.getName(), column.getColumnId(), actionId); } @Override public boolean contains( PermissionChecker permissionChecker, long columnId, String actionId) throws PortalException { ExpandoColumn column = ExpandoColumnLocalServiceUtil.getColumn( columnId); return contains(permissionChecker, column, actionId); } @Override public boolean contains( PermissionChecker permissionChecker, long companyId, String className, String tableName, String columnName, String actionId) { ExpandoColumn column = ExpandoColumnLocalServiceUtil.getColumn( companyId, className, tableName, columnName); return contains(permissionChecker, column, actionId); } }