001    /**
002     * Copyright (c) 2000-2010 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.portlet.journal.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.security.permission.ActionKeys;
020    import com.liferay.portal.service.ServiceContext;
021    import com.liferay.portlet.journal.model.JournalStructure;
022    import com.liferay.portlet.journal.service.base.JournalStructureServiceBaseImpl;
023    import com.liferay.portlet.journal.service.permission.JournalPermission;
024    import com.liferay.portlet.journal.service.permission.JournalStructurePermission;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     * @author Raymond Augé
029     */
030    public class JournalStructureServiceImpl
031            extends JournalStructureServiceBaseImpl {
032    
033            public JournalStructure addStructure(
034                            long groupId, String structureId, boolean autoStructureId,
035                            String parentStructureId, String name, String description,
036                            String xsd, ServiceContext serviceContext)
037                    throws PortalException, SystemException {
038    
039                    JournalPermission.check(
040                            getPermissionChecker(), groupId, ActionKeys.ADD_STRUCTURE);
041    
042                    return journalStructureLocalService.addStructure(
043                            getUserId(), groupId, structureId, autoStructureId,
044                            parentStructureId, name, description, xsd, serviceContext);
045            }
046    
047            public JournalStructure copyStructure(
048                            long groupId, String oldStructureId, String newStructureId,
049                            boolean autoStructureId)
050                    throws PortalException, SystemException {
051    
052                    JournalPermission.check(
053                            getPermissionChecker(), groupId, ActionKeys.ADD_STRUCTURE);
054    
055                    return journalStructureLocalService.copyStructure(
056                            getUserId(), groupId, oldStructureId, newStructureId,
057                            autoStructureId);
058            }
059    
060            public void deleteStructure(long groupId, String structureId)
061                    throws PortalException, SystemException {
062    
063                    JournalStructurePermission.check(
064                            getPermissionChecker(), groupId, structureId, ActionKeys.DELETE);
065    
066                    journalStructureLocalService.deleteStructure(groupId, structureId);
067            }
068    
069            public JournalStructure getStructure(long groupId, String structureId)
070                    throws PortalException, SystemException {
071    
072                    JournalStructurePermission.check(
073                            getPermissionChecker(), groupId, structureId, ActionKeys.VIEW);
074    
075                    return journalStructureLocalService.getStructure(groupId, structureId);
076            }
077    
078            public JournalStructure updateStructure(
079                            long groupId, String structureId, String parentStructureId,
080                            String name, String description, String xsd,
081                            ServiceContext serviceContext)
082                    throws PortalException, SystemException {
083    
084                    JournalStructurePermission.check(
085                            getPermissionChecker(), groupId, structureId, ActionKeys.UPDATE);
086    
087                    return journalStructureLocalService.updateStructure(
088                            groupId, structureId, parentStructureId, name, description, xsd,
089                            serviceContext);
090            }
091    
092    }