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