1   /**
2    * Copyright (c) 2000-2010 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   *
12   *
13   */
14  
15  package com.liferay.portlet.shopping.service.impl;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.security.permission.ActionKeys;
20  import com.liferay.portal.service.ServiceContext;
21  import com.liferay.portlet.shopping.model.ShoppingCategory;
22  import com.liferay.portlet.shopping.service.base.ShoppingCategoryServiceBaseImpl;
23  import com.liferay.portlet.shopping.service.permission.ShoppingCategoryPermission;
24  
25  /**
26   * <a href="ShoppingCategoryServiceImpl.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   */
30  public class ShoppingCategoryServiceImpl
31      extends ShoppingCategoryServiceBaseImpl {
32  
33      public ShoppingCategory addCategory(
34              long parentCategoryId, String name, String description,
35              ServiceContext serviceContext)
36          throws PortalException, SystemException {
37  
38          ShoppingCategoryPermission.check(
39              getPermissionChecker(), serviceContext.getScopeGroupId(),
40              parentCategoryId, ActionKeys.ADD_CATEGORY);
41  
42          return shoppingCategoryLocalService.addCategory(
43              getUserId(), parentCategoryId, name, description, serviceContext);
44      }
45  
46      public void deleteCategory(long categoryId)
47          throws PortalException, SystemException {
48  
49          ShoppingCategoryPermission.check(
50              getPermissionChecker(), categoryId, ActionKeys.DELETE);
51  
52          shoppingCategoryLocalService.deleteCategory(categoryId);
53      }
54  
55      public ShoppingCategory getCategory(long categoryId)
56          throws PortalException, SystemException {
57  
58          ShoppingCategoryPermission.check(
59              getPermissionChecker(), categoryId, ActionKeys.VIEW);
60  
61          return shoppingCategoryLocalService.getCategory(categoryId);
62      }
63  
64      public ShoppingCategory updateCategory(
65              long categoryId, long parentCategoryId, String name,
66              String description, boolean mergeWithParentCategory,
67              ServiceContext serviceContext)
68          throws PortalException, SystemException {
69  
70          ShoppingCategoryPermission.check(
71              getPermissionChecker(), categoryId, ActionKeys.UPDATE);
72  
73          return shoppingCategoryLocalService.updateCategory(
74              categoryId, parentCategoryId, name, description,
75              mergeWithParentCategory, serviceContext);
76      }
77  
78  }