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.portal.service.ServiceContext;
30 import com.liferay.portlet.messageboards.model.MBCategory;
31 import com.liferay.portlet.messageboards.service.base.MBCategoryServiceBaseImpl;
32 import com.liferay.portlet.messageboards.service.permission.MBCategoryPermission;
33
34 import java.util.Iterator;
35 import java.util.List;
36
37
42 public class MBCategoryServiceImpl extends MBCategoryServiceBaseImpl {
43
44 public MBCategory addCategory(
45 long parentCategoryId, String name, String description,
46 String emailAddress, String inProtocol, String inServerName,
47 int inServerPort, boolean inUseSSL, String inUserName,
48 String inPassword, int inReadInterval, String outEmailAddress,
49 boolean outCustom, String outServerName, int outServerPort,
50 boolean outUseSSL, String outUserName, String outPassword,
51 boolean mailingListActive, ServiceContext serviceContext)
52 throws PortalException, SystemException {
53
54 MBCategoryPermission.check(
55 getPermissionChecker(), serviceContext.getScopeGroupId(),
56 parentCategoryId, ActionKeys.ADD_CATEGORY);
57
58 return mbCategoryLocalService.addCategory(
59 getUserId(), parentCategoryId, name, description,
60 emailAddress, inProtocol, inServerName, inServerPort, inUseSSL,
61 inUserName, inPassword, inReadInterval, outEmailAddress, outCustom,
62 outServerName, outServerPort, outUseSSL, outUserName, outPassword,
63 mailingListActive, serviceContext);
64 }
65
66 public void deleteCategory(long categoryId)
67 throws PortalException, SystemException {
68
69 MBCategoryPermission.check(
70 getPermissionChecker(), categoryId, ActionKeys.DELETE);
71
72 mbCategoryLocalService.deleteCategory(categoryId);
73 }
74
75 public List<MBCategory> getCategories(
76 long groupId, long parentCategoryId, int start, int end)
77 throws PortalException, SystemException {
78
79 List<MBCategory> categories = mbCategoryLocalService.getCategories(
80 groupId, parentCategoryId, start, end);
81
82 categories = ListUtil.copy(categories);
83
84 Iterator<MBCategory> itr = categories.iterator();
85
86 while (itr.hasNext()) {
87 MBCategory category = itr.next();
88
89 if (!MBCategoryPermission.contains(
90 getPermissionChecker(), category, ActionKeys.VIEW)) {
91
92 itr.remove();
93 }
94 }
95
96 return categories;
97 }
98
99 public int getCategoriesCount(long groupId, long parentCategoryId)
100 throws SystemException {
101
102 return mbCategoryLocalService.getCategoriesCount(
103 groupId, parentCategoryId);
104 }
105
106 public MBCategory getCategory(long categoryId)
107 throws PortalException, SystemException {
108
109 MBCategoryPermission.check(
110 getPermissionChecker(), categoryId, ActionKeys.VIEW);
111
112 return mbCategoryLocalService.getCategory(categoryId);
113 }
114
115 public void subscribeCategory(long categoryId)
116 throws PortalException, SystemException {
117
118 MBCategoryPermission.check(
119 getPermissionChecker(), categoryId, ActionKeys.SUBSCRIBE);
120
121 mbCategoryLocalService.subscribeCategory(getUserId(), categoryId);
122 }
123
124 public void unsubscribeCategory(long categoryId)
125 throws PortalException, SystemException {
126
127 MBCategoryPermission.check(
128 getPermissionChecker(), categoryId, ActionKeys.SUBSCRIBE);
129
130 mbCategoryLocalService.unsubscribeCategory(getUserId(), categoryId);
131 }
132
133 public MBCategory updateCategory(
134 long categoryId, long parentCategoryId, String name,
135 String description, String emailAddress, String inProtocol,
136 String inServerName, int inServerPort, boolean inUseSSL,
137 String inUserName, String inPassword, int inReadInterval,
138 String outEmailAddress, boolean outCustom, String outServerName,
139 int outServerPort, boolean outUseSSL, String outUserName,
140 String outPassword, boolean mailingListActive,
141 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, emailAddress,
149 inProtocol, inServerName, inServerPort, inUseSSL, inUserName,
150 inPassword, inReadInterval, outEmailAddress, outCustom,
151 outServerName, outServerPort, outUseSSL, outUserName, outPassword,
152 mailingListActive, mergeWithParentCategory);
153 }
154
155 }