1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portlet.shopping.service.impl;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.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 categoryId, String[] isbns)
40          throws PortalException, SystemException {
41  
42          ShoppingCategoryPermission.check(
43              getPermissionChecker(), categoryId, ActionKeys.ADD_ITEM);
44  
45          shoppingItemLocalService.addBookItems(getUserId(), categoryId, isbns);
46      }
47  
48      public ShoppingItem addItem(
49              long categoryId, String sku, String name, String description,
50              String properties, String fieldsQuantities,
51              boolean requiresShipping, int stockQuantity, boolean featured,
52              Boolean sale, boolean smallImage, String smallImageURL,
53              File smallFile, boolean mediumImage, String mediumImageURL,
54              File mediumFile, boolean largeImage, String largeImageURL,
55              File largeFile, List<ShoppingItemField> itemFields,
56              List<ShoppingItemPrice> itemPrices, ServiceContext serviceContext)
57          throws PortalException, SystemException {
58  
59          ShoppingCategoryPermission.check(
60              getPermissionChecker(), categoryId, ActionKeys.ADD_ITEM);
61  
62          return shoppingItemLocalService.addItem(
63              getUserId(), categoryId, sku, name, description, properties,
64              fieldsQuantities, requiresShipping, stockQuantity, featured, sale,
65              smallImage, smallImageURL, smallFile, mediumImage, mediumImageURL,
66              mediumFile, largeImage, largeImageURL, largeFile, itemFields,
67              itemPrices, serviceContext);
68      }
69  
70      public void deleteItem(long itemId)
71          throws PortalException, SystemException {
72  
73          ShoppingItemPermission.check(
74              getPermissionChecker(), itemId, ActionKeys.DELETE);
75  
76          shoppingItemLocalService.deleteItem(itemId);
77      }
78  
79      public ShoppingItem getItem(long itemId)
80          throws PortalException, SystemException {
81  
82          ShoppingItemPermission.check(
83              getPermissionChecker(), itemId, ActionKeys.VIEW);
84  
85          return shoppingItemLocalService.getItem(itemId);
86      }
87  
88      public ShoppingItem updateItem(
89              long itemId, long categoryId, String sku, String name,
90              String description, String properties, String fieldsQuantities,
91              boolean requiresShipping, int stockQuantity, boolean featured,
92              Boolean sale, boolean smallImage, String smallImageURL,
93              File smallFile, boolean mediumImage, String mediumImageURL,
94              File mediumFile, boolean largeImage, String largeImageURL,
95              File largeFile, List<ShoppingItemField> itemFields,
96              List<ShoppingItemPrice> itemPrices, ServiceContext serviceContext)
97          throws PortalException, SystemException {
98  
99          ShoppingItemPermission.check(
100             getPermissionChecker(), itemId, ActionKeys.UPDATE);
101 
102         return shoppingItemLocalService.updateItem(
103             getUserId(), itemId, categoryId, sku, name, description, properties,
104             fieldsQuantities, requiresShipping, stockQuantity, featured, sale,
105             smallImage, smallImageURL, smallFile, mediumImage, mediumImageURL,
106             mediumFile, largeImage, largeImageURL, largeFile, itemFields,
107             itemPrices, serviceContext);
108     }
109 
110 }