/*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* - Neither the name of Oracle nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copy folder hierarchies between different Stores. This is a useful
* utility to populate new (and possibly empty) mail stores. Specify
* both the source and destination folders as URLs.
*
* @author John Mani
* @author Bill Shannon
*/
public class populate {
static boolean force = false;
static boolean skipSpecial = false;
static boolean clear = false;
static boolean dontPreserveFlags = false;
boolean debug = false;
int optind;
debug = true;
force = true;
skipSpecial = true;
clear = true;
dontPreserveFlags = true;
optind++;
break;
printUsage();
} else {
break;
}
}
try {
printUsage();
}
// Get source folder
// Check if the source URL has a folder specified. If
// not, we use the default folder
s.connect();
srcFolder = s.getDefaultFolder();
} else {
}
}
// Set up destination folder
// Check if the destination URL has a folder specified. If
// not, we use the source folder name
s.connect();
} else
dstFolder.getFullName());
return;
}
}
// Close the respective stores.
} catch (MessagingException mex) {
}
}
throws MessagingException {
// Create it.
boolean dstHoldsOnlyFolders = false;
// might not be able to create a folder that holds both
Folder.HOLDS_MESSAGES)) {
// might only be able to create one type (Gmail)
dst.getFullName());
return;
}
}
}
// Copy over any messges from src to dst
if (dstHoldsOnlyFolders) {
" because destination holds only folders");
}
} else
}
} else {
// Copy over any messges from src to dst
}
}
// Copy over subfolders
if (srcHasChildren) {
// skip special directories?
if (skipSpecial) {
continue;
}
}
}
}
/**
* Copy message from src to dst. If dontPreserveFlags is set
* we first copy the messages to memory, clear all the flags,
* and then copy to the destination.
*/
throws MessagingException {
if (dontPreserveFlags) {
msgs[i] = m;
}
}
}
private static void printUsage() {
"-s source_url -d dest_url");
"protocol://username:password@hostname/foldername");
" in which case, the source foldername is used");
}
}