001
014
015 package com.liferay.portlet.bookmarks.service.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.security.permission.ActionKeys;
020 import com.liferay.portal.service.ServiceContext;
021 import com.liferay.portlet.bookmarks.model.BookmarksFolder;
022 import com.liferay.portlet.bookmarks.service.base.BookmarksFolderServiceBaseImpl;
023 import com.liferay.portlet.bookmarks.service.permission.BookmarksFolderPermission;
024
025 import java.util.List;
026
027
030 public class BookmarksFolderServiceImpl extends BookmarksFolderServiceBaseImpl {
031
032 public BookmarksFolder addFolder(
033 long parentFolderId, String name, String description,
034 ServiceContext serviceContext)
035 throws PortalException, SystemException {
036
037 BookmarksFolderPermission.check(
038 getPermissionChecker(), serviceContext.getScopeGroupId(),
039 parentFolderId, ActionKeys.ADD_FOLDER);
040
041 return bookmarksFolderLocalService.addFolder(
042 getUserId(), parentFolderId, name, description, serviceContext);
043 }
044
045 public void deleteFolder(long folderId)
046 throws PortalException, SystemException {
047
048 BookmarksFolder folder = bookmarksFolderLocalService.getFolder(
049 folderId);
050
051 BookmarksFolderPermission.check(
052 getPermissionChecker(), folder, ActionKeys.DELETE);
053
054 bookmarksFolderLocalService.deleteFolder(folderId);
055 }
056
057 public BookmarksFolder getFolder(long folderId)
058 throws PortalException, SystemException {
059
060 BookmarksFolder folder = bookmarksFolderLocalService.getFolder(
061 folderId);
062
063 BookmarksFolderPermission.check(
064 getPermissionChecker(), folder, ActionKeys.VIEW);
065
066 return folder;
067 }
068
069 public List<BookmarksFolder> getFolders(long groupId)
070 throws SystemException {
071
072 return bookmarksFolderPersistence.filterFindByGroupId(groupId);
073 }
074
075 public List<BookmarksFolder> getFolders(long groupId, long parentFolderId)
076 throws SystemException {
077
078 return bookmarksFolderPersistence.filterFindByG_P(
079 groupId, parentFolderId);
080 }
081
082 public List<BookmarksFolder> getFolders(
083 long groupId, long parentFolderId, int start, int end)
084 throws SystemException {
085
086 return bookmarksFolderPersistence.filterFindByG_P(
087 groupId, parentFolderId, start, end);
088 }
089
090 public int getFoldersCount(long groupId, long parentFolderId)
091 throws SystemException {
092
093 return bookmarksFolderPersistence.filterCountByG_P(
094 groupId, parentFolderId);
095 }
096
097 public void getSubfolderIds(
098 List<Long> folderIds, long groupId, long folderId)
099 throws SystemException {
100
101 List<BookmarksFolder> folders =
102 bookmarksFolderPersistence.filterFindByG_P(groupId, folderId);
103
104 for (BookmarksFolder folder : folders) {
105 folderIds.add(folder.getFolderId());
106
107 getSubfolderIds(
108 folderIds, folder.getGroupId(), folder.getFolderId());
109 }
110 }
111
112 public void subscribeFolder(long groupId, long folderId)
113 throws PortalException, SystemException {
114
115 BookmarksFolderPermission.check(
116 getPermissionChecker(), groupId, folderId, ActionKeys.SUBSCRIBE);
117
118 bookmarksFolderLocalService.subscribeFolder(
119 getUserId(), groupId, folderId);
120 }
121
122 public void unsubscribeFolder(long groupId, long folderId)
123 throws PortalException, SystemException {
124
125 BookmarksFolderPermission.check(
126 getPermissionChecker(), groupId, folderId, ActionKeys.SUBSCRIBE);
127
128 bookmarksFolderLocalService.unsubscribeFolder(
129 getUserId(), groupId, folderId);
130 }
131
132 public BookmarksFolder updateFolder(
133 long folderId, long parentFolderId, String name, String description,
134 boolean mergeWithParentFolder, ServiceContext serviceContext)
135 throws PortalException, SystemException {
136
137 BookmarksFolder folder = bookmarksFolderLocalService.getFolder(
138 folderId);
139
140 BookmarksFolderPermission.check(
141 getPermissionChecker(), folder, ActionKeys.UPDATE);
142
143 return bookmarksFolderLocalService.updateFolder(
144 folderId, parentFolderId, name, description, mergeWithParentFolder,
145 serviceContext);
146 }
147
148 }