001: /**
002: * $Id: MAJspCalendarAppHelper.java,v 1.9 2005/09/21 10:48:21 dg154973 Exp $
003: * Copyright 2002 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 iPlanet
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.portal.wireless.providers.calendar;
014:
015: import java.net.URL;
016: import java.net.MalformedURLException;
017: import java.util.*;
018: import java.util.logging.Level;
019: import java.util.logging.Logger;
020:
021: import javax.servlet.http.HttpServletRequest;
022: import javax.servlet.http.HttpServletResponse;
023:
024: import com.sun.comclient.calendar.VEvent;
025: import com.sun.comclient.calendar.VTodo;
026:
027: import com.iplanet.sso.*;
028:
029: import com.sun.ssoadapter.SSOAdapter;
030:
031: import com.sun.portal.providers.calendar.CalendarApplicationHelper;
032: import com.sun.portal.providers.calendar.CalendarProvider;
033: import com.sun.portal.providers.context.ProviderContext;
034: import com.sun.portal.providers.ProviderEditUtility;
035:
036: import com.sun.portal.wireless.taglibs.dispatcher.*;
037: import com.sun.mobile.util.*;
038: import com.sun.portal.log.common.PortalLogger;
039:
040: /**
041: * This class implements the CalendarApplicationHelper interface.
042: * <p>This CalendarApplicationHelper implementation consumes the following
043: * Configuration properties:
044: * <ul>
045: * </ul>
046: *
047: * @version 1.0
048: *
049: */
050:
051: public class MAJspCalendarAppHelper implements
052: CalendarApplicationHelper {
053:
054: public SSOAdapter ssoAdapter = null;
055: public Properties adapterProperties = null;
056: private CalendarProvider provider = null;
057: protected String appName = "";
058: private static Logger logger = PortalLogger
059: .getLogger(MAJspCalendarAppHelper.class);
060:
061: /**
062: * Initialize MAMailAppHelper.
063: *
064: * @param ssoAdapter SSOAdapter object
065: */
066: public void init(CalendarProvider provider, SSOAdapter ssoAdapter) {
067: this .provider = provider;
068: this .ssoAdapter = ssoAdapter;
069: this .adapterProperties = ssoAdapter.getProperties();
070: }
071:
072: /**
073: * Returns a client URL, if supported by the service.
074: */
075: public String getStartURL(CalendarProvider provider,
076: HttpServletRequest request) {
077: return getApplicationURL(provider, request);
078: }
079:
080: /**
081: */
082: private String getApplicationURL(CalendarProvider provider,
083: HttpServletRequest request) {
084:
085: String appURL = null;
086: SSOToken token;
087:
088: try {
089: SSOTokenManager tokenManager = SSOTokenManager
090: .getInstance();
091: token = tokenManager.createSSOToken(request);
092:
093: appURL = "/jsp/default/launchCal.jsp"
094: + "?ci="
095: + ContentUtils.rfc2396Escape("", ssoAdapter
096: .getName());
097:
098: Compressor compressor = Compressor.getCompressor(token);
099:
100: appURL = request.getContextPath()
101: + compressor.compressURL(appURL);
102:
103: appURL = token.encodeURL(appURL);
104:
105: } catch (Exception e) {
106: return null;
107: }
108:
109: return appURL;
110: }
111:
112: public String getEventURL(CalendarProvider provider,
113: HttpServletRequest request, VEvent event) throws Exception {
114: return null;
115: }
116:
117: public String getTaskURL(CalendarProvider provider,
118: HttpServletRequest request, VTodo task) throws Exception {
119: return null;
120: }
121:
122: public StringBuffer getAppPrefsEdit(CalendarProvider aprov,
123: HttpServletRequest req, HttpServletResponse res) {
124: return null;
125: }
126:
127: public URL processAppPrefsEdit(CalendarProvider aprov,
128: HttpServletRequest req, HttpServletResponse res) {
129: return null;
130: }
131:
132: /**
133: * Returns a HTML link containing encoding specific for the app helper
134: */
135:
136: public String getAppHelperEditLink(HttpServletRequest req,
137: ProviderContext pc) {
138:
139: Hashtable tagTable = new Hashtable();
140: StringBuffer link = new StringBuffer();
141: try {
142: link.append(pc.getDesktopURL(req));
143: } catch (Exception e) {
144: return "";
145: }
146: link.append("?action=edit&provider=");
147: link.append(ProviderEditUtility.getRequestParameter("provider",
148: req));
149: link.append("&targetprovider=" + provider.getName());
150: link.append("&containerName=");
151: link.append(ProviderEditUtility.getRequestParameter(
152: "containerName", req));
153: link.append("&appPref=" + this .getName());
154:
155: tagTable.put("editLink", link.toString());
156:
157: String content = null;
158:
159: try {
160: String fontTag = pc.getStringProperty(provider.getName(),
161: "fontFace1", "Sans-serif");
162: tagTable.put("iwtDesktop-fontFace1", fontTag);
163: content = pc.getTemplate(provider.getName(),
164: "ma-edit-link.template", tagTable).toString();
165: if (logger.isLoggable(Level.FINEST)) {
166: String[] param = { "content", content.toString() };
167: logger.log(Level.FINEST, "PSMA_CSPWPCL0001", param);
168: }
169: } catch (Exception e) {
170: if (logger.isLoggable(Level.WARNING))
171: logger.log(Level.WARNING, "PSMA_CSPWPCL0002", e);
172: content = "";
173: }
174:
175: if (logger.isLoggable(Level.FINEST))
176: logger.log(Level.FINEST, "PSMA_CSPWPCL0003", content
177: .toString());
178:
179: return content;
180: }
181:
182: /**
183: * Sets the App Helpers name
184: */
185: public void setName(String name) {
186: this .appName = name;
187: }
188:
189: /**
190: * Gets the App Helpers name
191: */
192: public String getName() {
193: return this.appName;
194: }
195:
196: }
|