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.portlet.shopping.model.ShoppingCategory;
21  import com.liferay.portlet.shopping.service.base.ShoppingCategoryServiceBaseImpl;
22  import com.liferay.portlet.shopping.service.permission.ShoppingCategoryPermission;
23  
24  /**
25   * <a href="ShoppingCategoryServiceImpl.java.html"><b><i>View Source</i></b></a>
26   *
27   * @author Brian Wing Shun Chan
28   */
29  public class ShoppingCategoryServiceImpl
30      extends ShoppingCategoryServiceBaseImpl {
31  
32      public ShoppingCategory addCategory(
33              long plid, long parentCategoryId, String name, String description,
34              boolean addCommunityPermissions, boolean addGuestPermissions)
35          throws PortalException, SystemException {
36  
37          ShoppingCategoryPermission.check(
38              getPermissionChecker(), plid, parentCategoryId,
39              ActionKeys.ADD_CATEGORY);
40  
41          return shoppingCategoryLocalService.addCategory(
42              getUserId(), plid, parentCategoryId, name, description,
43              addCommunityPermissions, addGuestPermissions);
44      }
45  
46      public ShoppingCategory addCategory(
47              long plid, long parentCategoryId, String name, String description,
48              String[] communityPermissions, String[] guestPermissions)
49          throws PortalException, SystemException {
50  
51          ShoppingCategoryPermission.check(
52              getPermissionChecker(), plid, parentCategoryId,
53              ActionKeys.ADD_CATEGORY);
54  
55          return shoppingCategoryLocalService.addCategory(
56              getUserId(), plid, parentCategoryId, name, description,
57              communityPermissions, guestPermissions);
58      }
59  
60      public void deleteCategory(long categoryId)
61          throws PortalException, SystemException {
62  
63          ShoppingCategoryPermission.check(
64              getPermissionChecker(), categoryId, ActionKeys.DELETE);
65  
66          shoppingCategoryLocalService.deleteCategory(categoryId);
67      }
68  
69      public ShoppingCategory getCategory(long categoryId)
70          throws PortalException, SystemException {
71  
72          ShoppingCategoryPermission.check(
73              getPermissionChecker(), categoryId, ActionKeys.VIEW);
74  
75          return shoppingCategoryLocalService.getCategory(categoryId);
76      }
77  
78      public ShoppingCategory updateCategory(
79              long categoryId, long parentCategoryId, String name,
80              String description, boolean mergeWithParentCategory)
81          throws PortalException, SystemException {
82  
83          ShoppingCategoryPermission.check(
84              getPermissionChecker(), categoryId, ActionKeys.UPDATE);
85  
86          return shoppingCategoryLocalService.updateCategory(
87              categoryId, parentCategoryId, name, description,
88              mergeWithParentCategory);
89      }
90  
91  }