* Move folders and bookmarks to a new folder.
*/
public String move() {
try {
BookmarkManager bmgr = WebloggerFactory.getWeblogger().getBookmarkManager();
log.debug("Moving folders and bookmarks to folder - "+getTargetFolderId());
// Move folders to new parent folder.
String folders[] = getSelectedFolders();
WeblogBookmarkFolder parent = bmgr.getFolder(getTargetFolderId());
if (null != folders) {
for (int i = 0; i < folders.length; i++) {
WeblogBookmarkFolder fd = bmgr.getFolder(folders[i]);
// Don't move folder into itself.
if (!fd.getId().equals(parent.getId()) &&
!parent.descendentOf(fd)) {
bmgr.moveFolder(fd, parent);
} else {
addMessage("bookmarksForm.warn.notMoving", fd.getName());
}
}
}
// Move bookmarks to new parent folder.
String bookmarks[] = getSelectedBookmarks();
if (null != bookmarks) {
for (int j = 0; j < bookmarks.length; j++) {
// maybe we should be using folder.addBookmark()?
WeblogBookmark bd = bmgr.getBookmark(bookmarks[j]);
bd.setFolder(parent);
bmgr.saveBookmark(bd);
}
}
// flush changes
WebloggerFactory.getWeblogger().flush();