
com.liferay.journal.model.impl.JournalFolderImpl Maven / Gradle / Ivy
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.journal.model.impl;
import com.liferay.journal.exception.NoSuchFolderException;
import com.liferay.journal.model.JournalFolder;
import com.liferay.journal.model.JournalFolderConstants;
import com.liferay.journal.service.JournalFolderLocalServiceUtil;
import com.liferay.portal.kernel.exception.PortalException;
import java.util.ArrayList;
import java.util.List;
/**
* @author Juan Fernández
*/
public class JournalFolderImpl extends JournalFolderBaseImpl {
@Override
public List getAncestorFolderIds() throws PortalException {
List ancestorFolderIds = new ArrayList<>();
JournalFolder folder = this;
while (!folder.isRoot()) {
try {
folder = folder.getParentFolder();
ancestorFolderIds.add(folder.getFolderId());
}
catch (NoSuchFolderException nsfe) {
if (folder.isInTrash()) {
break;
}
throw nsfe;
}
}
return ancestorFolderIds;
}
@Override
public List getAncestors() throws PortalException {
List ancestors = new ArrayList<>();
JournalFolder folder = this;
while (!folder.isRoot()) {
folder = folder.getParentFolder();
ancestors.add(folder);
}
return ancestors;
}
@Override
public JournalFolder getParentFolder() throws PortalException {
if (getParentFolderId() ==
JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
return null;
}
return JournalFolderLocalServiceUtil.getFolder(getParentFolderId());
}
@Override
public boolean isRoot() {
if (getParentFolderId() ==
JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
return true;
}
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy