001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.shopping.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.security.permission.ActionKeys;
020    import com.liferay.portal.service.ServiceContext;
021    import com.liferay.portlet.shopping.model.ShoppingItem;
022    import com.liferay.portlet.shopping.model.ShoppingItemField;
023    import com.liferay.portlet.shopping.model.ShoppingItemPrice;
024    import com.liferay.portlet.shopping.service.base.ShoppingItemServiceBaseImpl;
025    import com.liferay.portlet.shopping.service.permission.ShoppingCategoryPermission;
026    import com.liferay.portlet.shopping.service.permission.ShoppingItemPermission;
027    
028    import java.io.File;
029    
030    import java.util.List;
031    
032    /**
033     * @author Brian Wing Shun Chan
034     */
035    public class ShoppingItemServiceImpl extends ShoppingItemServiceBaseImpl {
036    
037            public void addBookItems(long groupId, long categoryId, String[] isbns)
038                    throws PortalException, SystemException {
039    
040                    ShoppingCategoryPermission.check(
041                            getPermissionChecker(), groupId, categoryId, ActionKeys.ADD_ITEM);
042    
043                    shoppingItemLocalService.addBookItems(
044                            getUserId(), groupId, categoryId, isbns);
045            }
046    
047            public ShoppingItem addItem(
048                            long groupId, long categoryId, String sku, String name,
049                            String description, String properties, String fieldsQuantities,
050                            boolean requiresShipping, int stockQuantity, boolean featured,
051                            Boolean sale, boolean smallImage, String smallImageURL,
052                            File smallFile, boolean mediumImage, String mediumImageURL,
053                            File mediumFile, boolean largeImage, String largeImageURL,
054                            File largeFile, List<ShoppingItemField> itemFields,
055                            List<ShoppingItemPrice> itemPrices, ServiceContext serviceContext)
056                    throws PortalException, SystemException {
057    
058                    ShoppingCategoryPermission.check(
059                            getPermissionChecker(), groupId, categoryId, ActionKeys.ADD_ITEM);
060    
061                    return shoppingItemLocalService.addItem(
062                            getUserId(), groupId, categoryId, sku, name, description,
063                            properties, fieldsQuantities, requiresShipping, stockQuantity,
064                            featured, sale, smallImage, smallImageURL, smallFile, mediumImage,
065                            mediumImageURL, mediumFile, largeImage, largeImageURL, largeFile,
066                            itemFields, itemPrices, serviceContext);
067            }
068    
069            public void deleteItem(long itemId)
070                    throws PortalException, SystemException {
071    
072                    ShoppingItemPermission.check(
073                            getPermissionChecker(), itemId, ActionKeys.DELETE);
074    
075                    shoppingItemLocalService.deleteItem(itemId);
076            }
077    
078            public ShoppingItem getItem(long itemId)
079                    throws PortalException, SystemException {
080    
081                    ShoppingItemPermission.check(
082                            getPermissionChecker(), itemId, ActionKeys.VIEW);
083    
084                    return shoppingItemLocalService.getItem(itemId);
085            }
086    
087            public ShoppingItem updateItem(
088                            long itemId, long groupId, long categoryId, String sku, String name,
089                            String description, String properties, String fieldsQuantities,
090                            boolean requiresShipping, int stockQuantity, boolean featured,
091                            Boolean sale, boolean smallImage, String smallImageURL,
092                            File smallFile, boolean mediumImage, String mediumImageURL,
093                            File mediumFile, boolean largeImage, String largeImageURL,
094                            File largeFile, List<ShoppingItemField> itemFields,
095                            List<ShoppingItemPrice> itemPrices, ServiceContext serviceContext)
096                    throws PortalException, SystemException {
097    
098                    ShoppingItemPermission.check(
099                            getPermissionChecker(), itemId, ActionKeys.UPDATE);
100    
101                    return shoppingItemLocalService.updateItem(
102                            getUserId(), itemId, groupId, categoryId, sku, name, description,
103                            properties, fieldsQuantities, requiresShipping, stockQuantity,
104                            featured, sale, smallImage, smallImageURL, smallFile, mediumImage,
105                            mediumImageURL, mediumFile, largeImage, largeImageURL, largeFile,
106                            itemFields, itemPrices, serviceContext);
107            }
108    
109    }