001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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    }