001: /**
002: * $Id: SOCSTaskStoreTag.java,v 1.8 2005/09/21 10:51:41 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.CalendarException;
023: import com.sun.comclient.calendar.RecurrencePattern;
024:
025: import com.sun.portal.wireless.taglibs.base.Util;
026: import com.sun.portal.wireless.taglibs.cal.TaskCommandTag;
027: import com.sun.portal.wireless.taglibs.cal.socs.SOCSTaskBean;
028: import com.sun.portal.log.common.PortalLogger;
029:
030: /**
031: * SOCSTaskStoreTag - executes a store operation on an SOCSToDo object
032: *
033: * <b>Attributes:</b>
034: * <ul>
035: * <li>name</li>
036: * <ul><li>the Task object to operate on; or parent TaskTag</li></ul>
037: *
038: * <li>modifier</li>
039: * <ul><li>the task modifier; defaults to Task.THISINSTANCE</li></ul>
040: * </ul>
041: *
042: * @version 6.0
043: */
044:
045: public class SOCSTaskStoreTag extends TaskCommandTag {
046:
047: private String modifier = null;
048: private String modifier_val = RecurrencePattern.THIS_INSTANCE;
049:
050: // Create a logger for this class
051: private static Logger debugLogger = PortalLogger
052: .getLogger(SOCSTaskStoreTag.class);
053:
054: /**
055: * the default constructor
056: */
057: public SOCSTaskStoreTag() {
058: super ();
059: }
060:
061: /**
062: * Execute the store operation of the Task
063: * <br><br>
064: * @return true if store is successful
065: * @exception JspException
066: */
067: public boolean execute() throws JspException {
068:
069: ICalendar calendar = getCalendar();
070: SOCSTaskBean task = (SOCSTaskBean) findTask();
071:
072: if (calendar == null) {
073: throw new JspException(
074: "SOCSTaskStoreTag.execute(): no Calendar found");
075: }
076: if (task == null) {
077: throw new JspException(
078: "SOCSTaskStoreTag.execute(): no Event found or specified");
079: }
080:
081: //Get the modifier value
082: String modifierval = getModifierValue(task);
083: debugLogger.log(Level.FINER, "PSMA_CSPWTCS0016", modifierval);
084:
085: if (modifierval == null) {
086: throw new JspException("SOCSTaskStoreTag.execute(): "
087: + "invalid modifier attribute: " + modifierval);
088: }
089:
090: //Store the task
091: try {
092: if (task.isNew()) {
093: // Add task
094: calendar.addTodo(task.getTask(), true);
095: } else {
096: // Modify Task
097: calendar.modifyTodo(task.getTask(), modifierval, true);
098: }
099:
100: } catch (Exception e) {
101: debugLogger.log(Level.INFO, "PSMA_CSPWTCS0017", e);
102: throw new JspException("SOCSTaskStoreTag.execute(): "
103: + "Task modify failed: " + e);
104: }
105:
106: return true;
107: }
108:
109: /**
110: * Set the modifier attribute
111: * <br><br>
112: * @param modifier the format attribute
113: */
114: public void setModifier(String modifier) {
115: debugLogger.log(Level.FINER, "PSMA_CSPWTCS0018", modifier);
116: this .modifier = evalAttribute(modifier);
117: }
118:
119: /**
120: * Get the modifier attribute
121: * <br><br>
122: * @return the modifier attribute
123: */
124: public String getModifier() {
125: debugLogger.log(Level.FINER, "PSMA_CSPWTCS0018", modifier);
126: return modifier;
127: }
128:
129: /**
130: * Get the modifier attribute value
131: * <br><br>
132: * @return the modifier value
133: */
134: public String getModifierValue(SOCSTaskBean task) {
135:
136: if (modifier == null || modifier.trim().equals("")) {
137: modifier = task.getModifier();
138: }
139:
140: debugLogger.log(Level.FINER, "PSMA_CSPWTCS0019", modifier);
141: if (modifier == null || modifier.trim().equals("")) {
142: return RecurrencePattern.THIS_INSTANCE;
143: }
144: debugLogger.log(Level.FINER, "PSMA_CSPWTCS0020", modifier);
145: return modifier;
146: }
147: }
|