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 @Override
032 public List<Long> getAncestorFolderIds() throws PortalException {
033 List<Long> ancestorFolderIds = new ArrayList<Long>();
034
035 JournalFolder folder = this;
036
037 while (!folder.isRoot()) {
038 try {
039 folder = folder.getParentFolder();
040
041 ancestorFolderIds.add(folder.getFolderId());
042 }
043 catch (NoSuchFolderException nsfe) {
044 if (folder.isInTrash()) {
045 break;
046 }
047
048 throw nsfe;
049 }
050 }
051
052 return ancestorFolderIds;
053 }
054
055 @Override
056 public List<JournalFolder> getAncestors() throws PortalException {
057 List<JournalFolder> ancestors = new ArrayList<JournalFolder>();
058
059 JournalFolder folder = this;
060
061 while (!folder.isRoot()) {
062 folder = folder.getParentFolder();
063
064 ancestors.add(folder);
065 }
066
067 return ancestors;
068 }
069
070 @Override
071 public JournalFolder getParentFolder() throws PortalException {
072 if (getParentFolderId() ==
073 JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
074
075 return null;
076 }
077
078 return JournalFolderLocalServiceUtil.getFolder(getParentFolderId());
079 }
080
081 @Override
082 public boolean isRoot() {
083 if (getParentFolderId() ==
084 JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
085
086 return true;
087 }
088
089 return false;
090 }
091
092 }