001    /**
002     * Copyright (c) 2000-2013 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.documentlibrary.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.portlet.documentlibrary.model.DLFileVersion;
021    import com.liferay.portlet.documentlibrary.service.base.DLFileVersionServiceBaseImpl;
022    import com.liferay.portlet.documentlibrary.service.permission.DLFileEntryPermission;
023    
024    import java.util.List;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class DLFileVersionServiceImpl extends DLFileVersionServiceBaseImpl {
030    
031            @Override
032            public DLFileVersion getFileVersion(long fileVersionId)
033                    throws PortalException, SystemException {
034    
035                    DLFileVersion fileVersion = dlFileVersionLocalService.getFileVersion(
036                            fileVersionId);
037    
038                    DLFileEntryPermission.check(
039                            getPermissionChecker(), fileVersion.getFileEntryId(),
040                            ActionKeys.VIEW);
041    
042                    return fileVersion;
043            }
044    
045            @Override
046            public List<DLFileVersion> getFileVersions(long fileEntryId, int status)
047                    throws PortalException, SystemException {
048    
049                    DLFileEntryPermission.check(
050                            getPermissionChecker(), fileEntryId, ActionKeys.VIEW);
051    
052                    return dlFileVersionLocalService.getFileVersions(fileEntryId, status);
053            }
054    
055            @Override
056            public int getFileVersionsCount(long fileEntryId, int status)
057                    throws PortalException, SystemException {
058    
059                    DLFileEntryPermission.check(
060                            getPermissionChecker(), fileEntryId, ActionKeys.VIEW);
061    
062                    return dlFileVersionPersistence.countByF_S(fileEntryId, status);
063            }
064    
065            @Override
066            public DLFileVersion getLatestFileVersion(long fileEntryId)
067                    throws PortalException, SystemException {
068    
069                    DLFileEntryPermission.check(
070                            getPermissionChecker(), fileEntryId, ActionKeys.VIEW);
071    
072                    return dlFileVersionLocalService.getLatestFileVersion(
073                            getGuestOrUserId(), fileEntryId);
074            }
075    
076    }