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   */
46  public class ShoppingItemServiceImpl extends ShoppingItemServiceBaseImpl {
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          shoppingItemLocalService.addBookItems(getUserId(), categoryId, isbns);
55      }
56  
57      public ShoppingItem addItem(
58              long categoryId, String sku, String name, String description,
59              String properties, String fieldsQuantities,
60              boolean requiresShipping, int stockQuantity, boolean featured,
61              Boolean sale, boolean smallImage, String smallImageURL,
62              File smallFile, boolean mediumImage, String mediumImageURL,
63              File mediumFile, boolean largeImage, String largeImageURL,
64              File largeFile, List<ShoppingItemField> itemFields,
65              List<ShoppingItemPrice> itemPrices, ServiceContext serviceContext)
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, serviceContext);
77      }
78  
79      public void deleteItem(long itemId)
80          throws PortalException, SystemException {
81  
82          ShoppingItemPermission.check(
83              getPermissionChecker(), itemId, ActionKeys.DELETE);
84  
85          shoppingItemLocalService.deleteItem(itemId);
86      }
87  
88      public ShoppingItem getItem(long itemId)
89          throws PortalException, SystemException {
90  
91          ShoppingItemPermission.check(
92              getPermissionChecker(), itemId, ActionKeys.VIEW);
93  
94          return shoppingItemLocalService.getItem(itemId);
95      }
96  
97      public ShoppingItem updateItem(
98              long itemId, long categoryId, String sku, String name,
99              String description, String properties, String fieldsQuantities,
100             boolean requiresShipping, int stockQuantity, boolean featured,
101             Boolean sale, boolean smallImage, String smallImageURL,
102             File smallFile, boolean mediumImage, String mediumImageURL,
103             File mediumFile, boolean largeImage, String largeImageURL,
104             File largeFile, List<ShoppingItemField> itemFields,
105             List<ShoppingItemPrice> itemPrices, ServiceContext serviceContext)
106         throws PortalException, SystemException {
107 
108         ShoppingItemPermission.check(
109             getPermissionChecker(), itemId, ActionKeys.UPDATE);
110 
111         return shoppingItemLocalService.updateItem(
112             getUserId(), itemId, categoryId, sku, name, description, properties,
113             fieldsQuantities, requiresShipping, stockQuantity, featured, sale,
114             smallImage, smallImageURL, smallFile, mediumImage, mediumImageURL,
115             mediumFile, largeImage, largeImageURL, largeFile, itemFields,
116             itemPrices, serviceContext);
117     }
118 
119 }