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.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    }