001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.model.Team;
020    import com.liferay.portal.security.permission.ActionKeys;
021    import com.liferay.portal.service.base.TeamServiceBaseImpl;
022    import com.liferay.portal.service.permission.GroupPermissionUtil;
023    import com.liferay.portal.service.permission.TeamPermissionUtil;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    public class TeamServiceImpl extends TeamServiceBaseImpl {
029    
030            public Team addTeam(
031                            long groupId, String name, String description)
032                    throws PortalException, SystemException {
033    
034                    GroupPermissionUtil.check(
035                            getPermissionChecker(), groupId, ActionKeys.MANAGE_TEAMS);
036    
037                    return teamLocalService.addTeam(
038                            getUserId(), groupId, name, description);
039            }
040    
041            public void deleteTeam(long teamId)
042                    throws PortalException, SystemException {
043    
044                    TeamPermissionUtil.check(
045                            getPermissionChecker(), teamId, ActionKeys.DELETE);
046    
047                    teamLocalService.deleteTeam(teamId);
048            }
049    
050            public Team updateTeam(long teamId, String name, String description)
051                    throws PortalException, SystemException {
052    
053                    TeamPermissionUtil.check(
054                            getPermissionChecker(), teamId, ActionKeys.UPDATE);
055    
056                    return teamLocalService.updateTeam(teamId, name, description);
057            }
058    
059    }