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.softwarecatalog.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.softwarecatalog.model.SCProductVersion;
022    import com.liferay.portlet.softwarecatalog.service.base.SCProductVersionServiceBaseImpl;
023    import com.liferay.portlet.softwarecatalog.service.permission.SCProductEntryPermission;
024    
025    import java.util.List;
026    
027    /**
028     * @author Jorge Ferrer
029     * @author Brian Wing Shun Chan
030     */
031    public class SCProductVersionServiceImpl
032            extends SCProductVersionServiceBaseImpl {
033    
034            @Override
035            public SCProductVersion addProductVersion(
036                            long productEntryId, String version, String changeLog,
037                            String downloadPageURL, String directDownloadURL,
038                            boolean testDirectDownloadURL, boolean repoStoreArtifact,
039                            long[] frameworkVersionIds, ServiceContext serviceContext)
040                    throws PortalException, SystemException {
041    
042                    SCProductEntryPermission.check(
043                            getPermissionChecker(), productEntryId, ActionKeys.UPDATE);
044    
045                    return scProductVersionLocalService.addProductVersion(
046                            getUserId(), productEntryId, version, changeLog, downloadPageURL,
047                            directDownloadURL, testDirectDownloadURL, repoStoreArtifact,
048                            frameworkVersionIds, serviceContext);
049            }
050    
051            @Override
052            public void deleteProductVersion(long productVersionId)
053                    throws PortalException, SystemException {
054    
055                    SCProductVersion productVersion =
056                            scProductVersionLocalService.getProductVersion(productVersionId);
057    
058                    SCProductEntryPermission.check(
059                            getPermissionChecker(), productVersion.getProductEntryId(),
060                            ActionKeys.UPDATE);
061    
062                    scProductVersionLocalService.deleteProductVersion(productVersionId);
063            }
064    
065            @Override
066            public SCProductVersion getProductVersion(long productVersionId)
067                    throws PortalException, SystemException {
068    
069                    SCProductVersion productVersion =
070                            scProductVersionLocalService.getProductVersion(productVersionId);
071    
072                    SCProductEntryPermission.check(
073                            getPermissionChecker(), productVersion.getProductEntryId(),
074                            ActionKeys.VIEW);
075    
076                    return productVersion;
077            }
078    
079            @Override
080            public List<SCProductVersion> getProductVersions(
081                            long productEntryId, int start, int end)
082                    throws PortalException, SystemException {
083    
084                    SCProductEntryPermission.check(
085                            getPermissionChecker(), productEntryId, ActionKeys.VIEW);
086    
087                    return scProductVersionLocalService.getProductVersions(
088                            productEntryId, start, end);
089            }
090    
091            @Override
092            public int getProductVersionsCount(long productEntryId)
093                    throws PortalException, SystemException {
094    
095                    SCProductEntryPermission.check(
096                            getPermissionChecker(), productEntryId, ActionKeys.VIEW);
097    
098                    return scProductVersionLocalService.getProductVersionsCount(
099                            productEntryId);
100            }
101    
102            @Override
103            public SCProductVersion updateProductVersion(
104                            long productVersionId, String version, String changeLog,
105                            String downloadPageURL, String directDownloadURL,
106                            boolean testDirectDownloadURL, boolean repoStoreArtifact,
107                            long[] frameworkVersionIds)
108                    throws PortalException, SystemException {
109    
110                    SCProductVersion productVersion =
111                            scProductVersionLocalService.getProductVersion(productVersionId);
112    
113                    SCProductEntryPermission.check(
114                            getPermissionChecker(), productVersion.getProductEntryId(),
115                            ActionKeys.UPDATE);
116    
117                    return scProductVersionLocalService.updateProductVersion(
118                            productVersionId, version, changeLog, downloadPageURL,
119                            directDownloadURL, testDirectDownloadURL, repoStoreArtifact,
120                            frameworkVersionIds);
121            }
122    
123    }