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     * @author Brian Wing Shun Chan
031     * @author Marcellus Tavares
032     */
033    public class DDLRecordSetServiceImpl extends DDLRecordSetServiceBaseImpl {
034    
035            @Override
036            public DDLRecordSet addRecordSet(
037                            long groupId, long ddmStructureId, String recordSetKey,
038                            Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
039                            int minDisplayRows, int scope, ServiceContext serviceContext)
040                    throws PortalException, SystemException {
041    
042                    DDLPermission.check(
043                            getPermissionChecker(), groupId, ActionKeys.ADD_RECORD_SET);
044    
045                    return ddlRecordSetLocalService.addRecordSet(
046                            getUserId(), groupId, ddmStructureId, recordSetKey, nameMap,
047                            descriptionMap, minDisplayRows, scope, serviceContext);
048            }
049    
050            @Override
051            public void deleteRecordSet(long recordSetId)
052                    throws PortalException, SystemException {
053    
054                    DDLRecordSetPermission.check(
055                            getPermissionChecker(), recordSetId, ActionKeys.DELETE);
056    
057                    ddlRecordSetLocalService.deleteRecordSet(recordSetId);
058            }
059    
060            @Override
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            @Override
071            public DDLRecordSet updateMinDisplayRows(
072                            long recordSetId, int minDisplayRows, ServiceContext serviceContext)
073                    throws PortalException, SystemException {
074    
075                    DDLRecordSetPermission.check(
076                            getPermissionChecker(), recordSetId, ActionKeys.UPDATE);
077    
078                    return ddlRecordSetLocalService.updateMinDisplayRows(
079                            recordSetId, minDisplayRows, serviceContext);
080            }
081    
082            @Override
083            public DDLRecordSet updateRecordSet(
084                            long recordSetId, long ddmStructureId, Map<Locale, String> nameMap,
085                            Map<Locale, String> descriptionMap, int minDisplayRows,
086                            ServiceContext serviceContext)
087                    throws PortalException, SystemException {
088    
089                    DDLRecordSetPermission.check(
090                            getPermissionChecker(), recordSetId, ActionKeys.UPDATE);
091    
092                    return ddlRecordSetLocalService.updateRecordSet(
093                            recordSetId, ddmStructureId, nameMap, descriptionMap,
094                            minDisplayRows, serviceContext);
095            }
096    
097            @Override
098            public DDLRecordSet updateRecordSet(
099                            long groupId, long ddmStructureId, String recordSetKey,
100                            Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
101                            int minDisplayRows, ServiceContext serviceContext)
102                    throws PortalException, SystemException {
103    
104                    DDLRecordSetPermission.check(
105                            getPermissionChecker(), groupId, recordSetKey, ActionKeys.UPDATE);
106    
107                    return ddlRecordSetLocalService.updateRecordSet(
108                            groupId, ddmStructureId, recordSetKey, nameMap, descriptionMap,
109                            minDisplayRows, serviceContext);
110            }
111    
112    }