* org.grouplite.mail.ui.mail.IMailConnection#moveFolder(org.grouplite.mail
* .ui.mail.IMailFolder, org.grouplite.mail.ui.mail.IMailFolder)
*/
public IMailFolder moveFolder( String sourceFolderId, String targetFolderId ) throws MailFolderException {
IMailFolder sourceFolder = null;
IMailFolder targetFolder = null;
try {
String newFolderName;
sourceFolder = getMailFolderById( sourceFolderId );
targetFolder = getMailFolderById( targetFolderId );
if ( sourceFolder != null ) {
if ( targetFolder == null ) {
newFolderName = sourceFolder.getName();
}
else {
newFolderName = targetFolder.getId() + getFolderSeparator() + sourceFolder.getName();
}
if ( sourceFolder.isOpen() ) {
sourceFolder.close( false );
}
if ( targetFolder != null && targetFolder.isOpen() ) {
targetFolder.close( false );
}
Folder newFolder = this.store.getFolder( newFolderName );
if ( !newFolder.exists() ) {
sourceFolder.renameTo( newFolder );