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.dynamicdatamapping.service.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.exception.PortalException;
020    import com.liferay.portal.kernel.util.OrderByComparator;
021    import com.liferay.portal.security.permission.ActionKeys;
022    import com.liferay.portlet.dynamicdatamapping.model.DDMStructureVersion;
023    import com.liferay.portlet.dynamicdatamapping.service.base.DDMStructureVersionServiceBaseImpl;
024    import com.liferay.portlet.dynamicdatamapping.service.permission.DDMStructurePermission;
025    
026    import java.util.List;
027    
028    /**
029     * @author Pablo Carvalho
030     */
031    @ProviderType
032    public class DDMStructureVersionServiceImpl
033            extends DDMStructureVersionServiceBaseImpl {
034    
035            @Override
036            public DDMStructureVersion getLatestStructureVersion(long structureId)
037                    throws PortalException {
038    
039                    DDMStructurePermission.check(
040                            getPermissionChecker(), structureId, ActionKeys.VIEW);
041    
042                    return ddmStructureVersionLocalService.getLatestStructureVersion(
043                            structureId);
044            }
045    
046            @Override
047            public DDMStructureVersion getStructureVersion(long structureVersionId)
048                    throws PortalException {
049    
050                    DDMStructureVersion structureVersion =
051                            ddmStructureVersionLocalService.getStructureVersion(
052                                    structureVersionId);
053    
054                    DDMStructurePermission.check(
055                            getPermissionChecker(), structureVersion.getStructureId(),
056                            ActionKeys.VIEW);
057    
058                    return structureVersion;
059            }
060    
061            @Override
062            public List<DDMStructureVersion> getStructureVersions(
063                            long structureId, int start, int end,
064                            OrderByComparator<DDMStructureVersion> orderByComparator)
065                    throws PortalException {
066    
067                    DDMStructurePermission.check(
068                            getPermissionChecker(), structureId, ActionKeys.VIEW);
069    
070                    return ddmStructureVersionLocalService.getStructureVersions(
071                            structureId, start, end, orderByComparator);
072            }
073    
074            @Override
075            public int getStructureVersionsCount(long structureId)
076                    throws PortalException {
077    
078                    DDMStructurePermission.check(
079                            getPermissionChecker(), structureId, ActionKeys.VIEW);
080    
081                    return ddmStructureVersionLocalService.getStructureVersionsCount(
082                            structureId);
083            }
084    
085    }