001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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.LayoutSetBranch;
020    import com.liferay.portal.security.permission.ActionKeys;
021    import com.liferay.portal.service.ServiceContext;
022    import com.liferay.portal.service.base.LayoutSetBranchServiceBaseImpl;
023    import com.liferay.portal.service.permission.GroupPermissionUtil;
024    import com.liferay.portal.service.permission.LayoutSetBranchPermissionUtil;
025    
026    import java.util.List;
027    
028    /**
029     * @author Raymond Augé
030     * @author Brian Wing Shun Chan
031     */
032    public class LayoutSetBranchServiceImpl extends LayoutSetBranchServiceBaseImpl {
033    
034            public LayoutSetBranch addLayoutSetBranch(
035                            long groupId, boolean privateLayout, String name,
036                            String description, boolean master, long copyLayoutSetBranchId,
037                            ServiceContext serviceContext)
038                    throws PortalException, SystemException {
039    
040                    GroupPermissionUtil.check(
041                            getPermissionChecker(), groupId, ActionKeys.ADD_LAYOUT_SET_BRANCH);
042    
043                    return layoutSetBranchLocalService.addLayoutSetBranch(
044                            getUserId(), groupId, privateLayout, name, description, master,
045                            copyLayoutSetBranchId, serviceContext);
046            }
047    
048            public void deleteLayoutSetBranch(long layoutSetBranchId)
049                    throws PortalException, SystemException {
050    
051                    LayoutSetBranchPermissionUtil.check(
052                            getPermissionChecker(), layoutSetBranchId, ActionKeys.DELETE);
053    
054                    layoutSetBranchLocalService.deleteLayoutSetBranch(layoutSetBranchId);
055            }
056    
057            public List<LayoutSetBranch> getLayoutSetBranches(
058                            long groupId, boolean privateLayout)
059                    throws SystemException {
060    
061                    return layoutSetBranchLocalService.getLayoutSetBranches(
062                            groupId, privateLayout);
063            }
064    
065            public LayoutSetBranch mergeLayoutSetBranch(
066                            long layoutSetBranchId, long mergeLayoutSetBranchId,
067                            ServiceContext serviceContext)
068                    throws PortalException, SystemException {
069    
070                    LayoutSetBranchPermissionUtil.check(
071                            getPermissionChecker(), layoutSetBranchId, ActionKeys.UPDATE);
072    
073                    return layoutSetBranchLocalService.mergeLayoutSetBranch(
074                            layoutSetBranchId, mergeLayoutSetBranchId, serviceContext);
075            }
076    
077            public LayoutSetBranch updateLayoutSetBranch(
078                            long groupId, long layoutSetBranchId, String name,
079                            String description, ServiceContext serviceContext)
080                    throws PortalException, SystemException {
081    
082                    LayoutSetBranchPermissionUtil.check(
083                            getPermissionChecker(), layoutSetBranchId, ActionKeys.UPDATE);
084    
085                    return layoutSetBranchLocalService.updateLayoutSetBranch(
086                            layoutSetBranchId, name, description, serviceContext);
087            }
088    
089    }