11/*
2- * Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions
@@ -47,6 +47,7 @@ public class populate {
4747 static boolean skipSpecial = false ;
4848 static boolean clear = false ;
4949 static boolean dontPreserveFlags = false ;
50+ static boolean warn = false ;
5051
5152 public static void main (String argv []) {
5253 String srcURL = null ;
@@ -70,6 +71,8 @@ public static void main(String argv[]) {
7071 clear = true ;
7172 } else if (argv [optind ].equals ("-P" )) {
7273 dontPreserveFlags = true ;
74+ } else if (argv [optind ].equals ("-W" )) {
75+ warn = true ;
7376 } else if (argv [optind ].equals ("--" )) {
7477 optind ++;
7578 break ;
@@ -222,7 +225,20 @@ private static void copyMessages(Folder src, Folder dst)
222225 msgs [i ] = m ;
223226 }
224227 }
225- src .copyMessages (msgs , dst );
228+ if (warn ) {
229+ // have to copy messages one at a time
230+ for (int i = 0 ; i < msgs .length ; i ++) {
231+ try {
232+ src .copyMessages (new Message [] { msgs [i ] }, dst );
233+ } catch (MessagingException mex ) {
234+ System .out .println ("WARNING: Copy of message " + (i + 1 ) +
235+ " from " + src .getFullName () +
236+ " to " + dst .getFullName () +
237+ " failed: " + mex .toString ());
238+ }
239+ }
240+ } else
241+ src .copyMessages (msgs , dst );
226242 }
227243
228244 private static void printUsage () {
0 commit comments