1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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.security.permission.ActionKeys;
28  import com.liferay.portal.service.ServiceContext;
29  import com.liferay.portlet.shopping.model.ShoppingItem;
30  import com.liferay.portlet.shopping.model.ShoppingItemField;
31  import com.liferay.portlet.shopping.model.ShoppingItemPrice;
32  import com.liferay.portlet.shopping.service.base.ShoppingItemServiceBaseImpl;
33  import com.liferay.portlet.shopping.service.permission.ShoppingCategoryPermission;
34  import com.liferay.portlet.shopping.service.permission.ShoppingItemPermission;
35  
36  import java.io.File;
37  
38  import java.util.List;
39  
40  /**
41   * <a href="ShoppingItemServiceImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * @author Brian Wing Shun Chan
44   */
45  public class ShoppingItemServiceImpl extends ShoppingItemServiceBaseImpl {
46  
47      public void addBookItems(long categoryId, String[] isbns)
48          throws PortalException, SystemException {
49  
50          ShoppingCategoryPermission.check(
51              getPermissionChecker(), categoryId, ActionKeys.ADD_ITEM);
52  
53          shoppingItemLocalService.addBookItems(getUserId(), categoryId, isbns);
54      }
55  
56      public ShoppingItem addItem(
57              long categoryId, String sku, String name, String description,
58              String properties, String fieldsQuantities,
59              boolean requiresShipping, int stockQuantity, boolean featured,
60              Boolean sale, boolean smallImage, String smallImageURL,
61              File smallFile, boolean mediumImage, String mediumImageURL,
62              File mediumFile, boolean largeImage, String largeImageURL,
63              File largeFile, List<ShoppingItemField> itemFields,
64              List<ShoppingItemPrice> itemPrices, ServiceContext serviceContext)
65          throws PortalException, SystemException {
66  
67          ShoppingCategoryPermission.check(
68              getPermissionChecker(), categoryId, ActionKeys.ADD_ITEM);
69  
70          return shoppingItemLocalService.addItem(
71              getUserId(), categoryId, sku, name, description, properties,
72              fieldsQuantities, requiresShipping, stockQuantity, featured, sale,
73              smallImage, smallImageURL, smallFile, mediumImage, mediumImageURL,
74              mediumFile, largeImage, largeImageURL, largeFile, itemFields,
75              itemPrices, serviceContext);
76      }
77  
78      public void deleteItem(long itemId)
79          throws PortalException, SystemException {
80  
81          ShoppingItemPermission.check(
82              getPermissionChecker(), itemId, ActionKeys.DELETE);
83  
84          shoppingItemLocalService.deleteItem(itemId);
85      }
86  
87      public ShoppingItem getItem(long itemId)
88          throws PortalException, SystemException {
89  
90          ShoppingItemPermission.check(
91              getPermissionChecker(), itemId, ActionKeys.VIEW);
92  
93          return shoppingItemLocalService.getItem(itemId);
94      }
95  
96      public ShoppingItem updateItem(
97              long itemId, long categoryId, String sku, String name,
98              String description, String properties, String fieldsQuantities,
99              boolean requiresShipping, int stockQuantity, boolean featured,
100             Boolean sale, boolean smallImage, String smallImageURL,
101             File smallFile, boolean mediumImage, String mediumImageURL,
102             File mediumFile, boolean largeImage, String largeImageURL,
103             File largeFile, List<ShoppingItemField> itemFields,
104             List<ShoppingItemPrice> itemPrices, ServiceContext serviceContext)
105         throws PortalException, SystemException {
106 
107         ShoppingItemPermission.check(
108             getPermissionChecker(), itemId, ActionKeys.UPDATE);
109 
110         return shoppingItemLocalService.updateItem(
111             getUserId(), itemId, categoryId, sku, name, description, properties,
112             fieldsQuantities, requiresShipping, stockQuantity, featured, sale,
113             smallImage, smallImageURL, smallFile, mediumImage, mediumImageURL,
114             mediumFile, largeImage, largeImageURL, largeFile, itemFields,
115             itemPrices, serviceContext);
116     }
117 
118 }