001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.service.permission;
022:
023: import com.liferay.portal.PortalException;
024: import com.liferay.portal.SystemException;
025: import com.liferay.portal.kernel.bean.BeanLocatorUtil;
026: import com.liferay.portal.kernel.security.permission.PermissionChecker;
027: import com.liferay.portal.model.Layout;
028:
029: /**
030: * <a href="LayoutPermissionUtil.java.html"><b><i>View Source</i></b></a>
031: *
032: * @author Brian Wing Shun Chan
033: *
034: */
035: public class LayoutPermissionUtil {
036:
037: public static void check(PermissionChecker permissionChecker,
038: long plid, String actionId) throws PortalException,
039: SystemException {
040:
041: getLayoutPermission().check(permissionChecker, plid, actionId);
042: }
043:
044: public static void check(PermissionChecker permissionChecker,
045: long groupId, boolean privateLayout, long layoutId,
046: String actionId) throws PortalException, SystemException {
047:
048: getLayoutPermission().check(permissionChecker, groupId,
049: privateLayout, layoutId, actionId);
050: }
051:
052: public static void check(PermissionChecker permissionChecker,
053: Layout layout, String actionId) throws PortalException,
054: SystemException {
055:
056: getLayoutPermission()
057: .check(permissionChecker, layout, actionId);
058: }
059:
060: public static boolean contains(PermissionChecker permissionChecker,
061: long plid, String actionId) throws PortalException,
062: SystemException {
063:
064: return getLayoutPermission().contains(permissionChecker, plid,
065: actionId);
066: }
067:
068: public static boolean contains(PermissionChecker permissionChecker,
069: long groupId, boolean privateLayout, long layoutId,
070: String actionId) throws PortalException, SystemException {
071:
072: return getLayoutPermission().contains(permissionChecker,
073: groupId, privateLayout, layoutId, actionId);
074: }
075:
076: public static boolean contains(PermissionChecker permissionChecker,
077: Layout layout, String actionId) throws PortalException,
078: SystemException {
079:
080: return getLayoutPermission().contains(permissionChecker,
081: layout, actionId);
082: }
083:
084: public static LayoutPermission getLayoutPermission() {
085: return _getUtil()._layoutPermission;
086: }
087:
088: public void setLayoutPermission(LayoutPermission layoutPermission) {
089: _layoutPermission = layoutPermission;
090: }
091:
092: private static LayoutPermissionUtil _getUtil() {
093: if (_util == null) {
094: _util = (LayoutPermissionUtil) BeanLocatorUtil
095: .locate(_UTIL);
096: }
097:
098: return _util;
099: }
100:
101: private static final String _UTIL = LayoutPermissionUtil.class
102: .getName();
103:
104: private static LayoutPermissionUtil _util;
105:
106: private LayoutPermission _layoutPermission;
107:
108: }
|