1
14
15 package com.liferay.portlet.messageboards.service.impl;
16
17 import com.liferay.portal.PortalException;
18 import com.liferay.portal.SystemException;
19 import com.liferay.portal.kernel.util.ListUtil;
20 import com.liferay.portal.security.permission.ActionKeys;
21 import com.liferay.portal.service.ServiceContext;
22 import com.liferay.portlet.messageboards.model.MBCategory;
23 import com.liferay.portlet.messageboards.service.base.MBCategoryServiceBaseImpl;
24 import com.liferay.portlet.messageboards.service.permission.MBCategoryPermission;
25
26 import java.util.Iterator;
27 import java.util.List;
28
29
34 public class MBCategoryServiceImpl extends MBCategoryServiceBaseImpl {
35
36 public MBCategory addCategory(
37 long parentCategoryId, String name, String description,
38 String emailAddress, String inProtocol, String inServerName,
39 int inServerPort, boolean inUseSSL, String inUserName,
40 String inPassword, int inReadInterval, String outEmailAddress,
41 boolean outCustom, String outServerName, int outServerPort,
42 boolean outUseSSL, String outUserName, String outPassword,
43 boolean mailingListActive, ServiceContext serviceContext)
44 throws PortalException, SystemException {
45
46 MBCategoryPermission.check(
47 getPermissionChecker(), serviceContext.getScopeGroupId(),
48 parentCategoryId, ActionKeys.ADD_CATEGORY);
49
50 return mbCategoryLocalService.addCategory(
51 getUserId(), parentCategoryId, name, description,
52 emailAddress, inProtocol, inServerName, inServerPort, inUseSSL,
53 inUserName, inPassword, inReadInterval, outEmailAddress, outCustom,
54 outServerName, outServerPort, outUseSSL, outUserName, outPassword,
55 mailingListActive, serviceContext);
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 List<MBCategory> getCategories(
68 long groupId, long parentCategoryId, int start, int end)
69 throws PortalException, SystemException {
70
71 List<MBCategory> categories = mbCategoryLocalService.getCategories(
72 groupId, parentCategoryId, start, end);
73
74 categories = ListUtil.copy(categories);
75
76 Iterator<MBCategory> itr = categories.iterator();
77
78 while (itr.hasNext()) {
79 MBCategory category = itr.next();
80
81 if (!MBCategoryPermission.contains(
82 getPermissionChecker(), category, ActionKeys.VIEW)) {
83
84 itr.remove();
85 }
86 }
87
88 return categories;
89 }
90
91 public int getCategoriesCount(long groupId, long parentCategoryId)
92 throws SystemException {
93
94 return mbCategoryLocalService.getCategoriesCount(
95 groupId, parentCategoryId);
96 }
97
98 public MBCategory getCategory(long categoryId)
99 throws PortalException, SystemException {
100
101 MBCategoryPermission.check(
102 getPermissionChecker(), categoryId, ActionKeys.VIEW);
103
104 return mbCategoryLocalService.getCategory(categoryId);
105 }
106
107 public void subscribeCategory(long categoryId)
108 throws PortalException, SystemException {
109
110 MBCategoryPermission.check(
111 getPermissionChecker(), categoryId, ActionKeys.SUBSCRIBE);
112
113 mbCategoryLocalService.subscribeCategory(getUserId(), categoryId);
114 }
115
116 public void unsubscribeCategory(long categoryId)
117 throws PortalException, SystemException {
118
119 MBCategoryPermission.check(
120 getPermissionChecker(), categoryId, ActionKeys.SUBSCRIBE);
121
122 mbCategoryLocalService.unsubscribeCategory(getUserId(), categoryId);
123 }
124
125 public MBCategory updateCategory(
126 long categoryId, long parentCategoryId, String name,
127 String description, String emailAddress, String inProtocol,
128 String inServerName, int inServerPort, boolean inUseSSL,
129 String inUserName, String inPassword, int inReadInterval,
130 String outEmailAddress, boolean outCustom, String outServerName,
131 int outServerPort, boolean outUseSSL, String outUserName,
132 String outPassword, boolean mailingListActive,
133 boolean mergeWithParentCategory)
134 throws PortalException, SystemException {
135
136 MBCategoryPermission.check(
137 getPermissionChecker(), categoryId, ActionKeys.UPDATE);
138
139 return mbCategoryLocalService.updateCategory(
140 categoryId, parentCategoryId, name, description, emailAddress,
141 inProtocol, inServerName, inServerPort, inUseSSL, inUserName,
142 inPassword, inReadInterval, outEmailAddress, outCustom,
143 outServerName, outServerPort, outUseSSL, outUserName, outPassword,
144 mailingListActive, mergeWithParentCategory);
145 }
146
147 }