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.security.permission.ActionKeys;
20 import com.liferay.portal.service.ServiceContext;
21 import com.liferay.portlet.messageboards.model.MBCategory;
22 import com.liferay.portlet.messageboards.service.base.MBCategoryServiceBaseImpl;
23 import com.liferay.portlet.messageboards.service.permission.MBCategoryPermission;
24
25 import java.util.List;
26
27
32 public class MBCategoryServiceImpl extends MBCategoryServiceBaseImpl {
33
34 public MBCategory addCategory(
35 long parentCategoryId, String name, String description,
36 String emailAddress, String inProtocol, String inServerName,
37 int inServerPort, boolean inUseSSL, String inUserName,
38 String inPassword, int inReadInterval, String outEmailAddress,
39 boolean outCustom, String outServerName, int outServerPort,
40 boolean outUseSSL, String outUserName, String outPassword,
41 boolean mailingListActive, ServiceContext serviceContext)
42 throws PortalException, SystemException {
43
44 MBCategoryPermission.check(
45 getPermissionChecker(), serviceContext.getScopeGroupId(),
46 parentCategoryId, ActionKeys.ADD_CATEGORY);
47
48 return mbCategoryLocalService.addCategory(
49 getUserId(), parentCategoryId, name, description,
50 emailAddress, inProtocol, inServerName, inServerPort, inUseSSL,
51 inUserName, inPassword, inReadInterval, outEmailAddress, outCustom,
52 outServerName, outServerPort, outUseSSL, outUserName, outPassword,
53 mailingListActive, serviceContext);
54 }
55
56 public void deleteCategory(long groupId, long categoryId)
57 throws PortalException, SystemException {
58
59 MBCategoryPermission.check(
60 getPermissionChecker(), groupId, categoryId, ActionKeys.DELETE);
61
62 mbCategoryLocalService.deleteCategory(categoryId);
63 }
64
65 public MBCategory getCategory(long categoryId)
66 throws PortalException, SystemException {
67
68 MBCategory category = mbCategoryLocalService.getCategory(categoryId);
69
70 MBCategoryPermission.check(
71 getPermissionChecker(), category, ActionKeys.VIEW);
72
73 return category;
74 }
75
76 public List<MBCategory> getCategories(
77 long groupId, long parentCategoryId, int start, int end)
78 throws SystemException {
79
80 return mbCategoryPersistence.filterFindByG_P(
81 groupId, parentCategoryId, start, end);
82 }
83
84 public int getCategoriesCount(long groupId, long parentCategoryId)
85 throws SystemException {
86
87 return mbCategoryPersistence.filterCountByG_P(
88 groupId, parentCategoryId);
89 }
90
91 public List<Long> getSubcategoryIds(
92 List<Long> categoryIds, long groupId, long categoryId)
93 throws SystemException {
94
95 List<MBCategory> categories = mbCategoryPersistence.filterFindByG_P(
96 groupId, categoryId);
97
98 for (MBCategory category : categories) {
99 categoryIds.add(category.getCategoryId());
100
101 getSubcategoryIds(
102 categoryIds, category.getGroupId(), category.getCategoryId());
103 }
104
105 return categoryIds;
106 }
107
108 public List<MBCategory> getSubscribedCategories(
109 long groupId, long userId, int start, int end)
110 throws SystemException {
111
112 return mbCategoryFinder.filterFindByS_G_U(groupId, userId, start, end);
113 }
114
115 public int getSubscribedCategoriesCount(long groupId, long userId)
116 throws SystemException {
117
118 return mbCategoryFinder.filterCountByS_G_U(groupId, userId);
119 }
120
121 public void subscribeCategory(long groupId, long categoryId)
122 throws PortalException, SystemException {
123
124 MBCategoryPermission.check(
125 getPermissionChecker(), groupId, categoryId, ActionKeys.SUBSCRIBE);
126
127 mbCategoryLocalService.subscribeCategory(
128 getUserId(), groupId, categoryId);
129 }
130
131 public void unsubscribeCategory(long groupId, long categoryId)
132 throws PortalException, SystemException {
133
134 MBCategoryPermission.check(
135 getPermissionChecker(), groupId, categoryId, ActionKeys.SUBSCRIBE);
136
137 mbCategoryLocalService.unsubscribeCategory(
138 getUserId(), groupId, categoryId);
139 }
140
141 public MBCategory updateCategory(
142 long categoryId, long parentCategoryId, String name,
143 String description, String emailAddress, String inProtocol,
144 String inServerName, int inServerPort, boolean inUseSSL,
145 String inUserName, String inPassword, int inReadInterval,
146 String outEmailAddress, boolean outCustom, String outServerName,
147 int outServerPort, boolean outUseSSL, String outUserName,
148 String outPassword, boolean mailingListActive,
149 boolean mergeWithParentCategory, ServiceContext serviceContext)
150 throws PortalException, SystemException {
151
152 MBCategory category = mbCategoryLocalService.getCategory(categoryId);
153
154 MBCategoryPermission.check(
155 getPermissionChecker(), category, ActionKeys.UPDATE);
156
157 return mbCategoryLocalService.updateCategory(
158 categoryId, parentCategoryId, name, description, emailAddress,
159 inProtocol, inServerName, inServerPort, inUseSSL, inUserName,
160 inPassword, inReadInterval, outEmailAddress, outCustom,
161 outServerName, outServerPort, outUseSSL, outUserName, outPassword,
162 mailingListActive, mergeWithParentCategory, serviceContext);
163 }
164
165 }