import java.text.*;
/** a fast-write, slow-read place to stash all messages we touch -- in case of a major f*ckup */
-public class Transcript extends Mailbox {
+public class Transcript extends Target {
+
+ public static final Transcript transcript = new Transcript(Mailbox.STORAGE_ROOT + File.separatorChar + "transcript");
+
private String path;
- public Transcript(String path) throws MailException { new File(this.path = path).mkdirs(); }
+ public Transcript(String path) { new File(this.path = path).mkdirs(); }
private static String lastTime = null;
private static int lastCounter = 0;
- // FIXME
- public String getName() { return "Transcript"; }
-
- public Mailbox.Iterator iterator() { return null; }
- public int uidValidity() { return 0; }
- public int uidNext() { return 0; }
-
- /** returns a message identifier */
- public synchronized int add(Message message) throws MailException {
+ public synchronized void accept(Message message) {
try {
File today = new File(path + File.separatorChar + (new SimpleDateFormat("yy-MMM-dd").format(new Date())));
today.mkdirs();
time += "." + (++lastCounter);
} else {
lastTime = time;
+ lastCounter = 0;
}
}
File target = new File(today.getPath() + File.separatorChar + time + ".txt");
OutputStream os = new FileOutputStream(target);
message.dump(os);
+ os.flush();
os.close();
- return -1;
} catch (IOException e) { throw new MailException.IOException(e); }
}
}