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.Portlet;
028:
029: /**
030: * <a href="PortletPermissionUtil.java.html"><b><i>View Source</i></b></a>
031: *
032: * @author Brian Wing Shun Chan
033: *
034: */
035: public class PortletPermissionUtil {
036:
037: public static void check(PermissionChecker permissionChecker,
038: String portletId, String actionId) throws PortalException,
039: SystemException {
040:
041: getPortletPermission().check(permissionChecker, portletId,
042: actionId);
043: }
044:
045: public static void check(PermissionChecker permissionChecker,
046: long plid, String portletId, String actionId)
047: throws PortalException, SystemException {
048:
049: getPortletPermission().check(permissionChecker, plid,
050: portletId, actionId);
051: }
052:
053: public static void check(PermissionChecker permissionChecker,
054: long plid, String portletId, String actionId, boolean strict)
055: throws PortalException, SystemException {
056:
057: getPortletPermission().check(permissionChecker, plid,
058: portletId, actionId, strict);
059: }
060:
061: public static boolean contains(PermissionChecker permissionChecker,
062: String portletId, String actionId) throws PortalException,
063: SystemException {
064:
065: return getPortletPermission().contains(permissionChecker,
066: portletId, actionId);
067: }
068:
069: public static boolean contains(PermissionChecker permissionChecker,
070: long plid, String portletId, String actionId)
071: throws PortalException, SystemException {
072:
073: return getPortletPermission().contains(permissionChecker, plid,
074: portletId, actionId);
075: }
076:
077: public static boolean contains(PermissionChecker permissionChecker,
078: long plid, String portletId, String actionId, boolean strict)
079: throws PortalException, SystemException {
080:
081: return getPortletPermission().contains(permissionChecker, plid,
082: portletId, actionId, strict);
083: }
084:
085: public static boolean contains(PermissionChecker permissionChecker,
086: long plid, Portlet portlet, String actionId)
087: throws PortalException, SystemException {
088:
089: return getPortletPermission().contains(permissionChecker, plid,
090: portlet, actionId);
091: }
092:
093: public static boolean contains(PermissionChecker permissionChecker,
094: long plid, Portlet portlet, String actionId, boolean strict)
095: throws PortalException, SystemException {
096:
097: return getPortletPermission().contains(permissionChecker, plid,
098: portlet, actionId, strict);
099: }
100:
101: public static PortletPermission getPortletPermission() {
102: return _getUtil()._portletPermission;
103: }
104:
105: public static String getPrimaryKey(long plid, String portletId) {
106: return getPortletPermission().getPrimaryKey(plid, portletId);
107: }
108:
109: public static boolean hasLayoutManagerPermission(String portletId,
110: String actionId) {
111:
112: return getPortletPermission().hasLayoutManagerPermission(
113: portletId, actionId);
114: }
115:
116: public void setPortletPermission(PortletPermission portletPermission) {
117: _portletPermission = portletPermission;
118: }
119:
120: private static PortletPermissionUtil _getUtil() {
121: if (_util == null) {
122: _util = (PortletPermissionUtil) BeanLocatorUtil
123: .locate(_UTIL);
124: }
125:
126: return _util;
127: }
128:
129: private static final String _UTIL = PortletPermissionUtil.class
130: .getName();
131:
132: private static PortletPermissionUtil _util;
133:
134: private PortletPermission _portletPermission;
135:
136: }
|