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   */
42  public class SCProductVersionServiceImpl
43      extends SCProductVersionServiceBaseImpl {
44  
45      public SCProductVersion addProductVersion(
46              long productEntryId, String version, String changeLog,
47              String downloadPageURL, String directDownloadURL,
48              boolean testDirectDownloadURL, boolean repoStoreArtifact,
49              long[] frameworkVersionIds, ServiceContext serviceContext)
50          throws PortalException, SystemException {
51  
52          SCProductEntryPermission.check(
53              getPermissionChecker(), productEntryId, ActionKeys.UPDATE);
54  
55          return scProductVersionLocalService.addProductVersion(
56              getUserId(), productEntryId, version, changeLog, downloadPageURL,
57              directDownloadURL, testDirectDownloadURL, repoStoreArtifact,
58              frameworkVersionIds, serviceContext);
59      }
60  
61      public void deleteProductVersion(long productVersionId)
62          throws PortalException, SystemException {
63  
64          SCProductVersion productVersion =
65              scProductVersionLocalService.getProductVersion(productVersionId);
66  
67          SCProductEntryPermission.check(
68              getPermissionChecker(), productVersion.getProductEntryId(),
69              ActionKeys.UPDATE);
70  
71          scProductVersionLocalService.deleteProductVersion(productVersionId);
72      }
73  
74      public SCProductVersion getProductVersion(long productVersionId)
75          throws PortalException, SystemException {
76  
77          SCProductVersion productVersion =
78              scProductVersionLocalService.getProductVersion(productVersionId);
79  
80          SCProductEntryPermission.check(
81              getPermissionChecker(), productVersion.getProductEntryId(),
82              ActionKeys.VIEW);
83  
84          return productVersion;
85      }
86  
87      public List<SCProductVersion> getProductVersions(
88              long productEntryId, int start, int end)
89          throws SystemException, PortalException {
90  
91          SCProductEntryPermission.check(
92              getPermissionChecker(), productEntryId, ActionKeys.VIEW);
93  
94          return scProductVersionLocalService.getProductVersions(
95              productEntryId, start, end);
96      }
97  
98      public int getProductVersionsCount(long productEntryId)
99          throws SystemException, PortalException {
100 
101         SCProductEntryPermission.check(
102             getPermissionChecker(), productEntryId, ActionKeys.VIEW);
103 
104         return scProductVersionLocalService.getProductVersionsCount(
105             productEntryId);
106     }
107 
108     public SCProductVersion updateProductVersion(
109             long productVersionId, String version, String changeLog,
110             String downloadPageURL, String directDownloadURL,
111             boolean testDirectDownloadURL, boolean repoStoreArtifact,
112             long[] frameworkVersionIds)
113         throws PortalException, SystemException {
114 
115         SCProductVersion productVersion =
116             scProductVersionLocalService.getProductVersion(productVersionId);
117 
118         SCProductEntryPermission.check(
119             getPermissionChecker(), productVersion.getProductEntryId(),
120             ActionKeys.UPDATE);
121 
122         return scProductVersionLocalService.updateProductVersion(
123             productVersionId, version, changeLog, downloadPageURL,
124             directDownloadURL, testDirectDownloadURL, repoStoreArtifact,
125             frameworkVersionIds);
126     }
127 
128 }