1 package org.ibex.mail.target;
2 import org.ibex.mail.*;
3 import org.ibex.util.*;
4 import org.ibex.mail.*;
10 /** a fast-write, slow-read place to stash all messages we touch -- in case of a major f*ckup */
11 public class Transcript extends Mailbox {
13 public Transcript(String path) throws MailException { new File(this.path = path).mkdirs(); }
14 private static String lastTime = null;
15 private static int lastCounter = 0;
18 public String getName() { return "Transcript"; }
20 public Mailbox.Iterator iterator() { return null; }
21 public int uidValidity() { return 0; }
22 public int uidNext() { return 0; }
24 /** returns a message identifier */
25 public synchronized int add(Message message) throws MailException {
27 File today = new File(path + File.separatorChar + (new SimpleDateFormat("yy-MMM-dd").format(new Date())));
30 String time = new SimpleDateFormat("HH:mm:ss").format(new Date());
31 synchronized (Transcript.class) {
32 if (lastTime != null && lastTime.equals(time)) {
33 time += "." + (++lastCounter);
39 File target = new File(today.getPath() + File.separatorChar + time + ".txt");
40 OutputStream os = new FileOutputStream(target);
44 } catch (IOException e) { throw new MailException.IOException(e); }