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.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            public LayoutBranch addLayoutBranch(
033                            long layoutRevisionId, String name, String description,
034                            boolean master, ServiceContext serviceContext)
035                    throws PortalException, SystemException {
036    
037                    long groupId = serviceContext.getScopeGroupId();
038    
039                    GroupPermissionUtil.check(
040                            getPermissionChecker(), groupId, ActionKeys.ADD_LAYOUT_BRANCH);
041    
042                    return layoutBranchLocalService.addLayoutBranch(
043                            layoutRevisionId, name, description, false, serviceContext);
044            }
045    
046            public void deleteLayoutBranch(long layoutBranchId)
047                    throws PortalException, SystemException {
048    
049                    LayoutBranchPermissionUtil.check(
050                            getPermissionChecker(), layoutBranchId, ActionKeys.DELETE);
051    
052                    layoutBranchLocalService.deleteLayoutBranch(layoutBranchId);
053            }
054    
055            public LayoutBranch updateLayoutBranch(
056                            long layoutBranchId, String name, String description,
057                            ServiceContext serviceContext)
058                    throws PortalException, SystemException {
059    
060                    LayoutBranchPermissionUtil.check(
061                            getPermissionChecker(), layoutBranchId, ActionKeys.UPDATE);
062    
063                    return layoutBranchLocalService.updateLayoutBranch(
064                            layoutBranchId, name, description, serviceContext);
065            }
066    
067    }