001    /**
002     * Copyright (c) 2000-2013 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            @Override
035            public LayoutSetBranch addLayoutSetBranch(
036                            long groupId, boolean privateLayout, String name,
037                            String description, boolean master, long copyLayoutSetBranchId,
038                            ServiceContext serviceContext)
039                    throws PortalException, SystemException {
040    
041                    GroupPermissionUtil.check(
042                            getPermissionChecker(), groupId, ActionKeys.ADD_LAYOUT_SET_BRANCH);
043    
044                    return layoutSetBranchLocalService.addLayoutSetBranch(
045                            getUserId(), groupId, privateLayout, name, description, master,
046                            copyLayoutSetBranchId, serviceContext);
047            }
048    
049            @Override
050            public void deleteLayoutSetBranch(long layoutSetBranchId)
051                    throws PortalException, SystemException {
052    
053                    LayoutSetBranchPermissionUtil.check(
054                            getPermissionChecker(), layoutSetBranchId, ActionKeys.DELETE);
055    
056                    layoutSetBranchLocalService.deleteLayoutSetBranch(layoutSetBranchId);
057            }
058    
059            @Override
060            public List<LayoutSetBranch> getLayoutSetBranches(
061                            long groupId, boolean privateLayout)
062                    throws SystemException {
063    
064                    return layoutSetBranchLocalService.getLayoutSetBranches(
065                            groupId, privateLayout);
066            }
067    
068            @Override
069            public LayoutSetBranch mergeLayoutSetBranch(
070                            long layoutSetBranchId, long mergeLayoutSetBranchId,
071                            ServiceContext serviceContext)
072                    throws PortalException, SystemException {
073    
074                    LayoutSetBranchPermissionUtil.check(
075                            getPermissionChecker(), layoutSetBranchId, ActionKeys.UPDATE);
076    
077                    return layoutSetBranchLocalService.mergeLayoutSetBranch(
078                            layoutSetBranchId, mergeLayoutSetBranchId, serviceContext);
079            }
080    
081            @Override
082            public LayoutSetBranch updateLayoutSetBranch(
083                            long groupId, long layoutSetBranchId, String name,
084                            String description, ServiceContext serviceContext)
085                    throws PortalException, SystemException {
086    
087                    LayoutSetBranchPermissionUtil.check(
088                            getPermissionChecker(), layoutSetBranchId, ActionKeys.UPDATE);
089    
090                    return layoutSetBranchLocalService.updateLayoutSetBranch(
091                            layoutSetBranchId, name, description, serviceContext);
092            }
093    
094    }