1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.softwarecatalog.service.impl;
16  
17  import com.liferay.portal.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.security.permission.ActionKeys;
20  import com.liferay.portal.service.ServiceContext;
21  import com.liferay.portlet.softwarecatalog.model.SCProductEntry;
22  import com.liferay.portlet.softwarecatalog.service.base.SCProductEntryServiceBaseImpl;
23  import com.liferay.portlet.softwarecatalog.service.permission.SCPermission;
24  import com.liferay.portlet.softwarecatalog.service.permission.SCProductEntryPermission;
25  
26  import java.util.List;
27  
28  /**
29   * <a href="SCProductEntryServiceImpl.java.html"><b><i>View Source</i></b></a>
30   *
31   * @author Jorge Ferrer
32   * @author Brian Wing Shun Chan
33   */
34  public class SCProductEntryServiceImpl extends SCProductEntryServiceBaseImpl {
35  
36      public SCProductEntry addProductEntry(
37              String name, String type, String tags, String shortDescription,
38              String longDescription, String pageURL, String author,
39              String repoGroupId, String repoArtifactId, long[] licenseIds,
40              List<byte[]> thumbnails, List<byte[]> fullImages,
41              ServiceContext serviceContext)
42          throws PortalException, SystemException {
43  
44          SCPermission.check(
45              getPermissionChecker(), serviceContext.getScopeGroupId(),
46              ActionKeys.ADD_PRODUCT_ENTRY);
47  
48          return scProductEntryLocalService.addProductEntry(
49              getUserId(), name, type, tags, shortDescription,
50              longDescription, pageURL, author, repoGroupId, repoArtifactId,
51              licenseIds, thumbnails, fullImages, serviceContext);
52      }
53  
54      public void deleteProductEntry(long productEntryId)
55          throws PortalException, SystemException {
56  
57          SCProductEntryPermission.check(
58              getPermissionChecker(), productEntryId, ActionKeys.DELETE);
59  
60          scProductEntryLocalService.deleteProductEntry(productEntryId);
61      }
62  
63      public SCProductEntry getProductEntry(long productEntryId)
64          throws PortalException, SystemException {
65  
66          SCProductEntryPermission.check(
67              getPermissionChecker(), productEntryId, ActionKeys.VIEW);
68  
69          return scProductEntryLocalService.getProductEntry(productEntryId);
70      }
71  
72      public SCProductEntry updateProductEntry(
73              long productEntryId, String name, String type, String tags,
74              String shortDescription, String longDescription, String pageURL,
75              String author, String repoGroupId, String repoArtifactId,
76              long[] licenseIds, List<byte[]> thumbnails, List<byte[]> fullImages)
77          throws PortalException, SystemException {
78  
79          SCProductEntryPermission.check(
80              getPermissionChecker(), productEntryId, ActionKeys.UPDATE);
81  
82          return scProductEntryLocalService.updateProductEntry(
83              productEntryId, name, type, tags, shortDescription, longDescription,
84              pageURL, author, repoGroupId, repoArtifactId, licenseIds,
85              thumbnails, fullImages);
86      }
87  
88  }