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.kernel.util.ArrayUtil;
020 import com.liferay.portal.kernel.util.OrderByComparator;
021 import com.liferay.portal.security.permission.ActionKeys;
022 import com.liferay.portal.service.ServiceContext;
023 import com.liferay.portlet.bookmarks.model.BookmarksEntry;
024 import com.liferay.portlet.bookmarks.service.base.BookmarksEntryServiceBaseImpl;
025 import com.liferay.portlet.bookmarks.service.permission.BookmarksEntryPermission;
026 import com.liferay.portlet.bookmarks.service.permission.BookmarksFolderPermission;
027 import com.liferay.portlet.bookmarks.util.comparator.EntryModifiedDateComparator;
028
029 import java.util.List;
030
031
034 public class BookmarksEntryServiceImpl extends BookmarksEntryServiceBaseImpl {
035
036 public BookmarksEntry addEntry(
037 long groupId, long folderId, String name, String url,
038 String description, ServiceContext serviceContext)
039 throws PortalException, SystemException {
040
041 BookmarksFolderPermission.check(
042 getPermissionChecker(), groupId, folderId, ActionKeys.ADD_ENTRY);
043
044 return bookmarksEntryLocalService.addEntry(
045 getUserId(), groupId, folderId, name, url, description,
046 serviceContext);
047 }
048
049 public void deleteEntry(long entryId)
050 throws PortalException, SystemException {
051
052 BookmarksEntryPermission.check(
053 getPermissionChecker(), entryId, ActionKeys.DELETE);
054
055 bookmarksEntryLocalService.deleteEntry(entryId);
056 }
057
058 public List<BookmarksEntry> getEntries(
059 long groupId, long folderId, int start, int end)
060 throws SystemException {
061
062 return bookmarksEntryPersistence.filterFindByG_F(
063 groupId, folderId, start, end);
064 }
065
066 public List<BookmarksEntry> getEntries(
067 long groupId, long folderId, int start, int end,
068 OrderByComparator orderByComparator)
069 throws SystemException {
070
071 return bookmarksEntryPersistence.filterFindByG_F(
072 groupId, folderId, start, end, orderByComparator);
073 }
074
075 public int getEntriesCount(long groupId, long folderId)
076 throws SystemException {
077
078 return bookmarksEntryPersistence.filterCountByG_F(groupId, folderId);
079 }
080
081 public BookmarksEntry getEntry(long entryId)
082 throws PortalException, SystemException {
083
084 BookmarksEntryPermission.check(
085 getPermissionChecker(), entryId, ActionKeys.VIEW);
086
087 return bookmarksEntryLocalService.getEntry(entryId);
088 }
089
090 public int getFoldersEntriesCount(long groupId, List<Long> folderIds)
091 throws SystemException {
092
093 return bookmarksEntryPersistence.filterCountByG_F(
094 groupId,
095 ArrayUtil.toArray(folderIds.toArray(new Long[folderIds.size()])));
096 }
097
098 public List<BookmarksEntry> getGroupEntries(
099 long groupId, int start, int end)
100 throws SystemException {
101
102 return bookmarksEntryPersistence.filterFindByGroupId(
103 groupId, start, end, new EntryModifiedDateComparator());
104 }
105
106 public List<BookmarksEntry> getGroupEntries(
107 long groupId, long userId, int start, int end)
108 throws SystemException {
109
110 OrderByComparator orderByComparator = new EntryModifiedDateComparator();
111
112 if (userId <= 0) {
113 return bookmarksEntryPersistence.filterFindByGroupId(
114 groupId, start, end, orderByComparator);
115 }
116 else {
117 return bookmarksEntryPersistence.filterFindByG_U(
118 groupId, userId, start, end, orderByComparator);
119 }
120 }
121
122 public int getGroupEntriesCount(long groupId) throws SystemException {
123 return bookmarksEntryPersistence.filterCountByGroupId(groupId);
124 }
125
126 public int getGroupEntriesCount(long groupId, long userId)
127 throws SystemException {
128
129 if (userId <= 0) {
130 return bookmarksEntryPersistence.filterCountByGroupId(groupId);
131 }
132 else {
133 return bookmarksEntryPersistence.filterCountByG_U(groupId, userId);
134 }
135 }
136
137 public BookmarksEntry openEntry(long entryId)
138 throws PortalException, SystemException {
139
140 BookmarksEntryPermission.check(
141 getPermissionChecker(), entryId, ActionKeys.VIEW);
142
143 return bookmarksEntryLocalService.openEntry(
144 getGuestOrUserId(), entryId);
145 }
146
147 public BookmarksEntry updateEntry(
148 long entryId, long groupId, long folderId, String name, String url,
149 String description, ServiceContext serviceContext)
150 throws PortalException, SystemException {
151
152 BookmarksEntryPermission.check(
153 getPermissionChecker(), entryId, ActionKeys.UPDATE);
154
155 return bookmarksEntryLocalService.updateEntry(
156 getUserId(), entryId, groupId, folderId, name, url, description,
157 serviceContext);
158 }
159
160 }