001
014
015 package com.liferay.portlet.bookmarks.model.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.util.StringBundler;
020 import com.liferay.portal.kernel.util.StringPool;
021 import com.liferay.portlet.bookmarks.NoSuchFolderException;
022 import com.liferay.portlet.bookmarks.model.BookmarksFolder;
023 import com.liferay.portlet.bookmarks.service.BookmarksFolderLocalServiceUtil;
024
025
028 public class BookmarksEntryImpl extends BookmarksEntryBaseImpl {
029
030 public BookmarksEntryImpl() {
031 }
032
033 @Override
034 public String buildTreePath() throws PortalException, SystemException {
035 StringBundler sb = new StringBundler();
036
037 buildTreePath(sb, getFolder());
038
039 return sb.toString();
040 }
041
042 @Override
043 public BookmarksFolder getFolder() throws PortalException, SystemException {
044 if (getFolderId() <= 0) {
045 return new BookmarksFolderImpl();
046 }
047
048 return BookmarksFolderLocalServiceUtil.getFolder(getFolderId());
049 }
050
051 @Override
052 public BookmarksFolder getTrashContainer()
053 throws PortalException, SystemException {
054
055 BookmarksFolder folder = null;
056
057 try {
058 folder = getFolder();
059 }
060 catch (NoSuchFolderException nsfe) {
061 return null;
062 }
063
064 if (folder.isInTrash()) {
065 return folder;
066 }
067
068 return folder.getTrashContainer();
069 }
070
071 @Override
072 public boolean isInTrashContainer() {
073 try {
074 if (getTrashContainer() != null) {
075 return true;
076 }
077 }
078 catch (Exception e) {
079 }
080
081 return false;
082 }
083
084 protected void buildTreePath(StringBundler sb, BookmarksFolder folder)
085 throws PortalException, SystemException {
086
087 if (folder == null) {
088 sb.append(StringPool.SLASH);
089 }
090 else {
091 buildTreePath(sb, folder.getParentFolder());
092
093 sb.append(folder.getFolderId());
094 sb.append(StringPool.SLASH);
095 }
096 }
097
098 }