01: /*
02: * DeleteMessageTag
03: * @(#)DeleteMessageTag.java 1.3 04/01/01 Sun Microsystems
04: *
05: * Copyright 2000 Sun Microsystems, Inc. All rights reserved.
06: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
07: */
08:
09: package com.sun.portal.wireless.taglibs.mail;
10:
11: import javax.servlet.jsp.*;
12: import javax.servlet.jsp.tagext.*;
13:
14: import javax.mail.*;
15: import javax.mail.internet.*;
16: import javax.mail.search.*;
17:
18: import com.sun.portal.wireless.taglibs.base.*;
19: import com.sun.portal.log.common.PortalLogger;
20:
21: import java.util.logging.Logger;
22: import java.util.logging.Level;
23:
24: /**
25: *
26: * @version 1.0
27: */
28: public class DeleteMessageTag extends CommandTag {
29: private static Logger logger = PortalLogger
30: .getLogger(DeleteMessageTag.class);
31:
32: private String idx = null;
33:
34: public boolean execute() throws JspException {
35:
36: MailContext mc;
37: try {
38: mc = MailContext.getContext(pageContext);
39: } catch (Exception e) {
40: throw new JspException(this .getClass().getName()
41: + ".execute(): Couldn't get mail context: "
42: + e.getMessage());
43: }
44:
45: try {
46:
47: int i = 0;
48: i = Integer.parseInt(idx);
49:
50: MsgBean[] msgs = mc.getMsgsCollection();
51: msgs[i].delete();
52:
53: // TODO: opimization that could be done is compact the array
54:
55: } catch (Exception e) {
56: logger.log(Level.FINER, "PSMA_CSPWTM0005", e);
57: mc.setErrorCode("");
58: return false;
59: }
60:
61: return true;
62: }
63:
64: /**
65: * Specifies which message from the collection in which
66: * is to be marked for deletion.
67: */
68:
69: public void setIndex(String idx) {
70: this.idx = evalAttribute(idx);
71: }
72:
73: }
|