001    /**
002     * Copyright (c) 2000-present 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.util.OrderByComparator;
019    import com.liferay.portal.security.permission.ActionKeys;
020    import com.liferay.portlet.dynamicdatalists.model.DDLRecordVersion;
021    import com.liferay.portlet.dynamicdatalists.service.base.DDLRecordVersionServiceBaseImpl;
022    import com.liferay.portlet.dynamicdatalists.service.permission.DDLRecordPermission;
023    
024    import java.util.List;
025    
026    /**
027     * @author Marcellus Tavares
028     */
029    public class DDLRecordVersionServiceImpl
030            extends DDLRecordVersionServiceBaseImpl {
031    
032            @Override
033            public DDLRecordVersion getRecordVersion(long recordVersionId)
034                    throws PortalException {
035    
036                    DDLRecordVersion recordVersion =
037                            ddlRecordVersionLocalService.getRecordVersion(recordVersionId);
038    
039                    DDLRecordPermission.check(
040                            getPermissionChecker(), recordVersion.getRecordId(),
041                            ActionKeys.VIEW);
042    
043                    return recordVersion;
044            }
045    
046            @Override
047            public DDLRecordVersion getRecordVersion(long recordId, String version)
048                    throws PortalException {
049    
050                    DDLRecordPermission.check(
051                            getPermissionChecker(), recordId, ActionKeys.VIEW);
052    
053                    return ddlRecordVersionPersistence.findByR_V(recordId, version);
054            }
055    
056            @Override
057            public List<DDLRecordVersion> getRecordVersions(
058                            long recordId, int start, int end,
059                            OrderByComparator<DDLRecordVersion> orderByComparator)
060                    throws PortalException {
061    
062                    DDLRecordPermission.check(
063                            getPermissionChecker(), recordId, ActionKeys.VIEW);
064    
065                    return ddlRecordVersionPersistence.findByRecordId(
066                            recordId, start, end, orderByComparator);
067            }
068    
069            @Override
070            public int getRecordVersionsCount(long recordId) throws PortalException {
071                    DDLRecordPermission.check(
072                            getPermissionChecker(), recordId, ActionKeys.VIEW);
073    
074                    return ddlRecordVersionPersistence.countByRecordId(recordId);
075            }
076    
077    }