1
22
23 package com.liferay.portlet.messageboards.service.impl;
24
25 import com.liferay.portal.PortalException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.security.permission.ActionKeys;
28 import com.liferay.portlet.messageboards.model.MBCategory;
29 import com.liferay.portlet.messageboards.service.base.MBCategoryServiceBaseImpl;
30 import com.liferay.portlet.messageboards.service.permission.MBCategoryPermission;
31
32 import java.util.ArrayList;
33 import java.util.Iterator;
34 import java.util.List;
35
36
42 public class MBCategoryServiceImpl extends MBCategoryServiceBaseImpl {
43
44 public MBCategory addCategory(
45 long plid, long parentCategoryId, String name, String description,
46 String[] communityPermissions, String[] guestPermissions)
47 throws PortalException, SystemException {
48
49 MBCategoryPermission.check(
50 getPermissionChecker(), plid, parentCategoryId,
51 ActionKeys.ADD_CATEGORY);
52
53 return mbCategoryLocalService.addCategory(
54 getUserId(), plid, parentCategoryId, name, description,
55 communityPermissions, guestPermissions);
56 }
57
58 public void deleteCategory(long categoryId)
59 throws PortalException, SystemException {
60
61 MBCategoryPermission.check(
62 getPermissionChecker(), categoryId, ActionKeys.DELETE);
63
64 mbCategoryLocalService.deleteCategory(categoryId);
65 }
66
67 public MBCategory getCategory(long categoryId)
68 throws PortalException, SystemException {
69
70 MBCategoryPermission.check(
71 getPermissionChecker(), categoryId, ActionKeys.VIEW);
72
73 return mbCategoryLocalService.getCategory(categoryId);
74 }
75
76 public List getCategories(
77 long groupId, long parentCategoryId, int begin, int end)
78 throws PortalException, SystemException {
79
80 List categories = new ArrayList();
81
82 Iterator itr = mbCategoryLocalService.getCategories(
83 groupId, parentCategoryId, begin, end).iterator();
84
85 while (itr.hasNext()) {
86 MBCategory category = (MBCategory)itr.next();
87
88 if (MBCategoryPermission.contains(
89 getPermissionChecker(), category, ActionKeys.VIEW)) {
90
91 categories.add(category);
92 }
93 }
94
95 return categories;
96 }
97
98 public int getCategoriesCount(long groupId, long parentCategoryId)
99 throws SystemException {
100
101 return mbCategoryLocalService.getCategoriesCount(
102 groupId, parentCategoryId);
103 }
104
105 public void subscribeCategory(long categoryId)
106 throws PortalException, SystemException {
107
108 MBCategoryPermission.check(
109 getPermissionChecker(), categoryId, ActionKeys.SUBSCRIBE);
110
111 mbCategoryLocalService.subscribeCategory(getUserId(), categoryId);
112 }
113
114 public void unsubscribeCategory(long categoryId)
115 throws PortalException, SystemException {
116
117 MBCategoryPermission.check(
118 getPermissionChecker(), categoryId, ActionKeys.SUBSCRIBE);
119
120 mbCategoryLocalService.unsubscribeCategory(getUserId(), categoryId);
121 }
122
123 public MBCategory updateCategory(
124 long categoryId, long parentCategoryId, String name,
125 String description, boolean mergeWithParentCategory)
126 throws PortalException, SystemException {
127
128 MBCategoryPermission.check(
129 getPermissionChecker(), categoryId, ActionKeys.UPDATE);
130
131 return mbCategoryLocalService.updateCategory(
132 categoryId, parentCategoryId, name, description,
133 mergeWithParentCategory);
134 }
135
136 }