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