001: /**
002: * $Id: SOCSTaskDeleteTag.java,v 1.6 2005/09/21 10:51:39 dg154973 Exp $
003: * Copyright 2003 Sun Microsystems, Inc. All
004: * rights reserved. Use of this product is subject
005: * to license terms. Federal Acquisitions:
006: * Commercial Software -- Government Users
007: * Subject to Standard License Terms and
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.portal.wireless.taglibs.cal.socs;
014:
015: import java.util.*;
016: import java.util.logging.Logger;
017: import java.util.logging.Level;
018: import javax.servlet.jsp.*;
019: import javax.servlet.jsp.tagext.*;
020:
021: import com.sun.comclient.calendar.ICalendar;
022: import com.sun.comclient.calendar.RecurrencePattern;
023: import com.sun.comclient.calendar.CalendarException;
024:
025: import com.sun.portal.wireless.taglibs.base.*;
026: import com.sun.portal.wireless.taglibs.cal.*;
027: import com.sun.portal.log.common.PortalLogger;
028:
029: /**
030: * SOCSTaskDeleteTag - execute a delete operation on a Todo object
031: *
032: * <b>Attributes:</b>
033: * <ul>
034: * <li>name</li>
035: * <ul><li>the Todo object to operate on; or parent TaskTag</li><ul>
036: *
037: * <li>modifier</li>
038: * <ul><li>the task modifier; defaults to Task.THISINSTANCE</li><ul>
039: * </ul>
040: *
041: * @version 6.0
042: */
043:
044: public class SOCSTaskDeleteTag extends TaskDeleteTag {
045:
046: // Create a logger for this class
047: private static Logger debugLogger = PortalLogger
048: .getLogger(SOCSTaskDeleteTag.class);
049:
050: /**
051: * the default constructor
052: */
053: public SOCSTaskDeleteTag() {
054: super ();
055: }
056:
057: String modifier = RecurrencePattern.THIS_INSTANCE;
058:
059: /**
060: * Execute the delete operation of the Todo
061: * <br><br>
062: * @return true if deletion is successful
063: * @exception JspException
064: */
065:
066: public boolean execute() throws JspException {
067: ICalendar calendar = getCalendar();
068: SOCSTaskBean task = (SOCSTaskBean) findTask();
069:
070: if (calendar == null) {
071: throw new JspException("SOCSTaskDeleteTag.execute(): "
072: + "No Calendar found");
073: }
074:
075: if (task == null) {
076: throw new JspException("SOCSTaskDeleteTag.execute(): "
077: + "no Task found or specified");
078: }
079:
080: String modifierval = getModifierValue(task);
081: if (modifierval == null) {
082: throw new JspException("SOCSTaskDeleteTag.execute(): "
083: + "invalid modifier attribute: " + modifier);
084: }
085:
086: try {
087: calendar.deleteTodo(task.getTask(), modifierval, true);
088: } catch (CalendarException ce) {
089: debugLogger.log(Level.INFO, "PSMA_CSPWTCS0015", ce);
090: throw new JspException(
091: "SOCSTaskDeleteTag.execute(): task delete failed: "
092: + ce);
093: }
094: return true;
095: }
096:
097: /**
098: * Set the modifier attribute
099: * <br><br>
100: * @param modifier the format attribute
101: */
102: public void setModifier(String modifier) {
103: this .modifier = evalAttribute(modifier);
104: }
105:
106: /**
107: * Get the modifier attribute
108: * <br><br>
109: * @return the modifier attribute
110: */
111: public String getModifier() {
112: return modifier;
113: }
114:
115: /**
116: * Get the modifier attribute value
117: * <br><br>
118: * @return the modifier value
119: */
120:
121: public String getModifierValue(SOCSTaskBean task) {
122: if (modifier == null || modifier.trim().equals("")) {
123: modifier = task.getModifier();
124: }
125: if (modifier == null || modifier.trim().equals("")) {
126: return RecurrencePattern.THIS_INSTANCE;
127: }
128: return modifier;
129: }
130:
131: }
|