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