1
14
15 package com.liferay.portlet.bookmarks.model.impl;
16
17 import com.liferay.portal.kernel.exception.PortalException;
18 import com.liferay.portal.kernel.exception.SystemException;
19 import com.liferay.portlet.bookmarks.model.BookmarksFolder;
20 import com.liferay.portlet.bookmarks.model.BookmarksFolderConstants;
21 import com.liferay.portlet.bookmarks.service.BookmarksFolderLocalServiceUtil;
22
23 import java.util.ArrayList;
24 import java.util.List;
25
26
31 public class BookmarksFolderImpl
32 extends BookmarksFolderModelImpl implements BookmarksFolder {
33
34 public BookmarksFolderImpl() {
35 }
36
37 public List<BookmarksFolder> getAncestors()
38 throws PortalException, SystemException {
39
40 List<BookmarksFolder> ancestors = new ArrayList<BookmarksFolder>();
41
42 BookmarksFolder folder = this;
43
44 while (true) {
45 if (!folder.isRoot()) {
46 folder = folder.getParentFolder();
47
48 ancestors.add(folder);
49 }
50 else {
51 break;
52 }
53 }
54
55 return ancestors;
56 }
57
58 public BookmarksFolder getParentFolder()
59 throws PortalException, SystemException {
60
61 if (getParentFolderId() ==
62 BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
63
64 return null;
65 }
66
67 return BookmarksFolderLocalServiceUtil.getFolder(getParentFolderId());
68 }
69
70 public boolean isRoot() {
71 if (getParentFolderId() ==
72 BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
73
74 return true;
75 }
76 else {
77 return false;
78 }
79 }
80
81 }