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