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