001    /**
002     * Copyright (c) 2000-2012 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.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    }