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.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.kernel.util.OrderByComparator;
020    import com.liferay.portal.security.permission.ActionKeys;
021    import com.liferay.portal.service.ServiceContext;
022    import com.liferay.portlet.journal.model.JournalStructure;
023    import com.liferay.portlet.journal.service.base.JournalStructureServiceBaseImpl;
024    import com.liferay.portlet.journal.service.permission.JournalPermission;
025    import com.liferay.portlet.journal.service.permission.JournalStructurePermission;
026    
027    import java.util.List;
028    import java.util.Locale;
029    import java.util.Map;
030    
031    /**
032     * @author Brian Wing Shun Chan
033     * @author Raymond Augé
034     */
035    public class JournalStructureServiceImpl
036            extends JournalStructureServiceBaseImpl {
037    
038            public JournalStructure addStructure(
039                            long groupId, String structureId, boolean autoStructureId,
040                            String parentStructureId, Map<Locale, String> nameMap,
041                            Map<Locale, String> descriptionMap, String xsd,
042                            ServiceContext serviceContext)
043                    throws PortalException, SystemException {
044    
045                    JournalPermission.check(
046                            getPermissionChecker(), groupId, ActionKeys.ADD_STRUCTURE);
047    
048                    return journalStructureLocalService.addStructure(
049                            getUserId(), groupId, structureId, autoStructureId,
050                            parentStructureId, nameMap, descriptionMap, xsd, serviceContext);
051            }
052    
053            public JournalStructure copyStructure(
054                            long groupId, String oldStructureId, String newStructureId,
055                            boolean autoStructureId)
056                    throws PortalException, SystemException {
057    
058                    JournalPermission.check(
059                            getPermissionChecker(), groupId, ActionKeys.ADD_STRUCTURE);
060    
061                    return journalStructureLocalService.copyStructure(
062                            getUserId(), groupId, oldStructureId, newStructureId,
063                            autoStructureId);
064            }
065    
066            public void deleteStructure(long groupId, String structureId)
067                    throws PortalException, SystemException {
068    
069                    JournalStructurePermission.check(
070                            getPermissionChecker(), groupId, structureId, ActionKeys.DELETE);
071    
072                    journalStructureLocalService.deleteStructure(groupId, structureId);
073            }
074    
075            public JournalStructure getStructure(long groupId, String structureId)
076                    throws PortalException, SystemException {
077    
078                    JournalStructurePermission.check(
079                            getPermissionChecker(), groupId, structureId, ActionKeys.VIEW);
080    
081                    return journalStructureLocalService.getStructure(groupId, structureId);
082            }
083    
084            public List<JournalStructure> getStructures(long groupId)
085                    throws SystemException {
086    
087                    return journalStructurePersistence.filterFindByGroupId(groupId);
088            }
089    
090            public List<JournalStructure> search(
091                            long companyId, long[] groupIds, String keywords, int start,
092                            int end, OrderByComparator obc)
093                    throws SystemException {
094    
095                    return journalStructureFinder.filterFindByKeywords(
096                            companyId, groupIds, keywords, start, end, obc);
097            }
098    
099            public List<JournalStructure> search(
100                            long companyId, long[] groupIds, String structureId, String name,
101                            String description, boolean andOperator, int start, int end,
102                            OrderByComparator obc)
103                    throws SystemException {
104    
105                    return journalStructureFinder.filterFindByC_G_S_N_D(
106                            companyId, groupIds, structureId, name, description, andOperator,
107                            start, end, obc);
108            }
109    
110            public int searchCount(long companyId, long[] groupIds, String keywords)
111                    throws SystemException {
112    
113                    return journalStructureFinder.filterCountByKeywords(
114                            companyId, groupIds, keywords);
115            }
116    
117            public int searchCount(
118                            long companyId, long[] groupIds, String structureId, String name,
119                            String description, boolean andOperator)
120                    throws SystemException {
121    
122                    return journalStructureFinder.filterCountByC_G_S_N_D(
123                            companyId, groupIds, structureId, name, description, andOperator);
124            }
125    
126            public JournalStructure updateStructure(
127                            long groupId, String structureId, String parentStructureId,
128                            Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
129                            String xsd, ServiceContext serviceContext)
130                    throws PortalException, SystemException {
131    
132                    JournalStructurePermission.check(
133                            getPermissionChecker(), groupId, structureId, ActionKeys.UPDATE);
134    
135                    return journalStructureLocalService.updateStructure(
136                            groupId, structureId, parentStructureId, nameMap, descriptionMap,
137                            xsd, serviceContext);
138            }
139    
140    }