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(
103 groupId, folderId);
104
105 for (BookmarksFolder folder : folders) {
106 folderIds.add(folder.getFolderId());
107
108 getSubfolderIds(
109 folderIds, folder.getGroupId(), folder.getFolderId());
110 }
111 }
112
113 public BookmarksFolder updateFolder(
114 long folderId, long parentFolderId, String name,
115 String description, boolean mergeWithParentFolder,
116 ServiceContext serviceContext)
117 throws PortalException, SystemException {
118
119 BookmarksFolder folder = bookmarksFolderLocalService.getFolder(
120 folderId);
121
122 BookmarksFolderPermission.check(
123 getPermissionChecker(), folder, ActionKeys.UPDATE);
124
125 return bookmarksFolderLocalService.updateFolder(
126 folderId, parentFolderId, name, description, mergeWithParentFolder,
127 serviceContext);
128 }
129
130 }