1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.bookmarks.service.impl;
16  
17  import com.liferay.portal.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.security.permission.ActionKeys;
20  import com.liferay.portal.service.ServiceContext;
21  import com.liferay.portlet.bookmarks.model.BookmarksFolder;
22  import com.liferay.portlet.bookmarks.service.base.BookmarksFolderServiceBaseImpl;
23  import com.liferay.portlet.bookmarks.service.permission.BookmarksFolderPermission;
24  
25  /**
26   * <a href="BookmarksFolderServiceImpl.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   */
30  public class BookmarksFolderServiceImpl extends BookmarksFolderServiceBaseImpl {
31  
32      public BookmarksFolder addFolder(
33              long parentFolderId, String name, String description,
34              ServiceContext serviceContext)
35          throws PortalException, SystemException {
36  
37          BookmarksFolderPermission.check(
38              getPermissionChecker(), serviceContext.getScopeGroupId(),
39              parentFolderId, ActionKeys.ADD_FOLDER);
40  
41          return bookmarksFolderLocalService.addFolder(
42              null, getUserId(), parentFolderId, name, description,
43              serviceContext);
44      }
45  
46      public void deleteFolder(long folderId)
47          throws PortalException, SystemException {
48  
49          BookmarksFolder folder = bookmarksFolderLocalService.getFolder(
50              folderId);
51  
52          BookmarksFolderPermission.check(
53              getPermissionChecker(), folder, ActionKeys.DELETE);
54  
55          bookmarksFolderLocalService.deleteFolder(folderId);
56      }
57  
58      public BookmarksFolder getFolder(long folderId)
59          throws PortalException, SystemException {
60  
61          BookmarksFolder folder = bookmarksFolderLocalService.getFolder(
62              folderId);
63  
64          BookmarksFolderPermission.check(
65              getPermissionChecker(), folder, ActionKeys.VIEW);
66  
67          return folder;
68      }
69  
70      public BookmarksFolder updateFolder(
71              long folderId, long parentFolderId, String name,
72              String description, boolean mergeWithParentFolder,
73              ServiceContext serviceContext)
74          throws PortalException, SystemException {
75  
76          BookmarksFolder folder = bookmarksFolderLocalService.getFolder(
77              folderId);
78  
79          BookmarksFolderPermission.check(
80              getPermissionChecker(), folder, ActionKeys.UPDATE);
81  
82          return bookmarksFolderLocalService.updateFolder(
83              folderId, parentFolderId, name, description, mergeWithParentFolder,
84              serviceContext);
85      }
86  
87  }