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 @Override
033 public BookmarksFolder addFolder(
034 long parentFolderId, String name, String description,
035 ServiceContext serviceContext)
036 throws PortalException, SystemException {
037
038 BookmarksFolderPermission.check(
039 getPermissionChecker(), serviceContext.getScopeGroupId(),
040 parentFolderId, ActionKeys.ADD_FOLDER);
041
042 return bookmarksFolderLocalService.addFolder(
043 getUserId(), parentFolderId, name, description, serviceContext);
044 }
045
046 @Override
047 public void deleteFolder(long folderId)
048 throws PortalException, SystemException {
049
050 BookmarksFolder folder = bookmarksFolderLocalService.getFolder(
051 folderId);
052
053 BookmarksFolderPermission.check(
054 getPermissionChecker(), folder, ActionKeys.DELETE);
055
056 bookmarksFolderLocalService.deleteFolder(folderId);
057 }
058
059 @Override
060 public BookmarksFolder getFolder(long folderId)
061 throws PortalException, SystemException {
062
063 BookmarksFolder folder = bookmarksFolderLocalService.getFolder(
064 folderId);
065
066 BookmarksFolderPermission.check(
067 getPermissionChecker(), folder, ActionKeys.VIEW);
068
069 return folder;
070 }
071
072 @Override
073 public List<BookmarksFolder> getFolders(long groupId)
074 throws SystemException {
075
076 return bookmarksFolderPersistence.filterFindByGroupId(groupId);
077 }
078
079 @Override
080 public List<BookmarksFolder> getFolders(long groupId, long parentFolderId)
081 throws SystemException {
082
083 return bookmarksFolderPersistence.filterFindByG_P(
084 groupId, parentFolderId);
085 }
086
087 @Override
088 public List<BookmarksFolder> getFolders(
089 long groupId, long parentFolderId, int start, int end)
090 throws SystemException {
091
092 return bookmarksFolderPersistence.filterFindByG_P(
093 groupId, parentFolderId, start, end);
094 }
095
096 @Override
097 public int getFoldersCount(long groupId, long parentFolderId)
098 throws SystemException {
099
100 return bookmarksFolderPersistence.filterCountByG_P(
101 groupId, parentFolderId);
102 }
103
104 @Override
105 public void getSubfolderIds(
106 List<Long> folderIds, long groupId, long folderId)
107 throws SystemException {
108
109 List<BookmarksFolder> folders =
110 bookmarksFolderPersistence.filterFindByG_P(groupId, folderId);
111
112 for (BookmarksFolder folder : folders) {
113 folderIds.add(folder.getFolderId());
114
115 getSubfolderIds(
116 folderIds, folder.getGroupId(), folder.getFolderId());
117 }
118 }
119
120 @Override
121 public BookmarksFolder updateFolder(
122 long folderId, long parentFolderId, String name, String description,
123 boolean mergeWithParentFolder, ServiceContext serviceContext)
124 throws PortalException, SystemException {
125
126 BookmarksFolder folder = bookmarksFolderLocalService.getFolder(
127 folderId);
128
129 BookmarksFolderPermission.check(
130 getPermissionChecker(), folder, ActionKeys.UPDATE);
131
132 return bookmarksFolderLocalService.updateFolder(
133 folderId, parentFolderId, name, description, mergeWithParentFolder,
134 serviceContext);
135 }
136
137 }