@Override
  public boolean hasPermission(PermissionChecker permissionChecker, long classPK, String actionId)
      throws Exception {

    BookmarksFolder folder = BookmarksFolderLocalServiceUtil.getFolder(classPK);

    return BookmarksFolderPermission.contains(permissionChecker, folder, actionId);
  }
  @Override
  public void subscribeFolder(long groupId, long folderId) throws PortalException, SystemException {

    BookmarksFolderPermission.check(
        getPermissionChecker(), groupId, folderId, ActionKeys.SUBSCRIBE);

    bookmarksFolderLocalService.subscribeFolder(getUserId(), groupId, folderId);
  }
  @Override
  public BookmarksFolder getFolder(long folderId) throws PortalException, SystemException {

    BookmarksFolder folder = bookmarksFolderLocalService.getFolder(folderId);

    BookmarksFolderPermission.check(getPermissionChecker(), folder, ActionKeys.VIEW);

    return folder;
  }
  @Override
  public void deleteFolder(long folderId) throws PortalException, SystemException {

    BookmarksFolder folder = bookmarksFolderLocalService.getFolder(folderId);

    BookmarksFolderPermission.check(getPermissionChecker(), folder, ActionKeys.DELETE);

    bookmarksFolderLocalService.deleteFolder(folderId);
  }
  @Override
  public void restoreFolderFromTrash(long folderId) throws PortalException, SystemException {

    BookmarksFolder folder = bookmarksFolderLocalService.getFolder(folderId);

    BookmarksFolderPermission.check(getPermissionChecker(), folder, ActionKeys.UPDATE);

    bookmarksFolderLocalService.restoreFolderFromTrash(getUserId(), folderId);
  }
  @Override
  public BookmarksFolder moveFolderToTrash(long folderId) throws PortalException, SystemException {

    BookmarksFolder folder = bookmarksFolderLocalService.getFolder(folderId);

    BookmarksFolderPermission.check(getPermissionChecker(), folder, ActionKeys.DELETE);

    return bookmarksFolderLocalService.moveFolderToTrash(getUserId(), folderId);
  }
  @Override
  public BookmarksFolder moveFolder(long folderId, long parentFolderId)
      throws PortalException, SystemException {

    BookmarksFolder folder = bookmarksFolderLocalService.getFolder(folderId);

    BookmarksFolderPermission.check(getPermissionChecker(), folder, ActionKeys.UPDATE);

    return bookmarksFolderLocalService.moveFolder(folderId, parentFolderId);
  }
  @Override
  public List<Long> getFolderIds(long groupId, long folderId)
      throws PortalException, SystemException {

    BookmarksFolderPermission.check(getPermissionChecker(), groupId, folderId, ActionKeys.VIEW);

    List<Long> folderIds = getSubfolderIds(groupId, folderId, true);

    folderIds.add(0, folderId);

    return folderIds;
  }
  @Override
  public BookmarksFolder addFolder(
      long parentFolderId, String name, String description, ServiceContext serviceContext)
      throws PortalException, SystemException {

    BookmarksFolderPermission.check(
        getPermissionChecker(),
        serviceContext.getScopeGroupId(),
        parentFolderId,
        ActionKeys.ADD_FOLDER);

    return bookmarksFolderLocalService.addFolder(
        getUserId(), parentFolderId, name, description, serviceContext);
  }
  @Override
  public BookmarksFolder updateFolder(
      long folderId,
      long parentFolderId,
      String name,
      String description,
      boolean mergeWithParentFolder,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    BookmarksFolder folder = bookmarksFolderLocalService.getFolder(folderId);

    BookmarksFolderPermission.check(getPermissionChecker(), folder, ActionKeys.UPDATE);

    return bookmarksFolderLocalService.updateFolder(
        getUserId(),
        folderId,
        parentFolderId,
        name,
        description,
        mergeWithParentFolder,
        serviceContext);
  }