The mongodb shell allows to rename a collection and optionally drop the target. It would be great to be able to do this in the java driver, too. I.E.:
public DBCollection rename( String newName, boolean dropTarget )
throws MongoException
{
CommandResult ret =
_db.getSisterDB( "admin" )
.command( BasicDBObjectBuilder.start()
.add( "renameCollection" , _fullName )
.add( "to" , _db._name + "." + newName )
.add( "dropTarget", dropTarget)
.get() );
ret.throwOnError();
resetIndexCache();
return _db.getCollection( newName );
}