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.shopping.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.shopping.model.ShoppingItem;
22  import com.liferay.portlet.shopping.model.ShoppingItemField;
23  import com.liferay.portlet.shopping.model.ShoppingItemPrice;
24  import com.liferay.portlet.shopping.service.base.ShoppingItemServiceBaseImpl;
25  import com.liferay.portlet.shopping.service.permission.ShoppingCategoryPermission;
26  import com.liferay.portlet.shopping.service.permission.ShoppingItemPermission;
27  
28  import java.io.File;
29  
30  import java.util.List;
31  
32  /**
33   * <a href="ShoppingItemServiceImpl.java.html"><b><i>View Source</i></b></a>
34   *
35   * @author Brian Wing Shun Chan
36   */
37  public class ShoppingItemServiceImpl extends ShoppingItemServiceBaseImpl {
38  
39      public void addBookItems(long groupId, long categoryId, String[] isbns)
40          throws PortalException, SystemException {
41  
42          ShoppingCategoryPermission.check(
43              getPermissionChecker(), groupId, categoryId, ActionKeys.ADD_ITEM);
44  
45          shoppingItemLocalService.addBookItems(
46              getUserId(), groupId, categoryId, isbns);
47      }
48  
49      public ShoppingItem addItem(
50              long groupId, long categoryId, String sku, String name,
51              String description, String properties, String fieldsQuantities,
52              boolean requiresShipping, int stockQuantity, boolean featured,
53              Boolean sale, boolean smallImage, String smallImageURL,
54              File smallFile, boolean mediumImage, String mediumImageURL,
55              File mediumFile, boolean largeImage, String largeImageURL,
56              File largeFile, List<ShoppingItemField> itemFields,
57              List<ShoppingItemPrice> itemPrices, ServiceContext serviceContext)
58          throws PortalException, SystemException {
59  
60          ShoppingCategoryPermission.check(
61              getPermissionChecker(), groupId, categoryId, ActionKeys.ADD_ITEM);
62  
63          return shoppingItemLocalService.addItem(
64              getUserId(), groupId, categoryId, sku, name, description,
65              properties, fieldsQuantities, requiresShipping, stockQuantity,
66              featured, sale, smallImage, smallImageURL, smallFile, mediumImage,
67              mediumImageURL, mediumFile, largeImage, largeImageURL, largeFile,
68              itemFields, itemPrices, serviceContext);
69      }
70  
71      public void deleteItem(long itemId)
72          throws PortalException, SystemException {
73  
74          ShoppingItemPermission.check(
75              getPermissionChecker(), itemId, ActionKeys.DELETE);
76  
77          shoppingItemLocalService.deleteItem(itemId);
78      }
79  
80      public ShoppingItem getItem(long itemId)
81          throws PortalException, SystemException {
82  
83          ShoppingItemPermission.check(
84              getPermissionChecker(), itemId, ActionKeys.VIEW);
85  
86          return shoppingItemLocalService.getItem(itemId);
87      }
88  
89      public ShoppingItem updateItem(
90              long itemId, long groupId, long categoryId, String sku, String name,
91              String description, String properties, String fieldsQuantities,
92              boolean requiresShipping, int stockQuantity, boolean featured,
93              Boolean sale, boolean smallImage, String smallImageURL,
94              File smallFile, boolean mediumImage, String mediumImageURL,
95              File mediumFile, boolean largeImage, String largeImageURL,
96              File largeFile, List<ShoppingItemField> itemFields,
97              List<ShoppingItemPrice> itemPrices, ServiceContext serviceContext)
98          throws PortalException, SystemException {
99  
100         ShoppingItemPermission.check(
101             getPermissionChecker(), itemId, ActionKeys.UPDATE);
102 
103         return shoppingItemLocalService.updateItem(
104             getUserId(), itemId, groupId, categoryId, sku, name, description,
105             properties, fieldsQuantities, requiresShipping, stockQuantity,
106             featured, sale, smallImage, smallImageURL, smallFile, mediumImage,
107             mediumImageURL, mediumFile, largeImage, largeImageURL, largeFile,
108             itemFields, itemPrices, serviceContext);
109     }
110 
111 }