getSubject());
mDTO.setSent(null);
mDTO.setMsgID(new Integer(i).toString());
mDTO.setMsgType("received");
mDTO.setFilename(null);
messages.add(mDTO);
}
} catch (Exception e) {
e.printStackTrace();
log.error("Could not retrieve Inbox contents: " + e);
} finally {
try {
if (folder != null) {
folder.close(false);
}
if (store != null) {
store.close();
}
} catch (Exception e) {
log.error("Error closing folder or store: " + e);
}
}
return messages;
CHAPTER 4 n INSTAMAIL: AN AJAX-BASED WEBMAIL CLIENT 179
} // End getInboxContents().
/**
* This method retrieves the contents of the Sent Messages folder.
*
* @param sc ServletContext of the incoming request.
* @return A collection of MessageDTOs.
*/
public Collection getSentMessagesContents(ServletContext sc) {
Collection
messages = new ArrayList();
try {
// First, get a list of File objects for all the messages stored
// in WEB-INF.
String path = sc.getRealPath("WEB-INF");
File dir = new File(path);
FileFilter fileFilter = new FileFilter() {
public boolean accept(File file) {
if (file.isDirectory()) {
return false;
}
if (!file.getName().startsWith("msg_")) {
return false;
}
return true;
}
};
File[] files = dir.
Pages:
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338