1
14
15 package com.liferay.portlet.shopping.service.impl;
16
17 import com.liferay.portal.kernel.exception.PortalException;
18 import com.liferay.portal.kernel.exception.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
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 ShoppingCategory category = shoppingCategoryLocalService.getCategory(
50 categoryId);
51
52 ShoppingCategoryPermission.check(
53 getPermissionChecker(), category, ActionKeys.DELETE);
54
55 shoppingCategoryLocalService.deleteCategory(categoryId);
56 }
57
58 public ShoppingCategory getCategory(long categoryId)
59 throws PortalException, SystemException {
60
61 ShoppingCategory category = shoppingCategoryLocalService.getCategory(
62 categoryId);
63
64 ShoppingCategoryPermission.check(
65 getPermissionChecker(), category, ActionKeys.VIEW);
66
67 return category;
68 }
69
70 public ShoppingCategory updateCategory(
71 long categoryId, long parentCategoryId, String name,
72 String description, boolean mergeWithParentCategory,
73 ServiceContext serviceContext)
74 throws PortalException, SystemException {
75
76 ShoppingCategory category = shoppingCategoryLocalService.getCategory(
77 categoryId);
78
79 ShoppingCategoryPermission.check(
80 getPermissionChecker(), category, ActionKeys.UPDATE);
81
82 return shoppingCategoryLocalService.updateCategory(
83 categoryId, parentCategoryId, name, description,
84 mergeWithParentCategory, serviceContext);
85 }
86
87 }