1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.shopping.service.impl;
21  
22  import com.liferay.portal.PortalException;
23  import com.liferay.portal.SystemException;
24  import com.liferay.portal.security.permission.ActionKeys;
25  import com.liferay.portlet.shopping.model.ShoppingItem;
26  import com.liferay.portlet.shopping.model.ShoppingItemField;
27  import com.liferay.portlet.shopping.model.ShoppingItemPrice;
28  import com.liferay.portlet.shopping.service.base.ShoppingItemServiceBaseImpl;
29  import com.liferay.portlet.shopping.service.permission.ShoppingCategoryPermission;
30  import com.liferay.portlet.shopping.service.permission.ShoppingItemPermission;
31  
32  import java.io.File;
33  
34  import java.util.List;
35  
36  /**
37   * <a href="ShoppingItemServiceImpl.java.html"><b><i>View Source</i></b></a>
38   *
39   * @author Brian Wing Shun Chan
40   *
41   */
42  public class ShoppingItemServiceImpl extends ShoppingItemServiceBaseImpl {
43  
44      public void addBookItems(long categoryId, String[] isbns)
45          throws PortalException, SystemException {
46  
47          ShoppingCategoryPermission.check(
48              getPermissionChecker(), categoryId, ActionKeys.ADD_ITEM);
49  
50          shoppingItemLocalService.addBookItems(getUserId(), categoryId, isbns);
51      }
52  
53      public ShoppingItem addItem(
54              long categoryId, String sku, String name, String description,
55              String properties, String fieldsQuantities,
56              boolean requiresShipping, int stockQuantity, boolean featured,
57              Boolean sale, boolean smallImage, String smallImageURL,
58              File smallFile, boolean mediumImage, String mediumImageURL,
59              File mediumFile, boolean largeImage, String largeImageURL,
60              File largeFile, List<ShoppingItemField> itemFields,
61              List<ShoppingItemPrice> itemPrices, boolean addCommunityPermissions,
62              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<ShoppingItemField> itemFields,
84              List<ShoppingItemPrice> itemPrices, String[] communityPermissions,
85              String[] guestPermissions)
86          throws PortalException, SystemException {
87  
88          ShoppingCategoryPermission.check(
89              getPermissionChecker(), categoryId, ActionKeys.ADD_ITEM);
90  
91          return shoppingItemLocalService.addItem(
92              getUserId(), categoryId, sku, name, description, properties,
93              fieldsQuantities, requiresShipping, stockQuantity, featured, sale,
94              smallImage, smallImageURL, smallFile, mediumImage, mediumImageURL,
95              mediumFile, largeImage, largeImageURL, largeFile, itemFields,
96              itemPrices, communityPermissions, guestPermissions);
97      }
98  
99      public void deleteItem(long itemId)
100         throws PortalException, SystemException {
101 
102         ShoppingItemPermission.check(
103             getPermissionChecker(), itemId, ActionKeys.DELETE);
104 
105         shoppingItemLocalService.deleteItem(itemId);
106     }
107 
108     public ShoppingItem getItem(long itemId)
109         throws PortalException, SystemException {
110 
111         ShoppingItemPermission.check(
112             getPermissionChecker(), itemId, ActionKeys.VIEW);
113 
114         return shoppingItemLocalService.getItem(itemId);
115     }
116 
117     public ShoppingItem updateItem(
118             long itemId, long categoryId, String sku, String name,
119             String description, String properties, String fieldsQuantities,
120             boolean requiresShipping, int stockQuantity, boolean featured,
121             Boolean sale, boolean smallImage, String smallImageURL,
122             File smallFile, boolean mediumImage, String mediumImageURL,
123             File mediumFile, boolean largeImage, String largeImageURL,
124             File largeFile, List<ShoppingItemField> itemFields,
125             List<ShoppingItemPrice> itemPrices)
126         throws PortalException, SystemException {
127 
128         ShoppingItemPermission.check(
129             getPermissionChecker(), itemId, ActionKeys.UPDATE);
130 
131         return shoppingItemLocalService.updateItem(
132             getUserId(), itemId, categoryId, sku, name, description, properties,
133             fieldsQuantities, requiresShipping, stockQuantity, featured, sale,
134             smallImage, smallImageURL, smallFile, mediumImage, mediumImageURL,
135             mediumFile, largeImage, largeImageURL, largeFile, itemFields,
136             itemPrices);
137     }
138 
139 }