01: /**
02: * $Id: TaskStoreTag.java,v 1.9 2005/09/21 10:51:17 dg154973 Exp $
03: * Copyright 2003 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.wireless.taglibs.cal;
14:
15: import java.util.*;
16: import java.util.logging.Logger;
17: import java.util.logging.Level;
18: import javax.servlet.jsp.*;
19: import javax.servlet.jsp.tagext.*;
20:
21: import com.sun.comclient.calendar.ICalendar;
22: import com.sun.comclient.calendar.CalendarException;
23:
24: import com.sun.portal.wireless.taglibs.base.Util;
25: import com.sun.portal.log.common.PortalLogger;
26:
27: /**
28: * TaskStoreTag - execute a store operation on an Event object
29: *
30: * <b>Attributes:</b>
31: * <ul>
32: * <li>name</li>
33: * <ul><li>the Todo object to operate on; or parent TaskTag</li></ul>
34: *
35: * <li>modifier</li>
36: * <ul><li>the Todo modifier; defaults to <code>Task.THISINSTANCE</code></li></ul>
37: * </ul>
38: * @version 6.0
39: * @since 1.0
40: */
41:
42: public class TaskStoreTag extends TaskCommandTag {
43:
44: // Create a logger for this class
45: private static Logger debugLogger = PortalLogger
46: .getLogger(TaskStoreTag.class);
47:
48: /**
49: * the default constructor
50: */
51: public TaskStoreTag() {
52: super ();
53: }
54:
55: /**
56: * Execute the store of the Task
57: * <br><br>
58: * @return true if store is successful
59: * @exception JspException
60: */
61:
62: public boolean execute() throws JspException {
63: ICalendar calendar = getCalendar();
64: TaskBean task = findTask();
65: if (calendar == null) {
66: throw new JspException(
67: "TaskStoreTag.execute(): no Calendar found");
68: }
69: if (task == null) {
70: throw new JspException("TaskStoreTag.execute(): "
71: + "No Event found or specified");
72: }
73: String modifierval = getModifierValue(task);
74: if (modifierval == null) {
75: throw new JspException("TaskStoreTag.execute(): "
76: + "invalid modifier attribute: " + modifierval);
77: }
78: try {
79: if (task.isNew()) {
80: // Add task
81: calendar.addTodo(task.getTask(), true);
82: } else {
83: // Modify Task
84: calendar.modifyTodo(task.getTask(), modifierval, true);
85: }
86:
87: } catch (Exception e) {
88: debugLogger.log(Level.INFO, "PSMA_CSPWTC0012", e);
89: throw new JspException(
90: "TaskStoreTag.execute(): Task modify failed: " + e);
91: }
92: return true;
93: }
94: }
|