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.dynamicdatalists.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.dynamicdatalists.model.DDLRecordSet;
023    import com.liferay.portlet.dynamicdatalists.service.base.DDLRecordSetServiceBaseImpl;
024    import com.liferay.portlet.dynamicdatalists.service.permission.DDLPermission;
025    import com.liferay.portlet.dynamicdatalists.service.permission.DDLRecordSetPermission;
026    
027    import java.util.List;
028    import java.util.Locale;
029    import java.util.Map;
030    
031    /**
032     * Provides the remote service for accessing, adding, deleting, and updating
033     * dynamic data list (DDL) record sets. Its methods include permission checks.
034     *
035     * @author Brian Wing Shun Chan
036     * @author Marcellus Tavares
037     */
038    public class DDLRecordSetServiceImpl extends DDLRecordSetServiceBaseImpl {
039    
040            @Override
041            public DDLRecordSet addRecordSet(
042                            long groupId, long ddmStructureId, String recordSetKey,
043                            Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
044                            int minDisplayRows, int scope, ServiceContext serviceContext)
045                    throws PortalException, SystemException {
046    
047                    DDLPermission.check(
048                            getPermissionChecker(), groupId, ActionKeys.ADD_RECORD_SET);
049    
050                    return ddlRecordSetLocalService.addRecordSet(
051                            getUserId(), groupId, ddmStructureId, recordSetKey, nameMap,
052                            descriptionMap, minDisplayRows, scope, serviceContext);
053            }
054    
055            @Override
056            public void deleteRecordSet(long recordSetId)
057                    throws PortalException, SystemException {
058    
059                    DDLRecordSetPermission.check(
060                            getPermissionChecker(), recordSetId, ActionKeys.DELETE);
061    
062                    ddlRecordSetLocalService.deleteRecordSet(recordSetId);
063            }
064    
065            @Override
066            public DDLRecordSet getRecordSet(long recordSetId)
067                    throws PortalException, SystemException {
068    
069                    DDLRecordSetPermission.check(
070                            getPermissionChecker(), recordSetId, ActionKeys.VIEW);
071    
072                    return ddlRecordSetLocalService.getRecordSet(recordSetId);
073            }
074    
075            @Override
076            public List<DDLRecordSet> search(
077                            long companyId, long groupId, String keywords, int scope, int start,
078                            int end, OrderByComparator orderByComparator)
079                    throws SystemException {
080    
081                    return ddlRecordSetFinder.filterFindByKeywords(
082                            companyId, groupId, keywords, scope, start, end, orderByComparator);
083            }
084    
085            @Override
086            public List<DDLRecordSet> search(
087                            long companyId, long groupId, String name, String description,
088                            int scope, boolean andOperator, int start, int end,
089                            OrderByComparator orderByComparator)
090                    throws SystemException {
091    
092                    return ddlRecordSetFinder.filterFindByC_G_N_D_S(
093                            companyId, groupId, name, description, scope, andOperator, start,
094                            end, orderByComparator);
095            }
096    
097            @Override
098            public int searchCount(
099                            long companyId, long groupId, String keywords, int scope)
100                    throws SystemException {
101    
102                    return ddlRecordSetFinder.filterCountByKeywords(
103                            companyId, groupId, keywords, scope);
104            }
105    
106            @Override
107            public int searchCount(
108                            long companyId, long groupId, String name, String description,
109                            int scope, boolean andOperator)
110                    throws SystemException {
111    
112                    return ddlRecordSetFinder.filterCountByC_G_N_D_S(
113                            companyId, groupId, name, description, scope, andOperator);
114            }
115    
116            @Override
117            public DDLRecordSet updateMinDisplayRows(
118                            long recordSetId, int minDisplayRows, ServiceContext serviceContext)
119                    throws PortalException, SystemException {
120    
121                    DDLRecordSetPermission.check(
122                            getPermissionChecker(), recordSetId, ActionKeys.UPDATE);
123    
124                    return ddlRecordSetLocalService.updateMinDisplayRows(
125                            recordSetId, minDisplayRows, serviceContext);
126            }
127    
128            @Override
129            public DDLRecordSet updateRecordSet(
130                            long recordSetId, long ddmStructureId, Map<Locale, String> nameMap,
131                            Map<Locale, String> descriptionMap, int minDisplayRows,
132                            ServiceContext serviceContext)
133                    throws PortalException, SystemException {
134    
135                    DDLRecordSetPermission.check(
136                            getPermissionChecker(), recordSetId, ActionKeys.UPDATE);
137    
138                    return ddlRecordSetLocalService.updateRecordSet(
139                            recordSetId, ddmStructureId, nameMap, descriptionMap,
140                            minDisplayRows, serviceContext);
141            }
142    
143            @Override
144            public DDLRecordSet updateRecordSet(
145                            long groupId, long ddmStructureId, String recordSetKey,
146                            Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
147                            int minDisplayRows, ServiceContext serviceContext)
148                    throws PortalException, SystemException {
149    
150                    DDLRecordSetPermission.check(
151                            getPermissionChecker(), groupId, recordSetKey, ActionKeys.UPDATE);
152    
153                    return ddlRecordSetLocalService.updateRecordSet(
154                            groupId, ddmStructureId, recordSetKey, nameMap, descriptionMap,
155                            minDisplayRows, serviceContext);
156            }
157    
158    }