1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.softwarecatalog.service.impl;
24  
25  import com.liferay.portal.PortalException;
26  import com.liferay.portal.SystemException;
27  import com.liferay.portal.security.permission.ActionKeys;
28  import com.liferay.portal.service.ServiceContext;
29  import com.liferay.portlet.softwarecatalog.model.SCProductVersion;
30  import com.liferay.portlet.softwarecatalog.service.base.SCProductVersionServiceBaseImpl;
31  import com.liferay.portlet.softwarecatalog.service.permission.SCProductEntryPermission;
32  
33  import java.util.List;
34  
35  /**
36   * <a href="SCProductVersionServiceImpl.java.html"><b><i>View Source</i></b></a>
37   *
38   * @author Jorge Ferrer
39   * @author Brian Wing Shun Chan
40   */
41  public class SCProductVersionServiceImpl
42      extends SCProductVersionServiceBaseImpl {
43  
44      public SCProductVersion addProductVersion(
45              long productEntryId, String version, String changeLog,
46              String downloadPageURL, String directDownloadURL,
47              boolean testDirectDownloadURL, boolean repoStoreArtifact,
48              long[] frameworkVersionIds, ServiceContext serviceContext)
49          throws PortalException, SystemException {
50  
51          SCProductEntryPermission.check(
52              getPermissionChecker(), productEntryId, ActionKeys.UPDATE);
53  
54          return scProductVersionLocalService.addProductVersion(
55              getUserId(), productEntryId, version, changeLog, downloadPageURL,
56              directDownloadURL, testDirectDownloadURL, repoStoreArtifact,
57              frameworkVersionIds, serviceContext);
58      }
59  
60      public void deleteProductVersion(long productVersionId)
61          throws PortalException, SystemException {
62  
63          SCProductVersion productVersion =
64              scProductVersionLocalService.getProductVersion(productVersionId);
65  
66          SCProductEntryPermission.check(
67              getPermissionChecker(), productVersion.getProductEntryId(),
68              ActionKeys.UPDATE);
69  
70          scProductVersionLocalService.deleteProductVersion(productVersionId);
71      }
72  
73      public SCProductVersion getProductVersion(long productVersionId)
74          throws PortalException, SystemException {
75  
76          SCProductVersion productVersion =
77              scProductVersionLocalService.getProductVersion(productVersionId);
78  
79          SCProductEntryPermission.check(
80              getPermissionChecker(), productVersion.getProductEntryId(),
81              ActionKeys.VIEW);
82  
83          return productVersion;
84      }
85  
86      public List<SCProductVersion> getProductVersions(
87              long productEntryId, int start, int end)
88          throws SystemException, PortalException {
89  
90          SCProductEntryPermission.check(
91              getPermissionChecker(), productEntryId, ActionKeys.VIEW);
92  
93          return scProductVersionLocalService.getProductVersions(
94              productEntryId, start, end);
95      }
96  
97      public int getProductVersionsCount(long productEntryId)
98          throws SystemException, PortalException {
99  
100         SCProductEntryPermission.check(
101             getPermissionChecker(), productEntryId, ActionKeys.VIEW);
102 
103         return scProductVersionLocalService.getProductVersionsCount(
104             productEntryId);
105     }
106 
107     public SCProductVersion updateProductVersion(
108             long productVersionId, String version, String changeLog,
109             String downloadPageURL, String directDownloadURL,
110             boolean testDirectDownloadURL, boolean repoStoreArtifact,
111             long[] frameworkVersionIds)
112         throws PortalException, SystemException {
113 
114         SCProductVersion productVersion =
115             scProductVersionLocalService.getProductVersion(productVersionId);
116 
117         SCProductEntryPermission.check(
118             getPermissionChecker(), productVersion.getProductEntryId(),
119             ActionKeys.UPDATE);
120 
121         return scProductVersionLocalService.updateProductVersion(
122             productVersionId, version, changeLog, downloadPageURL,
123             directDownloadURL, testDirectDownloadURL, repoStoreArtifact,
124             frameworkVersionIds);
125     }
126 
127 }