001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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.DDLRecord;
022    import com.liferay.portlet.dynamicdatalists.service.base.DDLRecordServiceBaseImpl;
023    import com.liferay.portlet.dynamicdatalists.service.permission.DDLRecordSetPermission;
024    import com.liferay.portlet.dynamicdatamapping.storage.Fields;
025    
026    import java.io.Serializable;
027    
028    import java.util.Map;
029    
030    /**
031     * @author Brian Wing Shun Chan
032     * @author Eduardo Lundgren
033     */
034    public class DDLRecordServiceImpl extends DDLRecordServiceBaseImpl {
035    
036            public DDLRecord addRecord(
037                            long groupId, long recordSetId, int displayIndex, Fields fields,
038                            ServiceContext serviceContext)
039                    throws PortalException, SystemException {
040    
041                    DDLRecordSetPermission.check(
042                            getPermissionChecker(), recordSetId, ActionKeys.ADD_RECORD);
043    
044                    return ddlRecordLocalService.addRecord(
045                            getGuestOrUserId(), groupId, recordSetId, displayIndex, fields,
046                            serviceContext);
047            }
048    
049            public DDLRecord addRecord(
050                            long groupId, long recordSetId, int displayIndex,
051                            Map<String, Serializable> fieldsMap, ServiceContext serviceContext)
052                    throws PortalException, SystemException {
053    
054                    DDLRecordSetPermission.check(
055                            getPermissionChecker(), recordSetId, ActionKeys.ADD_RECORD);
056    
057                    return ddlRecordLocalService.addRecord(
058                            getGuestOrUserId(), groupId, recordSetId, displayIndex, fieldsMap,
059                            serviceContext);
060            }
061    
062            public DDLRecord getRecord(long recordId)
063                    throws PortalException, SystemException {
064    
065                    DDLRecord record = ddlRecordLocalService.getDDLRecord(recordId);
066    
067                    DDLRecordSetPermission.check(
068                            getPermissionChecker(), record.getRecordSetId(), ActionKeys.VIEW);
069    
070                    return record;
071            }
072    
073            public DDLRecord updateRecord(
074                            long recordId, boolean majorVersion, int displayIndex,
075                            Fields fields, boolean mergeFields, ServiceContext serviceContext)
076                    throws PortalException, SystemException {
077    
078                    DDLRecord record = ddlRecordLocalService.getDDLRecord(recordId);
079    
080                    DDLRecordSetPermission.check(
081                            getPermissionChecker(), record.getRecordSetId(), ActionKeys.UPDATE);
082    
083                    return ddlRecordLocalService.updateRecord(
084                            getUserId(), recordId, majorVersion, displayIndex, fields,
085                            mergeFields, serviceContext);
086            }
087    
088            public DDLRecord updateRecord(
089                            long recordId, int displayIndex,
090                            Map<String, Serializable> fieldsMap, boolean mergeFields,
091                            ServiceContext serviceContext)
092                    throws PortalException, SystemException {
093    
094                    DDLRecord record = ddlRecordLocalService.getDDLRecord(recordId);
095    
096                    DDLRecordSetPermission.check(
097                            getPermissionChecker(), record.getRecordSetId(), ActionKeys.UPDATE);
098    
099                    return ddlRecordLocalService.updateRecord(
100                            getUserId(), recordId, displayIndex, fieldsMap, mergeFields,
101                            serviceContext);
102            }
103    
104    }