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.security.permission.ActionKeys;
28  import com.liferay.portlet.shopping.model.ShoppingItem;
29  import com.liferay.portlet.shopping.model.ShoppingItemField;
30  import com.liferay.portlet.shopping.model.ShoppingItemPrice;
31  import com.liferay.portlet.shopping.service.base.ShoppingItemServiceBaseImpl;
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 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, boolean addCommunityPermissions,
65              boolean addGuestPermissions)
66          throws PortalException, SystemException {
67  
68          ShoppingCategoryPermission.check(
69              getPermissionChecker(), categoryId, ActionKeys.ADD_ITEM);
70  
71          return shoppingItemLocalService.addItem(
72              getUserId(), categoryId, sku, name, description, properties,
73              fieldsQuantities, requiresShipping, stockQuantity, featured, sale,
74              smallImage, smallImageURL, smallFile, mediumImage, mediumImageURL,
75              mediumFile, largeImage, largeImageURL, largeFile, itemFields,
76              itemPrices, addCommunityPermissions, addGuestPermissions);
77      }
78  
79      public ShoppingItem addItem(
80              long categoryId, String sku, String name, String description,
81              String properties, String fieldsQuantities,
82              boolean requiresShipping, int stockQuantity, boolean featured,
83              Boolean sale, boolean smallImage, String smallImageURL,
84              File smallFile, boolean mediumImage, String mediumImageURL,
85              File mediumFile, boolean largeImage, String largeImageURL,
86              File largeFile, List<ShoppingItemField> itemFields,
87              List<ShoppingItemPrice> itemPrices, String[] communityPermissions,
88              String[] guestPermissions)
89          throws PortalException, SystemException {
90  
91          ShoppingCategoryPermission.check(
92              getPermissionChecker(), categoryId, ActionKeys.ADD_ITEM);
93  
94          return shoppingItemLocalService.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         shoppingItemLocalService.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 shoppingItemLocalService.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<ShoppingItemField> itemFields,
128             List<ShoppingItemPrice> itemPrices)
129         throws PortalException, SystemException {
130 
131         ShoppingItemPermission.check(
132             getPermissionChecker(), itemId, ActionKeys.UPDATE);
133 
134         return shoppingItemLocalService.updateItem(
135             getUserId(), itemId, categoryId, sku, name, description, properties,
136             fieldsQuantities, requiresShipping, stockQuantity, featured, sale,
137             smallImage, smallImageURL, smallFile, mediumImage, mediumImageURL,
138             mediumFile, largeImage, largeImageURL, largeFile, itemFields,
139             itemPrices);
140     }
141 
142 }