001
014
015 package com.liferay.portlet.journal.model.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portlet.journal.NoSuchFolderException;
019 import com.liferay.portlet.journal.model.JournalFolder;
020 import com.liferay.portlet.journal.model.JournalFolderConstants;
021 import com.liferay.portlet.journal.service.JournalFolderLocalServiceUtil;
022
023 import java.util.ArrayList;
024 import java.util.List;
025
026
029 public class JournalFolderImpl extends JournalFolderBaseImpl {
030
031 public JournalFolderImpl() {
032 }
033
034 @Override
035 public List<Long> getAncestorFolderIds() throws PortalException {
036 List<Long> ancestorFolderIds = new ArrayList<Long>();
037
038 JournalFolder folder = this;
039
040 while (!folder.isRoot()) {
041 try {
042 folder = folder.getParentFolder();
043
044 ancestorFolderIds.add(folder.getFolderId());
045 }
046 catch (NoSuchFolderException nsfe) {
047 if (folder.isInTrash()) {
048 break;
049 }
050
051 throw nsfe;
052 }
053 }
054
055 return ancestorFolderIds;
056 }
057
058 @Override
059 public List<JournalFolder> getAncestors() throws PortalException {
060 List<JournalFolder> ancestors = new ArrayList<JournalFolder>();
061
062 JournalFolder folder = this;
063
064 while (!folder.isRoot()) {
065 folder = folder.getParentFolder();
066
067 ancestors.add(folder);
068 }
069
070 return ancestors;
071 }
072
073 @Override
074 public JournalFolder getParentFolder() throws PortalException {
075 if (getParentFolderId() ==
076 JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
077
078 return null;
079 }
080
081 return JournalFolderLocalServiceUtil.getFolder(getParentFolderId());
082 }
083
084 @Override
085 public boolean isRoot() {
086 if (getParentFolderId() ==
087 JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
088
089 return true;
090 }
091
092 return false;
093 }
094
095 }