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.util.ListUtil;
28 import com.liferay.portal.security.permission.ActionKeys;
29 import com.liferay.portlet.messageboards.model.MBCategory;
30 import com.liferay.portlet.messageboards.service.base.MBCategoryServiceBaseImpl;
31 import com.liferay.portlet.messageboards.service.permission.MBCategoryPermission;
32
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 boolean addCommunityPermissions, boolean addGuestPermissions)
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 addCommunityPermissions, addGuestPermissions);
56 }
57
58 public MBCategory addCategory(
59 long plid, long parentCategoryId, String name, String description,
60 String[] communityPermissions, String[] guestPermissions)
61 throws PortalException, SystemException {
62
63 MBCategoryPermission.check(
64 getPermissionChecker(), plid, parentCategoryId,
65 ActionKeys.ADD_CATEGORY);
66
67 return mbCategoryLocalService.addCategory(
68 getUserId(), plid, parentCategoryId, name, description,
69 communityPermissions, guestPermissions);
70 }
71
72 public void deleteCategory(long categoryId)
73 throws PortalException, SystemException {
74
75 MBCategoryPermission.check(
76 getPermissionChecker(), categoryId, ActionKeys.DELETE);
77
78 mbCategoryLocalService.deleteCategory(categoryId);
79 }
80
81 public MBCategory getCategory(long categoryId)
82 throws PortalException, SystemException {
83
84 MBCategoryPermission.check(
85 getPermissionChecker(), categoryId, ActionKeys.VIEW);
86
87 return mbCategoryLocalService.getCategory(categoryId);
88 }
89
90 public List<MBCategory> getCategories(
91 long groupId, long parentCategoryId, int start, int end)
92 throws PortalException, SystemException {
93
94 List<MBCategory> categories = mbCategoryLocalService.getCategories(
95 groupId, parentCategoryId, start, end);
96
97 categories = ListUtil.copy(categories);
98
99 Iterator<MBCategory> itr = categories.iterator();
100
101 while (itr.hasNext()) {
102 MBCategory category = itr.next();
103
104 if (!MBCategoryPermission.contains(
105 getPermissionChecker(), category, ActionKeys.VIEW)) {
106
107 itr.remove();
108 }
109 }
110
111 return categories;
112 }
113
114 public int getCategoriesCount(long groupId, long parentCategoryId)
115 throws SystemException {
116
117 return mbCategoryLocalService.getCategoriesCount(
118 groupId, parentCategoryId);
119 }
120
121 public void subscribeCategory(long categoryId)
122 throws PortalException, SystemException {
123
124 MBCategoryPermission.check(
125 getPermissionChecker(), categoryId, ActionKeys.SUBSCRIBE);
126
127 mbCategoryLocalService.subscribeCategory(getUserId(), categoryId);
128 }
129
130 public void unsubscribeCategory(long categoryId)
131 throws PortalException, SystemException {
132
133 MBCategoryPermission.check(
134 getPermissionChecker(), categoryId, ActionKeys.SUBSCRIBE);
135
136 mbCategoryLocalService.unsubscribeCategory(getUserId(), categoryId);
137 }
138
139 public MBCategory updateCategory(
140 long categoryId, long parentCategoryId, String name,
141 String description, boolean mergeWithParentCategory)
142 throws PortalException, SystemException {
143
144 MBCategoryPermission.check(
145 getPermissionChecker(), categoryId, ActionKeys.UPDATE);
146
147 return mbCategoryLocalService.updateCategory(
148 categoryId, parentCategoryId, name, description,
149 mergeWithParentCategory);
150 }
151
152 }