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 BookmarksFolder updateFolder(
113 long folderId, long parentFolderId, String name, String description,
114 boolean mergeWithParentFolder, ServiceContext serviceContext)
115 throws PortalException, SystemException {
116
117 BookmarksFolder folder = bookmarksFolderLocalService.getFolder(
118 folderId);
119
120 BookmarksFolderPermission.check(
121 getPermissionChecker(), folder, ActionKeys.UPDATE);
122
123 return bookmarksFolderLocalService.updateFolder(
124 folderId, parentFolderId, name, description, mergeWithParentFolder,
125 serviceContext);
126 }
127
128 }