001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
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.BookmarksEntry;
022    import com.liferay.portlet.bookmarks.service.base.BookmarksEntryServiceBaseImpl;
023    import com.liferay.portlet.bookmarks.service.permission.BookmarksEntryPermission;
024    import com.liferay.portlet.bookmarks.service.permission.BookmarksFolderPermission;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class BookmarksEntryServiceImpl extends BookmarksEntryServiceBaseImpl {
030    
031            public BookmarksEntry addEntry(
032                            long groupId, long folderId, String name, String url,
033                            String comments, ServiceContext serviceContext)
034                    throws PortalException, SystemException {
035    
036                    BookmarksFolderPermission.check(
037                            getPermissionChecker(), groupId, folderId, ActionKeys.ADD_ENTRY);
038    
039                    return bookmarksEntryLocalService.addEntry(
040                            getUserId(), groupId, folderId, name, url, comments,
041                            serviceContext);
042            }
043    
044            public void deleteEntry(long entryId)
045                    throws PortalException, SystemException {
046    
047                    BookmarksEntryPermission.check(
048                            getPermissionChecker(), entryId, ActionKeys.DELETE);
049    
050                    bookmarksEntryLocalService.deleteEntry(entryId);
051            }
052    
053            public BookmarksEntry getEntry(long entryId)
054                    throws PortalException, SystemException {
055    
056                    BookmarksEntryPermission.check(
057                            getPermissionChecker(), entryId, ActionKeys.VIEW);
058    
059                    return bookmarksEntryLocalService.getEntry(entryId);
060            }
061    
062            public BookmarksEntry openEntry(long entryId)
063                    throws PortalException, SystemException {
064    
065                    BookmarksEntryPermission.check(
066                            getPermissionChecker(), entryId, ActionKeys.VIEW);
067    
068                    return bookmarksEntryLocalService.openEntry(
069                            getGuestOrUserId(), entryId);
070            }
071    
072            public BookmarksEntry updateEntry(
073                            long entryId, long groupId, long folderId, String name, String url,
074                            String comments, ServiceContext serviceContext)
075                    throws PortalException, SystemException {
076    
077                    BookmarksEntryPermission.check(
078                            getPermissionChecker(), entryId, ActionKeys.UPDATE);
079    
080                    return bookmarksEntryLocalService.updateEntry(
081                            getUserId(), entryId, groupId, folderId, name, url, comments,
082                            serviceContext);
083            }
084    
085    }