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.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  public class ShoppingItemServiceImpl extends ShoppingItemServiceBaseImpl {
45  
46      public void addBookItems(long categoryId, String[] isbns)
47          throws PortalException, SystemException {
48  
49          ShoppingCategoryPermission.check(
50              getPermissionChecker(), categoryId, ActionKeys.ADD_ITEM);
51  
52          shoppingItemLocalService.addBookItems(getUserId(), categoryId, isbns);
53      }
54  
55      public ShoppingItem addItem(
56              long categoryId, String sku, String name, String description,
57              String properties, String fieldsQuantities,
58              boolean requiresShipping, int stockQuantity, boolean featured,
59              Boolean sale, boolean smallImage, String smallImageURL,
60              File smallFile, boolean mediumImage, String mediumImageURL,
61              File mediumFile, boolean largeImage, String largeImageURL,
62              File largeFile, List<ShoppingItemField> itemFields,
63              List<ShoppingItemPrice> itemPrices, boolean addCommunityPermissions,
64              boolean addGuestPermissions)
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, addCommunityPermissions, addGuestPermissions);
76      }
77  
78      public ShoppingItem addItem(
79              long categoryId, String sku, String name, String description,
80              String properties, String fieldsQuantities,
81              boolean requiresShipping, int stockQuantity, boolean featured,
82              Boolean sale, boolean smallImage, String smallImageURL,
83              File smallFile, boolean mediumImage, String mediumImageURL,
84              File mediumFile, boolean largeImage, String largeImageURL,
85              File largeFile, List<ShoppingItemField> itemFields,
86              List<ShoppingItemPrice> itemPrices, String[] communityPermissions,
87              String[] guestPermissions)
88          throws PortalException, SystemException {
89  
90          ShoppingCategoryPermission.check(
91              getPermissionChecker(), categoryId, ActionKeys.ADD_ITEM);
92  
93          return shoppingItemLocalService.addItem(
94              getUserId(), categoryId, sku, name, description, properties,
95              fieldsQuantities, requiresShipping, stockQuantity, featured, sale,
96              smallImage, smallImageURL, smallFile, mediumImage, mediumImageURL,
97              mediumFile, largeImage, largeImageURL, largeFile, itemFields,
98              itemPrices, communityPermissions, guestPermissions);
99      }
100 
101     public void deleteItem(long itemId)
102         throws PortalException, SystemException {
103 
104         ShoppingItemPermission.check(
105             getPermissionChecker(), itemId, ActionKeys.DELETE);
106 
107         shoppingItemLocalService.deleteItem(itemId);
108     }
109 
110     public ShoppingItem getItem(long itemId)
111         throws PortalException, SystemException {
112 
113         ShoppingItemPermission.check(
114             getPermissionChecker(), itemId, ActionKeys.VIEW);
115 
116         return shoppingItemLocalService.getItem(itemId);
117     }
118 
119     public ShoppingItem updateItem(
120             long itemId, long categoryId, String sku, String name,
121             String description, String properties, String fieldsQuantities,
122             boolean requiresShipping, int stockQuantity, boolean featured,
123             Boolean sale, boolean smallImage, String smallImageURL,
124             File smallFile, boolean mediumImage, String mediumImageURL,
125             File mediumFile, boolean largeImage, String largeImageURL,
126             File largeFile, List<ShoppingItemField> itemFields,
127             List<ShoppingItemPrice> itemPrices)
128         throws PortalException, SystemException {
129 
130         ShoppingItemPermission.check(
131             getPermissionChecker(), itemId, ActionKeys.UPDATE);
132 
133         return shoppingItemLocalService.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 }