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.BookmarksFolder;
022    import com.liferay.portlet.bookmarks.service.base.BookmarksFolderServiceBaseImpl;
023    import com.liferay.portlet.bookmarks.service.permission.BookmarksFolderPermission;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    public class BookmarksFolderServiceImpl extends BookmarksFolderServiceBaseImpl {
029    
030            public BookmarksFolder addFolder(
031                            long parentFolderId, String name, String description,
032                            ServiceContext serviceContext)
033                    throws PortalException, SystemException {
034    
035                    BookmarksFolderPermission.check(
036                            getPermissionChecker(), serviceContext.getScopeGroupId(),
037                            parentFolderId, ActionKeys.ADD_FOLDER);
038    
039                    return bookmarksFolderLocalService.addFolder(
040                            getUserId(), parentFolderId, name, description, serviceContext);
041            }
042    
043            public void deleteFolder(long folderId)
044                    throws PortalException, SystemException {
045    
046                    BookmarksFolder folder = bookmarksFolderLocalService.getFolder(
047                            folderId);
048    
049                    BookmarksFolderPermission.check(
050                            getPermissionChecker(), folder, ActionKeys.DELETE);
051    
052                    bookmarksFolderLocalService.deleteFolder(folderId);
053            }
054    
055            public BookmarksFolder getFolder(long folderId)
056                    throws PortalException, SystemException {
057    
058                    BookmarksFolder folder = bookmarksFolderLocalService.getFolder(
059                            folderId);
060    
061                    BookmarksFolderPermission.check(
062                            getPermissionChecker(), folder, ActionKeys.VIEW);
063    
064                    return folder;
065            }
066    
067            public BookmarksFolder updateFolder(
068                            long folderId, long parentFolderId, String name,
069                            String description, boolean mergeWithParentFolder,
070                            ServiceContext serviceContext)
071                    throws PortalException, SystemException {
072    
073                    BookmarksFolder folder = bookmarksFolderLocalService.getFolder(
074                            folderId);
075    
076                    BookmarksFolderPermission.check(
077                            getPermissionChecker(), folder, ActionKeys.UPDATE);
078    
079                    return bookmarksFolderLocalService.updateFolder(
080                            folderId, parentFolderId, name, description, mergeWithParentFolder,
081                            serviceContext);
082            }
083    
084    }