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