if (record.isDeleted()) {
throw new MailboxException("Mailbox has been deleted", MailboxException.LOCAL_BUT_DELETED);
} else if (openMailboxes.containsKey(absoluteName)) {
mailbox = (ACLMailbox) openMailboxes.get(absoluteName);
if (!mailbox.hasLookupRights(user)) {
throw new AccessControlException("No lookup rights.");
} else {
Integer c = (Integer)mailboxCounts.get(absoluteName);
int count = c.intValue() + 1;
mailboxCounts.put(absoluteName, (new Integer(count)));
getLogger().info("Request no " + count + " for " + absoluteName);
return mailbox;
}
} else {
String owner = record.getUser();
String key = getPath(absoluteName, owner);
ObjectInputStream in = null;
try {
in = new ObjectInputStream( new FileInputStream(key + File.separator + FileMailbox.MAILBOX_FILE_NAME) );
mailbox = (FileMailbox) in.readObject();
setupLogger(mailbox);
mailbox.configure(conf);
mailbox.contextualize(context);
mailbox.compose(compMgr);
mailbox.reinitialize();
} catch (Exception e) {
e.printStackTrace();
throw new
RuntimeException("Exception caught while reading FileMailbox: " + e);
} finally {
if (in != null) {
try {
in.close();
} catch (Exception ignored) {
}
}
notifyAll();
}
if (!mailbox.hasLookupRights(user)) {
throw new AccessControlException("No lookup rights.");
}
openMailboxes.put(absoluteName, mailbox);
mailboxCounts.put(absoluteName, new Integer(1));
return mailbox;
}