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.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            @Override
039            public JournalStructure addStructure(
040                            long groupId, String structureId, boolean autoStructureId,
041                            String parentStructureId, Map<Locale, String> nameMap,
042                            Map<Locale, String> descriptionMap, String xsd,
043                            ServiceContext serviceContext)
044                    throws PortalException, SystemException {
045    
046                    JournalPermission.check(
047                            getPermissionChecker(), groupId, ActionKeys.ADD_STRUCTURE);
048    
049                    return journalStructureLocalService.addStructure(
050                            getUserId(), groupId, structureId, autoStructureId,
051                            parentStructureId, nameMap, descriptionMap, xsd, serviceContext);
052            }
053    
054            @Override
055            public JournalStructure copyStructure(
056                            long groupId, String oldStructureId, String newStructureId,
057                            boolean autoStructureId)
058                    throws PortalException, SystemException {
059    
060                    JournalPermission.check(
061                            getPermissionChecker(), groupId, ActionKeys.ADD_STRUCTURE);
062    
063                    return journalStructureLocalService.copyStructure(
064                            getUserId(), groupId, oldStructureId, newStructureId,
065                            autoStructureId);
066            }
067    
068            @Override
069            public void deleteStructure(long groupId, String structureId)
070                    throws PortalException, SystemException {
071    
072                    JournalStructurePermission.check(
073                            getPermissionChecker(), groupId, structureId, ActionKeys.DELETE);
074    
075                    journalStructureLocalService.deleteStructure(groupId, structureId);
076            }
077    
078            @Override
079            public JournalStructure getStructure(long groupId, String structureId)
080                    throws PortalException, SystemException {
081    
082                    JournalStructurePermission.check(
083                            getPermissionChecker(), groupId, structureId, ActionKeys.VIEW);
084    
085                    return journalStructureLocalService.getStructure(groupId, structureId);
086            }
087    
088            @Override
089            public JournalStructure getStructure(
090                            long groupId, String structureId, boolean includeGlobalStructures)
091                    throws PortalException, SystemException {
092    
093                    JournalStructurePermission.check(
094                            getPermissionChecker(), groupId, structureId, ActionKeys.VIEW);
095    
096                    return journalStructureLocalService.getStructure(
097                            groupId, structureId, includeGlobalStructures);
098            }
099    
100            @Override
101            public List<JournalStructure> getStructures(long groupId)
102                    throws SystemException {
103    
104                    return journalStructurePersistence.filterFindByGroupId(groupId);
105            }
106    
107            @Override
108            public List<JournalStructure> search(
109                            long companyId, long[] groupIds, String keywords, int start,
110                            int end, OrderByComparator obc)
111                    throws SystemException {
112    
113                    return journalStructureFinder.filterFindByKeywords(
114                            companyId, groupIds, keywords, start, end, obc);
115            }
116    
117            @Override
118            public List<JournalStructure> search(
119                            long companyId, long[] groupIds, String structureId, String name,
120                            String description, boolean andOperator, int start, int end,
121                            OrderByComparator obc)
122                    throws SystemException {
123    
124                    return journalStructureFinder.filterFindByC_G_S_N_D(
125                            companyId, groupIds, structureId, name, description, andOperator,
126                            start, end, obc);
127            }
128    
129            @Override
130            public int searchCount(long companyId, long[] groupIds, String keywords)
131                    throws SystemException {
132    
133                    return journalStructureFinder.filterCountByKeywords(
134                            companyId, groupIds, keywords);
135            }
136    
137            @Override
138            public int searchCount(
139                            long companyId, long[] groupIds, String structureId, String name,
140                            String description, boolean andOperator)
141                    throws SystemException {
142    
143                    return journalStructureFinder.filterCountByC_G_S_N_D(
144                            companyId, groupIds, structureId, name, description, andOperator);
145            }
146    
147            @Override
148            public JournalStructure updateStructure(
149                            long groupId, String structureId, String parentStructureId,
150                            Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
151                            String xsd, ServiceContext serviceContext)
152                    throws PortalException, SystemException {
153    
154                    JournalStructurePermission.check(
155                            getPermissionChecker(), groupId, structureId, ActionKeys.UPDATE);
156    
157                    return journalStructureLocalService.updateStructure(
158                            groupId, structureId, parentStructureId, nameMap, descriptionMap,
159                            xsd, serviceContext);
160            }
161    
162    }