Skip to content
This repository has been archived by the owner on Feb 20, 2020. It is now read-only.

Commit

Permalink
add -W option to warn instead of fail when a message can't be copied
Browse files Browse the repository at this point in the history
  • Loading branch information
bshannon committed Aug 9, 2016
1 parent 3cc5d4d commit b9e9c33
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions demo/src/main/java/populate.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -47,6 +47,7 @@ public class populate {
static boolean skipSpecial = false;
static boolean clear = false;
static boolean dontPreserveFlags = false;
static boolean warn = false;

public static void main(String argv[]) {
String srcURL = null;
Expand All @@ -70,6 +71,8 @@ public static void main(String argv[]) {
clear = true;
} else if (argv[optind].equals("-P")) {
dontPreserveFlags = true;
} else if (argv[optind].equals("-W")) {
warn = true;
} else if (argv[optind].equals("--")) {
optind++;
break;
Expand Down Expand Up @@ -222,7 +225,20 @@ private static void copyMessages(Folder src, Folder dst)
msgs[i] = m;
}
}
src.copyMessages(msgs, dst);
if (warn) {
// have to copy messages one at a time
for (int i = 0; i < msgs.length; i++) {
try {
src.copyMessages(new Message[] { msgs[i] }, dst);
} catch (MessagingException mex) {
System.out.println("WARNING: Copy of message " + (i + 1) +
" from " + src.getFullName() +
" to " + dst.getFullName() +
" failed: " + mex.toString());
}
}
} else
src.copyMessages(msgs, dst);
}

private static void printUsage() {
Expand Down

0 comments on commit b9e9c33

Please sign in to comment.