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.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.Locale;
027    import java.util.Map;
028    
029    /**
030     * Provides the remote service for accessing, adding, deleting, and updating
031     * dynamic data list (DDL) record sets. Its methods include permission checks.
032     *
033     * @author Brian Wing Shun Chan
034     * @author Marcellus Tavares
035     */
036    public class DDLRecordSetServiceImpl extends DDLRecordSetServiceBaseImpl {
037    
038            @Override
039            public DDLRecordSet addRecordSet(
040                            long groupId, long ddmStructureId, String recordSetKey,
041                            Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
042                            int minDisplayRows, int scope, ServiceContext serviceContext)
043                    throws PortalException, SystemException {
044    
045                    DDLPermission.check(
046                            getPermissionChecker(), groupId, ActionKeys.ADD_RECORD_SET);
047    
048                    return ddlRecordSetLocalService.addRecordSet(
049                            getUserId(), groupId, ddmStructureId, recordSetKey, nameMap,
050                            descriptionMap, minDisplayRows, scope, serviceContext);
051            }
052    
053            @Override
054            public void deleteRecordSet(long recordSetId)
055                    throws PortalException, SystemException {
056    
057                    DDLRecordSetPermission.check(
058                            getPermissionChecker(), recordSetId, ActionKeys.DELETE);
059    
060                    ddlRecordSetLocalService.deleteRecordSet(recordSetId);
061            }
062    
063            @Override
064            public DDLRecordSet getRecordSet(long recordSetId)
065                    throws PortalException, SystemException {
066    
067                    DDLRecordSetPermission.check(
068                            getPermissionChecker(), recordSetId, ActionKeys.VIEW);
069    
070                    return ddlRecordSetLocalService.getRecordSet(recordSetId);
071            }
072    
073            @Override
074            public DDLRecordSet updateMinDisplayRows(
075                            long recordSetId, int minDisplayRows, ServiceContext serviceContext)
076                    throws PortalException, SystemException {
077    
078                    DDLRecordSetPermission.check(
079                            getPermissionChecker(), recordSetId, ActionKeys.UPDATE);
080    
081                    return ddlRecordSetLocalService.updateMinDisplayRows(
082                            recordSetId, minDisplayRows, serviceContext);
083            }
084    
085            @Override
086            public DDLRecordSet updateRecordSet(
087                            long recordSetId, long ddmStructureId, Map<Locale, String> nameMap,
088                            Map<Locale, String> descriptionMap, int minDisplayRows,
089                            ServiceContext serviceContext)
090                    throws PortalException, SystemException {
091    
092                    DDLRecordSetPermission.check(
093                            getPermissionChecker(), recordSetId, ActionKeys.UPDATE);
094    
095                    return ddlRecordSetLocalService.updateRecordSet(
096                            recordSetId, ddmStructureId, nameMap, descriptionMap,
097                            minDisplayRows, serviceContext);
098            }
099    
100            @Override
101            public DDLRecordSet updateRecordSet(
102                            long groupId, long ddmStructureId, String recordSetKey,
103                            Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
104                            int minDisplayRows, ServiceContext serviceContext)
105                    throws PortalException, SystemException {
106    
107                    DDLRecordSetPermission.check(
108                            getPermissionChecker(), groupId, recordSetKey, ActionKeys.UPDATE);
109    
110                    return ddlRecordSetLocalService.updateRecordSet(
111                            groupId, ddmStructureId, recordSetKey, nameMap, descriptionMap,
112                            minDisplayRows, serviceContext);
113            }
114    
115    }