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> getStructures(long[] groupIds)
091                    throws SystemException {
092    
093                    return journalStructurePersistence.filterFindByGroupId(groupIds);
094            }
095    
096            public List<JournalStructure> search(
097                            long companyId, long[] groupIds, String keywords, int start,
098                            int end, OrderByComparator obc)
099                    throws SystemException {
100    
101                    return journalStructureFinder.filterFindByKeywords(
102                            companyId, groupIds, keywords, start, end, obc);
103            }
104    
105            public List<JournalStructure> search(
106                            long companyId, long[] groupIds, String structureId, String name,
107                            String description, boolean andOperator, int start, int end,
108                            OrderByComparator obc)
109                    throws SystemException {
110    
111                    return journalStructureFinder.filterFindByC_G_S_N_D(
112                            companyId, groupIds, structureId, name, description, andOperator,
113                            start, end, obc);
114            }
115    
116            public int searchCount(long companyId, long[] groupIds, String keywords)
117                    throws SystemException {
118    
119                    return journalStructureFinder.filterCountByKeywords(
120                            companyId, groupIds, keywords);
121            }
122    
123            public int searchCount(
124                            long companyId, long[] groupIds, String structureId, String name,
125                            String description, boolean andOperator)
126                    throws SystemException {
127    
128                    return journalStructureFinder.filterCountByC_G_S_N_D(
129                            companyId, groupIds, structureId, name, description, andOperator);
130            }
131    
132            public JournalStructure updateStructure(
133                            long groupId, String structureId, String parentStructureId,
134                            Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
135                            String xsd, ServiceContext serviceContext)
136                    throws PortalException, SystemException {
137    
138                    JournalStructurePermission.check(
139                            getPermissionChecker(), groupId, structureId, ActionKeys.UPDATE);
140    
141                    return journalStructureLocalService.updateStructure(
142                            groupId, structureId, parentStructureId, nameMap, descriptionMap,
143                            xsd, serviceContext);
144            }
145    
146    }