1   /**
2    * Copyright (c) 2000-2008 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.portlet.softwarecatalog.model.SCProductVersion;
29  import com.liferay.portlet.softwarecatalog.service.base.SCProductVersionServiceBaseImpl;
30  import com.liferay.portlet.softwarecatalog.service.permission.SCProductEntryPermission;
31  
32  import java.util.List;
33  
34  /**
35   * <a href="SCProductVersionServiceImpl.java.html"><b><i>View Source</i></b></a>
36   *
37   * @author Jorge Ferrer
38   * @author Brian Wing Shun Chan
39   *
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 repoStoreArtifact, long[] frameworkVersionIds,
48              boolean addCommunityPermissions, boolean addGuestPermissions)
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, repoStoreArtifact, frameworkVersionIds,
57              addCommunityPermissions, addGuestPermissions);
58      }
59  
60      public SCProductVersion addProductVersion(
61              long productEntryId, String version, String changeLog,
62              String downloadPageURL, String directDownloadURL,
63              boolean repoStoreArtifact, long[] frameworkVersionIds,
64              String[] communityPermissions, String[] guestPermissions)
65          throws PortalException, SystemException {
66  
67          SCProductEntryPermission.check(
68              getPermissionChecker(), productEntryId, ActionKeys.UPDATE);
69  
70          return scProductVersionLocalService.addProductVersion(
71              getUserId(), productEntryId, version, changeLog, downloadPageURL,
72              directDownloadURL, repoStoreArtifact, frameworkVersionIds,
73              communityPermissions, guestPermissions);
74      }
75  
76      public void deleteProductVersion(long productVersionId)
77          throws PortalException, SystemException {
78  
79          SCProductVersion productVersion =
80              scProductVersionLocalService.getProductVersion(productVersionId);
81  
82          SCProductEntryPermission.check(
83              getPermissionChecker(), productVersion.getProductEntryId(),
84              ActionKeys.UPDATE);
85  
86          scProductVersionLocalService.deleteProductVersion(productVersionId);
87      }
88  
89      public SCProductVersion getProductVersion(long productVersionId)
90          throws PortalException, SystemException {
91  
92          SCProductVersion productVersion =
93              scProductVersionLocalService.getProductVersion(productVersionId);
94  
95          SCProductEntryPermission.check(
96              getPermissionChecker(), productVersion.getProductEntryId(),
97              ActionKeys.VIEW);
98  
99          return productVersion;
100     }
101 
102     public List<SCProductVersion> getProductVersions(
103             long productEntryId, int begin, int end)
104         throws SystemException, PortalException {
105 
106         SCProductEntryPermission.check(
107             getPermissionChecker(), productEntryId, ActionKeys.VIEW);
108 
109         return scProductVersionLocalService.getProductVersions(
110             productEntryId, begin, end);
111     }
112 
113     public int getProductVersionsCount(long productEntryId)
114         throws SystemException, PortalException {
115 
116         SCProductEntryPermission.check(
117             getPermissionChecker(), productEntryId, ActionKeys.VIEW);
118 
119         return scProductVersionLocalService.getProductVersionsCount(
120             productEntryId);
121     }
122 
123     public SCProductVersion updateProductVersion(
124             long productVersionId, String version, String changeLog,
125             String downloadPageURL, String directDownloadURL,
126             boolean repoStoreArtifact, long[] frameworkVersionIds)
127         throws PortalException, SystemException {
128 
129         SCProductVersion productVersion =
130             scProductVersionLocalService.getProductVersion(productVersionId);
131 
132         SCProductEntryPermission.check(
133             getPermissionChecker(), productVersion.getProductEntryId(),
134             ActionKeys.UPDATE);
135 
136         return scProductVersionLocalService.updateProductVersion(
137             productVersionId, version, changeLog, downloadPageURL,
138             directDownloadURL, repoStoreArtifact, frameworkVersionIds);
139     }
140 
141 }