-// Copyright 2000-2005 the Contributors, as shown in the revision logs.
+// Copyright 2007 the Contributors, as shown in the revision logs.
// Licensed under the Apache Public Source License 2.0 ("the License").
// You may not use this file except in compliance with the License.
import java.text.*;
/** a node on the "mailbox tree" */
-public abstract class MailboxTree extends JS.Obj {
+public interface MailboxTree {
public abstract MailboxTree slash(String name, boolean create);
public abstract String[] children();
- public Mailbox getMailbox() { return null; }
+ public abstract void rmdir(String subdir);
+ public abstract void rename(String subdir, MailboxTree newParent, String newName); /* FIXME: IMAP semantics require creating parent dirs */
+ public abstract Mailbox getMailbox();
+
+ public static class Wrapper implements MailboxTree {
+ protected MailboxTree mt;
+ public Wrapper(MailboxTree mt) { this.mt = mt; }
+ public MailboxTree slash(String name, boolean create) { return mt.slash(name, create); }
+ public String[] children() { return mt.children(); }
+ public void rmdir(String subdir) { mt.rmdir(subdir); }
+ public void rename(String subdir, MailboxTree newParent, String newName) { mt.rename(subdir, newParent, newName); }
+ public Mailbox getMailbox() { return mt.getMailbox(); }
+ }
+
+ public static class AclWrapper extends Wrapper {
+ protected Acl.Entry acl;
+ public AclWrapper(MailboxTree mt, Acl.Entry acl) { super(mt); this.acl = acl; }
+ public Mailbox getMailbox() {
+ return new Mailbox.AclWrapper(mt.getMailbox(), acl) {
+ public MailboxTree slash(String name, boolean create) {
+ return MailboxTree.AclWrapper.this.slash(name, create);
+ }
+ };
+ }
+ public MailboxTree slash(String name, boolean create) {
+ if (!acl.mkdir) create = false;
+ if (!acl.list) return null;
+ return super.slash(name, create);
+ }
+ public void rmdir(String subdir) {
+ if (!acl.delete) throw new Acl.PermissionDenied();
+ super.rmdir(subdir);
+ }
+ public void rename(String subdir, MailboxTree newParent, String newName) {
+ // FIXME: acl-checking on parent?
+ if (!acl.delete) throw new Acl.PermissionDenied();
+ super.rename(subdir, newParent, newName);
+ }
+ }
+
}