001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.messageboards.service.impl;
022:
023: import com.liferay.portal.PortalException;
024: import com.liferay.portal.SystemException;
025: import com.liferay.portal.kernel.security.permission.ActionKeys;
026: import com.liferay.portlet.messageboards.model.MBCategory;
027: import com.liferay.portlet.messageboards.service.base.MBCategoryServiceBaseImpl;
028: import com.liferay.portlet.messageboards.service.permission.MBCategoryPermission;
029:
030: import java.util.ArrayList;
031: import java.util.Iterator;
032: import java.util.List;
033:
034: /**
035: * <a href="MBCategoryServiceImpl.java.html"><b><i>View Source</i></b></a>
036: *
037: * @author Brian Wing Shun Chan
038: *
039: */
040: public class MBCategoryServiceImpl extends MBCategoryServiceBaseImpl {
041:
042: public MBCategory addCategory(long plid, long parentCategoryId,
043: String name, String description,
044: String[] communityPermissions, String[] guestPermissions)
045: throws PortalException, SystemException {
046:
047: MBCategoryPermission.check(getPermissionChecker(), plid,
048: parentCategoryId, ActionKeys.ADD_CATEGORY);
049:
050: return mbCategoryLocalService.addCategory(getUserId(), plid,
051: parentCategoryId, name, description,
052: communityPermissions, guestPermissions);
053: }
054:
055: public void deleteCategory(long categoryId) throws PortalException,
056: SystemException {
057:
058: MBCategoryPermission.check(getPermissionChecker(), categoryId,
059: ActionKeys.DELETE);
060:
061: mbCategoryLocalService.deleteCategory(categoryId);
062: }
063:
064: public MBCategory getCategory(long categoryId)
065: throws PortalException, SystemException {
066:
067: MBCategoryPermission.check(getPermissionChecker(), categoryId,
068: ActionKeys.VIEW);
069:
070: return mbCategoryLocalService.getCategory(categoryId);
071: }
072:
073: public List getCategories(long groupId, long parentCategoryId,
074: int begin, int end) throws PortalException, SystemException {
075:
076: List categories = new ArrayList();
077:
078: Iterator itr = mbCategoryLocalService.getCategories(groupId,
079: parentCategoryId, begin, end).iterator();
080:
081: while (itr.hasNext()) {
082: MBCategory category = (MBCategory) itr.next();
083:
084: if (MBCategoryPermission.contains(getPermissionChecker(),
085: category, ActionKeys.VIEW)) {
086:
087: categories.add(category);
088: }
089: }
090:
091: return categories;
092: }
093:
094: public int getCategoriesCount(long groupId, long parentCategoryId)
095: throws SystemException {
096:
097: return mbCategoryLocalService.getCategoriesCount(groupId,
098: parentCategoryId);
099: }
100:
101: public void subscribeCategory(long categoryId)
102: throws PortalException, SystemException {
103:
104: MBCategoryPermission.check(getPermissionChecker(), categoryId,
105: ActionKeys.SUBSCRIBE);
106:
107: mbCategoryLocalService.subscribeCategory(getUserId(),
108: categoryId);
109: }
110:
111: public void unsubscribeCategory(long categoryId)
112: throws PortalException, SystemException {
113:
114: MBCategoryPermission.check(getPermissionChecker(), categoryId,
115: ActionKeys.SUBSCRIBE);
116:
117: mbCategoryLocalService.unsubscribeCategory(getUserId(),
118: categoryId);
119: }
120:
121: public MBCategory updateCategory(long categoryId,
122: long parentCategoryId, String name, String description,
123: boolean mergeWithParentCategory) throws PortalException,
124: SystemException {
125:
126: MBCategoryPermission.check(getPermissionChecker(), categoryId,
127: ActionKeys.UPDATE);
128:
129: return mbCategoryLocalService.updateCategory(categoryId,
130: parentCategoryId, name, description,
131: mergeWithParentCategory);
132: }
133:
134: }
|