1
1
/*
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.
3
3
*
4
4
* Redistribution and use in source and binary forms, with or without
5
5
* modification, are permitted provided that the following conditions
@@ -47,6 +47,7 @@ public class populate {
47
47
static boolean skipSpecial = false ;
48
48
static boolean clear = false ;
49
49
static boolean dontPreserveFlags = false ;
50
+ static boolean warn = false ;
50
51
51
52
public static void main (String argv []) {
52
53
String srcURL = null ;
@@ -70,6 +71,8 @@ public static void main(String argv[]) {
70
71
clear = true ;
71
72
} else if (argv [optind ].equals ("-P" )) {
72
73
dontPreserveFlags = true ;
74
+ } else if (argv [optind ].equals ("-W" )) {
75
+ warn = true ;
73
76
} else if (argv [optind ].equals ("--" )) {
74
77
optind ++;
75
78
break ;
@@ -222,7 +225,20 @@ private static void copyMessages(Folder src, Folder dst)
222
225
msgs [i ] = m ;
223
226
}
224
227
}
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 );
226
242
}
227
243
228
244
private static void printUsage () {
0 commit comments