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.User;
027: import com.liferay.portal.model.UserGroup;
028: import com.liferay.portal.service.base.UserGroupServiceBaseImpl;
029: import com.liferay.portal.service.permission.GroupPermissionUtil;
030: import com.liferay.portal.service.permission.PortalPermissionUtil;
031: import com.liferay.portal.service.permission.UserGroupPermissionUtil;
032:
033: import java.util.List;
034:
035: /**
036: * <a href="UserGroupServiceImpl.java.html"><b><i>View Source</i></b></a>
037: *
038: * @author Charles May
039: *
040: */
041: public class UserGroupServiceImpl extends UserGroupServiceBaseImpl {
042:
043: public void addGroupUserGroups(long groupId, long[] userGroupIds)
044: throws PortalException, SystemException {
045:
046: GroupPermissionUtil.check(getPermissionChecker(), groupId,
047: ActionKeys.ASSIGN_MEMBERS);
048:
049: userGroupLocalService.addGroupUserGroups(groupId, userGroupIds);
050: }
051:
052: public UserGroup addUserGroup(String name, String description)
053: throws PortalException, SystemException {
054:
055: PortalPermissionUtil.check(getPermissionChecker(),
056: ActionKeys.ADD_USER_GROUP);
057:
058: User user = getUser();
059:
060: return userGroupLocalService.addUserGroup(user.getUserId(),
061: user.getCompanyId(), name, description);
062: }
063:
064: public void deleteUserGroup(long userGroupId)
065: throws PortalException, SystemException {
066:
067: UserGroupPermissionUtil.check(getPermissionChecker(),
068: userGroupId, ActionKeys.DELETE);
069:
070: userGroupLocalService.deleteUserGroup(userGroupId);
071: }
072:
073: public UserGroup getUserGroup(long userGroupId)
074: throws PortalException, SystemException {
075:
076: UserGroupPermissionUtil.check(getPermissionChecker(),
077: userGroupId, ActionKeys.VIEW);
078:
079: return userGroupLocalService.getUserGroup(userGroupId);
080: }
081:
082: public UserGroup getUserGroup(String name) throws PortalException,
083: SystemException {
084:
085: UserGroup userGroup = userGroupLocalService.getUserGroup(
086: getUser().getCompanyId(), name);
087:
088: long userGroupId = userGroup.getUserGroupId();
089:
090: UserGroupPermissionUtil.check(getPermissionChecker(),
091: userGroupId, ActionKeys.VIEW);
092:
093: return userGroup;
094: }
095:
096: public List getUserUserGroups(long userId) throws PortalException,
097: SystemException {
098:
099: return userGroupLocalService.getUserUserGroups(userId);
100: }
101:
102: public void unsetGroupUserGroups(long groupId, long[] userGroupIds)
103: throws PortalException, SystemException {
104:
105: GroupPermissionUtil.check(getPermissionChecker(), groupId,
106: ActionKeys.ASSIGN_MEMBERS);
107:
108: userGroupLocalService.unsetGroupUserGroups(groupId,
109: userGroupIds);
110: }
111:
112: public UserGroup updateUserGroup(long userGroupId, String name,
113: String description) throws PortalException, SystemException {
114:
115: UserGroupPermissionUtil.check(getPermissionChecker(),
116: userGroupId, ActionKeys.UPDATE);
117:
118: return userGroupLocalService.updateUserGroup(getUser()
119: .getCompanyId(), userGroupId, name, description);
120: }
121:
122: }
|