/* Remove existing Bookmarks and Empty Folders */
private List<IFolderChild> excludeExisting(List<IFolderChild> folderChilds) {
IBookMarkDAO dao = DynamicDAO.getDAO(IBookMarkDAO.class);
for (Iterator<IFolderChild> iterator = folderChilds.iterator(); iterator.hasNext();) {
IFolderChild child = iterator.next();
/* Bookmark (exclude if another Bookmark with same Link exists) */
if (child instanceof IBookMark) {
IBookMark bm = (IBookMark) child;
if (dao.exists(bm.getFeedLinkReference()))
iterator.remove();
}
/* Bin (exclude if another Bin with same name Exists at same Location) */
else if (child instanceof INewsBin) {
INewsBin bin = (INewsBin) child;
if (CoreUtils.existsNewsBin(bin))
iterator.remove();
}
/* Search (exclude if another Search with same name Exists at same Location and same Conditions) */
else if (child instanceof ISearchMark) {
ISearchMark search = (ISearchMark) child;
if (CoreUtils.existsSearchMark(search))
iterator.remove();
}
/* Folder */
else if (child instanceof IFolder) {
excludeExisting((IFolder) child);
}
}
/* Exclude Empty Folders */
for (Iterator<IFolderChild> iterator = folderChilds.iterator(); iterator.hasNext();) {
IFolderChild child = iterator.next();
if (child instanceof IFolder && ((IFolder) child).getChildren().isEmpty())
iterator.remove();
}
return folderChilds;