use of javax.mail.util.SharedFileInputStream in project zm-mailbox by Zimbra.
the class TestMain method main.
public static void main(String[] args) throws Exception {
ZimbraLog.toolSetupLog4jConsole("INFO", true, false);
boolean verbose = false;
boolean inputWasIcs = false;
File mimeFile = null;
File icalFile = null;
File tnefFile = null;
File recurInfoFile = null;
String outDirName = null;
int firstTestFileArgIndex = 0;
// Thread.sleep(30000);
for (int i = 0; i < args.length; ++i) {
String arg = args[i];
if (arg != null) {
if (arg.equalsIgnoreCase("-v")) {
verbose = true;
} else if (arg.equalsIgnoreCase("-debug")) {
sLog.setLevel(Level.debug);
} else if (arg.equalsIgnoreCase("-d")) {
if (i >= args.length - 2)
usage();
outDirName = args[i + 1];
firstTestFileArgIndex = i + 2;
;
break;
} else if (arg.equalsIgnoreCase("-i")) {
if (i >= args.length - 1)
usage();
String fname = args[i + 1];
mimeFile = new File(fname);
inputWasIcs = fname.endsWith(".ics");
++i;
} else if (arg.equalsIgnoreCase("-o")) {
if (i >= args.length - 1)
usage();
icalFile = new File(args[i + 1]);
++i;
} else if (arg.equalsIgnoreCase("-t")) {
if (i >= args.length - 1) {
usage();
}
tnefFile = new File(args[i + 1]);
++i;
} else if (arg.equalsIgnoreCase("-r")) {
if (i >= args.length - 1) {
usage();
}
recurInfoFile = new File(args[i + 1]);
++i;
} else {
usage();
}
}
}
if (inputWasIcs) {
SharedFileInputStream sfisMime = null;
ByteArrayOutputStream baos = new ByteArrayOutputStream(10240);
ByteUtil.copy(sfisMime, false, baos, true);
writeIcalendarData(mimeFile, baos, icalFile);
validateIcalendarData(mimeFile, baos);
return;
}
if (outDirName != null) {
File outDir = new File(outDirName);
if (!outDir.exists()) {
sLog.error("Output directory %s does not exist.", outDirName);
return;
}
for (int i = firstTestFileArgIndex; i < args.length; ++i) {
mimeFile = new File(args[i]);
String prefix = mimeFile.getName().replace(".eml", "");
icalFile = new File(outDir, prefix + ".ics");
tnefFile = new File(outDir, prefix + ".tnef");
recurInfoFile = new File(outDir, prefix + ".recurState");
processMimeFile(mimeFile, icalFile, tnefFile, recurInfoFile, verbose);
}
return;
}
// Thread.sleep(30000);
if (mimeFile == null)
usage();
processMimeFile(mimeFile, icalFile, tnefFile, recurInfoFile, verbose);
// List<ZVCalendar> icals = ZCalendarBuilder.buildMulti(bais, UTF8);
// Account dummyAcct = new Account();
// List<Invite> invites = Invite.createFromCalendar(dummyAcct, null, icals, false);
// boolean allGood = true;
// for (Invite inv : invites) {
// try {
// // This doesn't check much...
// inv.sanitize(true);
// } catch (ServiceException e) {
// ZimbraLog.tnef.error(e.getMessage());
// allGood = false;
// }
// }
// if (!allGood)
// System.exit(1);
}
use of javax.mail.util.SharedFileInputStream in project zm-mailbox by Zimbra.
the class Mime method main.
public static void main(String[] args) throws MessagingException, IOException {
String s = URLDecoder.decode("Zimbra%20日本語化の考慮点.txt", "utf-8");
System.out.println(s);
System.out.println(expandNumericCharacterReferences("Zimbra%20日本語化の考慮点.txt@&;&#;&#x;&#༤7"));
MimeMessage mm = new FixedMimeMessage(JMSession.getSession(), new SharedFileInputStream("C:\\Temp\\mail\\24245"));
InputStream is = new RawContentMultipartDataSource(mm, new ContentType(mm.getContentType())).getInputStream();
int num;
byte[] buf = new byte[1024];
while ((num = is.read(buf)) != -1) {
System.out.write(buf, 0, num);
}
}
Aggregations