001    /**
002     * Copyright (c) 2000-2013 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.LayoutBranch;
020    import com.liferay.portal.security.permission.ActionKeys;
021    import com.liferay.portal.service.ServiceContext;
022    import com.liferay.portal.service.base.LayoutBranchServiceBaseImpl;
023    import com.liferay.portal.service.permission.GroupPermissionUtil;
024    import com.liferay.portal.service.permission.LayoutBranchPermissionUtil;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     * @author Julio Camarero
029     */
030    public class LayoutBranchServiceImpl extends LayoutBranchServiceBaseImpl {
031    
032            @Override
033            public LayoutBranch addLayoutBranch(
034                            long layoutRevisionId, String name, String description,
035                            boolean master, ServiceContext serviceContext)
036                    throws PortalException, SystemException {
037    
038                    long groupId = serviceContext.getScopeGroupId();
039    
040                    GroupPermissionUtil.check(
041                            getPermissionChecker(), groupId, ActionKeys.ADD_LAYOUT_BRANCH);
042    
043                    return layoutBranchLocalService.addLayoutBranch(
044                            layoutRevisionId, name, description, false, serviceContext);
045            }
046    
047            @Override
048            public void deleteLayoutBranch(long layoutBranchId)
049                    throws PortalException, SystemException {
050    
051                    LayoutBranchPermissionUtil.check(
052                            getPermissionChecker(), layoutBranchId, ActionKeys.DELETE);
053    
054                    layoutBranchLocalService.deleteLayoutBranch(layoutBranchId);
055            }
056    
057            @Override
058            public LayoutBranch updateLayoutBranch(
059                            long layoutBranchId, String name, String description,
060                            ServiceContext serviceContext)
061                    throws PortalException, SystemException {
062    
063                    LayoutBranchPermissionUtil.check(
064                            getPermissionChecker(), layoutBranchId, ActionKeys.UPDATE);
065    
066                    return layoutBranchLocalService.updateLayoutBranch(
067                            layoutBranchId, name, description, serviceContext);
068            }
069    
070    }