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.impl;
022:
023: import com.liferay.portal.PortalException;
024: import com.liferay.portal.SystemException;
025: import com.liferay.portal.kernel.security.permission.ActionKeys;
026: import com.liferay.portal.model.Group;
027: import com.liferay.portal.service.base.GroupServiceBaseImpl;
028: import com.liferay.portal.service.permission.GroupPermissionUtil;
029: import com.liferay.portal.service.permission.PortalPermissionUtil;
030: import com.liferay.portal.service.permission.RolePermissionUtil;
031: import com.liferay.util.MapUtil;
032:
033: import java.util.LinkedHashMap;
034: import java.util.List;
035:
036: /**
037: * <a href="GroupServiceImpl.java.html"><b><i>View Source</i></b></a>
038: *
039: * @author Brian Wing Shun Chan
040: *
041: */
042: public class GroupServiceImpl extends GroupServiceBaseImpl {
043:
044: public Group addGroup(String name, String description, int type,
045: String friendlyURL, boolean active) throws PortalException,
046: SystemException {
047:
048: PortalPermissionUtil.check(getPermissionChecker(),
049: ActionKeys.ADD_COMMUNITY);
050:
051: return groupLocalService.addGroup(getUserId(), null, 0, name,
052: description, type, friendlyURL, active);
053: }
054:
055: public Group addGroup(long liveGroupId, String name,
056: String description, int type, String friendlyURL,
057: boolean active) throws PortalException, SystemException {
058:
059: GroupPermissionUtil.check(getPermissionChecker(), liveGroupId,
060: ActionKeys.UPDATE);
061:
062: return groupLocalService.addGroup(getUserId(), null, 0,
063: liveGroupId, name, description, type, friendlyURL,
064: active);
065: }
066:
067: public void addRoleGroups(long roleId, long[] groupIds)
068: throws PortalException, SystemException {
069:
070: RolePermissionUtil.check(getPermissionChecker(), roleId,
071: ActionKeys.UPDATE);
072:
073: groupLocalService.addRoleGroups(roleId, groupIds);
074: }
075:
076: public void deleteGroup(long groupId) throws PortalException,
077: SystemException {
078:
079: GroupPermissionUtil.check(getPermissionChecker(), groupId,
080: ActionKeys.DELETE);
081:
082: groupLocalService.deleteGroup(groupId);
083: }
084:
085: public Group getGroup(long groupId) throws PortalException,
086: SystemException {
087:
088: return groupLocalService.getGroup(groupId);
089: }
090:
091: public Group getGroup(long companyId, String name)
092: throws PortalException, SystemException {
093:
094: return groupLocalService.getGroup(companyId, name);
095: }
096:
097: public List getOrganizationsGroups(List organizations)
098: throws PortalException, SystemException {
099:
100: return groupLocalService.getOrganizationsGroups(organizations);
101: }
102:
103: public List getUserGroupsGroups(List userGroups)
104: throws PortalException, SystemException {
105:
106: return groupLocalService.getUserGroupsGroups(userGroups);
107: }
108:
109: public boolean hasUserGroup(long userId, long groupId)
110: throws SystemException {
111:
112: return groupLocalService.hasUserGroup(userId, groupId);
113: }
114:
115: public List search(long companyId, String name, String description,
116: String[] params, int begin, int end) throws SystemException {
117:
118: LinkedHashMap paramsObj = MapUtil.toLinkedHashMap(params);
119:
120: return groupLocalService.search(companyId, name, description,
121: paramsObj, begin, end);
122: }
123:
124: public int searchCount(long companyId, String name,
125: String description, String[] params) throws SystemException {
126:
127: LinkedHashMap paramsObj = MapUtil.toLinkedHashMap(params);
128:
129: return groupLocalService.searchCount(companyId, name,
130: description, paramsObj);
131: }
132:
133: public void setRoleGroups(long roleId, long[] groupIds)
134: throws PortalException, SystemException {
135:
136: RolePermissionUtil.check(getPermissionChecker(), roleId,
137: ActionKeys.UPDATE);
138:
139: groupLocalService.setRoleGroups(roleId, groupIds);
140: }
141:
142: public void unsetRoleGroups(long roleId, long[] groupIds)
143: throws PortalException, SystemException {
144:
145: RolePermissionUtil.check(getPermissionChecker(), roleId,
146: ActionKeys.UPDATE);
147:
148: groupLocalService.unsetRoleGroups(roleId, groupIds);
149: }
150:
151: public Group updateGroup(long groupId, String name,
152: String description, int type, String friendlyURL,
153: boolean active) throws PortalException, SystemException {
154:
155: GroupPermissionUtil.check(getPermissionChecker(), groupId,
156: ActionKeys.UPDATE);
157:
158: return groupLocalService.updateGroup(groupId, name,
159: description, type, friendlyURL, active);
160: }
161:
162: public Group updateGroup(long groupId, String typeSettings)
163: throws PortalException, SystemException {
164:
165: GroupPermissionUtil.check(getPermissionChecker(), groupId,
166: ActionKeys.UPDATE);
167:
168: return groupLocalService.updateGroup(groupId, typeSettings);
169: }
170:
171: }
|