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