001    /**
002     * Copyright (c) 2000-present 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.model.LayoutSetBranch;
019    import com.liferay.portal.security.permission.ActionKeys;
020    import com.liferay.portal.service.ServiceContext;
021    import com.liferay.portal.service.base.LayoutSetBranchServiceBaseImpl;
022    import com.liferay.portal.service.permission.GroupPermissionUtil;
023    import com.liferay.portal.service.permission.LayoutSetBranchPermissionUtil;
024    
025    import java.util.List;
026    
027    /**
028     * @author Raymond Aug??
029     * @author Brian Wing Shun Chan
030     */
031    public class LayoutSetBranchServiceImpl extends LayoutSetBranchServiceBaseImpl {
032    
033            @Override
034            public LayoutSetBranch addLayoutSetBranch(
035                            long groupId, boolean privateLayout, String name,
036                            String description, boolean master, long copyLayoutSetBranchId,
037                            ServiceContext serviceContext)
038                    throws PortalException {
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            @Override
049            public void deleteLayoutSetBranch(long layoutSetBranchId)
050                    throws PortalException {
051    
052                    LayoutSetBranchPermissionUtil.check(
053                            getPermissionChecker(), layoutSetBranchId, ActionKeys.DELETE);
054    
055                    layoutSetBranchLocalService.deleteLayoutSetBranch(layoutSetBranchId);
056            }
057    
058            @Override
059            public List<LayoutSetBranch> getLayoutSetBranches(
060                    long groupId, boolean privateLayout) {
061    
062                    return layoutSetBranchLocalService.getLayoutSetBranches(
063                            groupId, privateLayout);
064            }
065    
066            @Override
067            public LayoutSetBranch mergeLayoutSetBranch(
068                            long layoutSetBranchId, long mergeLayoutSetBranchId,
069                            ServiceContext serviceContext)
070                    throws PortalException {
071    
072                    LayoutSetBranchPermissionUtil.check(
073                            getPermissionChecker(), layoutSetBranchId, ActionKeys.UPDATE);
074    
075                    return layoutSetBranchLocalService.mergeLayoutSetBranch(
076                            layoutSetBranchId, mergeLayoutSetBranchId, serviceContext);
077            }
078    
079            @Override
080            public LayoutSetBranch updateLayoutSetBranch(
081                            long groupId, long layoutSetBranchId, String name,
082                            String description, ServiceContext serviceContext)
083                    throws PortalException {
084    
085                    LayoutSetBranchPermissionUtil.check(
086                            getPermissionChecker(), layoutSetBranchId, ActionKeys.UPDATE);
087    
088                    return layoutSetBranchLocalService.updateLayoutSetBranch(
089                            layoutSetBranchId, name, description, serviceContext);
090            }
091    
092    }