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            public DDLRecordSet addRecordSet(
039                            long groupId, long ddmStructureId, String recordSetKey,
040                            Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
041                            int minDisplayRows, int scope, ServiceContext serviceContext)
042                    throws PortalException, SystemException {
043    
044                    DDLPermission.check(
045                            getPermissionChecker(), groupId, ActionKeys.ADD_RECORD_SET);
046    
047                    return ddlRecordSetLocalService.addRecordSet(
048                            getUserId(), groupId, ddmStructureId, recordSetKey, nameMap,
049                            descriptionMap, minDisplayRows, scope, serviceContext);
050            }
051    
052            public void deleteRecordSet(long recordSetId)
053                    throws PortalException, SystemException {
054    
055                    DDLRecordSetPermission.check(
056                            getPermissionChecker(), recordSetId, ActionKeys.DELETE);
057    
058                    ddlRecordSetLocalService.deleteRecordSet(recordSetId);
059            }
060    
061            public DDLRecordSet getRecordSet(long recordSetId)
062                    throws PortalException, SystemException {
063    
064                    DDLRecordSetPermission.check(
065                            getPermissionChecker(), recordSetId, ActionKeys.VIEW);
066    
067                    return ddlRecordSetLocalService.getRecordSet(recordSetId);
068            }
069    
070            public DDLRecordSet updateMinDisplayRows(
071                            long recordSetId, int minDisplayRows, ServiceContext serviceContext)
072                    throws PortalException, SystemException {
073    
074                    DDLRecordSetPermission.check(
075                            getPermissionChecker(), recordSetId, ActionKeys.UPDATE);
076    
077                    return ddlRecordSetLocalService.updateMinDisplayRows(
078                            recordSetId, minDisplayRows, serviceContext);
079            }
080    
081            public DDLRecordSet updateRecordSet(
082                            long recordSetId, long ddmStructureId, Map<Locale, String> nameMap,
083                            Map<Locale, String> descriptionMap, int minDisplayRows,
084                            ServiceContext serviceContext)
085                    throws PortalException, SystemException {
086    
087                    DDLRecordSetPermission.check(
088                            getPermissionChecker(), recordSetId, ActionKeys.UPDATE);
089    
090                    return ddlRecordSetLocalService.updateRecordSet(
091                            recordSetId, ddmStructureId, nameMap, descriptionMap,
092                            minDisplayRows, serviceContext);
093            }
094    
095            public DDLRecordSet updateRecordSet(
096                            long groupId, long ddmStructureId, String recordSetKey,
097                            Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
098                            int minDisplayRows, ServiceContext serviceContext)
099                    throws PortalException, SystemException {
100    
101                    DDLRecordSetPermission.check(
102                            getPermissionChecker(), groupId, recordSetKey, ActionKeys.UPDATE);
103    
104                    return ddlRecordSetLocalService.updateRecordSet(
105                            groupId, ddmStructureId, recordSetKey, nameMap, descriptionMap,
106                            minDisplayRows, serviceContext);
107            }
108    
109    }