1
14
15 package com.liferay.portlet.messageboards.service.impl;
16
17 import com.liferay.portal.kernel.exception.PortalException;
18 import com.liferay.portal.kernel.exception.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 groupId, long categoryId)
59 throws PortalException, SystemException {
60
61 MBCategoryPermission.check(
62 getPermissionChecker(), groupId, categoryId, ActionKeys.DELETE);
63
64 mbCategoryLocalService.deleteCategory(categoryId);
65 }
66
67 public MBCategory getCategory(long categoryId)
68 throws PortalException, SystemException {
69
70 MBCategory category = mbCategoryLocalService.getCategory(categoryId);
71
72 MBCategoryPermission.check(
73 getPermissionChecker(), category, ActionKeys.VIEW);
74
75 return category;
76 }
77
78 public List<MBCategory> getCategories(
79 long groupId, long parentCategoryId, int start, int end)
80 throws PortalException, SystemException {
81
82 List<MBCategory> categories = mbCategoryLocalService.getCategories(
83 groupId, parentCategoryId, start, end);
84
85 categories = ListUtil.copy(categories);
86
87 Iterator<MBCategory> itr = categories.iterator();
88
89 while (itr.hasNext()) {
90 MBCategory category = itr.next();
91
92 if (!MBCategoryPermission.contains(
93 getPermissionChecker(), category, ActionKeys.VIEW)) {
94
95 itr.remove();
96 }
97 }
98
99 return categories;
100 }
101
102 public int getCategoriesCount(long groupId, long parentCategoryId)
103 throws SystemException {
104
105 return mbCategoryLocalService.getCategoriesCount(
106 groupId, parentCategoryId);
107 }
108
109 public void subscribeCategory(long groupId, long categoryId)
110 throws PortalException, SystemException {
111
112 MBCategoryPermission.check(
113 getPermissionChecker(), groupId, categoryId, ActionKeys.SUBSCRIBE);
114
115 mbCategoryLocalService.subscribeCategory(
116 getUserId(), groupId, categoryId);
117 }
118
119 public void unsubscribeCategory(long groupId, long categoryId)
120 throws PortalException, SystemException {
121
122 MBCategoryPermission.check(
123 getPermissionChecker(), groupId, categoryId, ActionKeys.SUBSCRIBE);
124
125 mbCategoryLocalService.unsubscribeCategory(
126 getUserId(), groupId, categoryId);
127 }
128
129 public MBCategory updateCategory(
130 long categoryId, long parentCategoryId, String name,
131 String description, String emailAddress, String inProtocol,
132 String inServerName, int inServerPort, boolean inUseSSL,
133 String inUserName, String inPassword, int inReadInterval,
134 String outEmailAddress, boolean outCustom, String outServerName,
135 int outServerPort, boolean outUseSSL, String outUserName,
136 String outPassword, boolean mailingListActive,
137 boolean mergeWithParentCategory, ServiceContext serviceContext)
138 throws PortalException, SystemException {
139
140 MBCategory category = mbCategoryLocalService.getCategory(categoryId);
141
142 MBCategoryPermission.check(
143 getPermissionChecker(), category, ActionKeys.UPDATE);
144
145 return mbCategoryLocalService.updateCategory(
146 categoryId, parentCategoryId, name, description, emailAddress,
147 inProtocol, inServerName, inServerPort, inUseSSL, inUserName,
148 inPassword, inReadInterval, outEmailAddress, outCustom,
149 outServerName, outServerPort, outUseSSL, outUserName, outPassword,
150 mailingListActive, mergeWithParentCategory, serviceContext);
151 }
152
153 }