001    /**
002     * Copyright (c) 2000-2011 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     *
028     * @author Brian Wing Shun Chan
029     * @author Julio Camarero
030     */
031    public class LayoutBranchServiceImpl extends LayoutBranchServiceBaseImpl {
032    
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            public void deleteLayoutBranch(long layoutBranchId)
048                    throws PortalException, SystemException {
049    
050                    LayoutBranchPermissionUtil.check(
051                            getPermissionChecker(), layoutBranchId, ActionKeys.DELETE);
052    
053                    layoutBranchLocalService.deleteLayoutBranch(layoutBranchId);
054            }
055    
056            public LayoutBranch updateLayoutBranch(
057                            long layoutBranchId, String name, String description,
058                            ServiceContext serviceContext)
059                    throws PortalException, SystemException {
060    
061                    LayoutBranchPermissionUtil.check(
062                            getPermissionChecker(), layoutBranchId, ActionKeys.UPDATE);
063    
064                    return layoutBranchLocalService.updateLayoutBranch(
065                            layoutBranchId, name, description, serviceContext);
066            }
067    
068    }