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.portal.service.permission.PortletPermissionUtil;
29  import com.liferay.portal.util.PortletKeys;
30  import com.liferay.portlet.softwarecatalog.model.SCProductEntry;
31  import com.liferay.portlet.softwarecatalog.service.base.SCProductEntryServiceBaseImpl;
32  import com.liferay.portlet.softwarecatalog.service.permission.SCProductEntryPermission;
33  
34  import java.util.List;
35  
36  /**
37   * <a href="SCProductEntryServiceImpl.java.html"><b><i>View Source</i></b></a>
38   *
39   * @author Jorge Ferrer
40   * @author Brian Wing Shun Chan
41   *
42   */
43  public class SCProductEntryServiceImpl extends SCProductEntryServiceBaseImpl {
44  
45      public SCProductEntry addProductEntry(
46              long plid, String name, String type, String tags,
47              String shortDescription, String longDescription, String pageURL,
48              String author, String repoGroupId, String repoArtifactId,
49              long[] licenseIds, List<byte[]> thumbnails, List<byte[]> fullImages,
50              boolean addCommunityPermissions, boolean addGuestPermissions)
51          throws PortalException, SystemException {
52  
53          PortletPermissionUtil.check(
54              getPermissionChecker(), plid, PortletKeys.SOFTWARE_CATALOG,
55              ActionKeys.ADD_PRODUCT_ENTRY);
56  
57          return scProductEntryLocalService.addProductEntry(
58              getUserId(), plid, name, type, tags, shortDescription,
59              longDescription, pageURL, author, repoGroupId, repoArtifactId,
60              licenseIds, thumbnails, fullImages, addCommunityPermissions,
61              addGuestPermissions);
62      }
63  
64      public SCProductEntry addProductEntry(
65              long plid, String name, String type, String tags,
66              String shortDescription, String longDescription, String pageURL,
67              String author, String repoGroupId, String repoArtifactId,
68              long[] licenseIds, List<byte[]> thumbnails, List<byte[]> fullImages,
69              String[] communityPermissions, String[] guestPermissions)
70          throws PortalException, SystemException {
71  
72          PortletPermissionUtil.check(
73              getPermissionChecker(), plid, PortletKeys.SOFTWARE_CATALOG,
74              ActionKeys.ADD_PRODUCT_ENTRY);
75  
76          return scProductEntryLocalService.addProductEntry(
77              getUserId(), plid, name, type, tags, shortDescription,
78              longDescription, pageURL, author, repoGroupId, repoArtifactId,
79              licenseIds, thumbnails, fullImages, communityPermissions,
80              guestPermissions);
81      }
82  
83      public void deleteProductEntry(long productEntryId)
84          throws PortalException, SystemException {
85  
86          SCProductEntryPermission.check(
87              getPermissionChecker(), productEntryId, ActionKeys.DELETE);
88  
89          scProductEntryLocalService.deleteProductEntry(productEntryId);
90      }
91  
92      public SCProductEntry getProductEntry(long productEntryId)
93          throws PortalException, SystemException {
94  
95          SCProductEntryPermission.check(
96              getPermissionChecker(), productEntryId, ActionKeys.VIEW);
97  
98          return scProductEntryLocalService.getProductEntry(productEntryId);
99      }
100 
101     public SCProductEntry updateProductEntry(
102             long productEntryId, String name, String type, String tags,
103             String shortDescription, String longDescription, String pageURL,
104             String author, String repoGroupId, String repoArtifactId,
105             long[] licenseIds, List<byte[]> thumbnails, List<byte[]> fullImages)
106         throws PortalException, SystemException {
107 
108         SCProductEntryPermission.check(
109             getPermissionChecker(), productEntryId, ActionKeys.UPDATE);
110 
111         return scProductEntryLocalService.updateProductEntry(
112             productEntryId, name, type, tags, shortDescription, longDescription,
113             pageURL, author, repoGroupId, repoArtifactId, licenseIds,
114             thumbnails, fullImages);
115     }
116 
117 }