/** * Returns a given folder's parent only if it's not marked as deleted, * otherwise there will be an exception, because a folder returns a not null parent, * but there is no such item in tree as it's not loaded as separate folder as it's marked as deleted. * * @param folder a folder to obtain a parent * @return a parent folder */ protected Folder getFolderParent(Folder folder) { if (!entityStates.isLoaded(folder, "parent")) { return null; } else { Folder parent = folder.getParent(); return parent == null ? null : PersistenceHelper.isDeleted(parent) ? null : parent; } }