001: /*
002: * TemplateContainerProvider.java
003: *
004: * Copyright 2002 Sun Microsystems, Inc. All
005: * rights reserved. Use of this product is subject
006: * to license terms. Federal Acquisitions:
007: * Commercial Software -- Government Users
008: * Subject to Standard License Terms and
009: * Conditions.
010: *
011: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
012: * are trademarks or registered trademarks of Sun Microsystems,
013: * Inc. in the United States and other countries.
014: */
015:
016: package com.sun.portal.providers.containers.template;
017:
018: import java.util.Map;
019: import java.util.HashMap;
020: import java.util.Hashtable;
021: import java.util.Enumeration;
022:
023: import java.net.URL;
024: import java.net.MalformedURLException;
025:
026: import javax.servlet.http.HttpServletRequest;
027: import javax.servlet.http.HttpServletResponse;
028:
029: import com.sun.portal.providers.Provider;
030: import com.sun.portal.providers.ProviderEditTypes;
031: import com.sun.portal.providers.ProviderException;
032: import com.sun.portal.providers.containers.ContainerProviderAdapter;
033: import com.sun.portal.providers.context.ProviderContext;
034: import com.sun.portal.providers.context.ProviderContextException;
035: import com.sun.portal.providers.context.ContainerProviderContext;
036: import com.sun.portal.providers.context.Theme;
037:
038: import com.sun.portal.providers.util.ProviderProperties;
039:
040: import com.sun.portal.desktop.context.DesktopContext;
041: import com.sun.portal.desktop.context.ContextException;
042:
043: public class TemplateContainerProvider extends ContainerProviderAdapter
044: implements ProviderProperties {
045:
046: HttpServletRequest _req = null;
047:
048: public TemplateContainerProvider() {
049: }
050:
051: public void init(String n, HttpServletRequest req)
052: throws ProviderException {
053: super .init(n, req);
054: _req = req;
055: }
056:
057: /*
058: * add standard tags used by the desktop providers
059: */
060: public Hashtable getStandardTags(HttpServletRequest req)
061: throws ProviderException {
062: Hashtable tags = new Hashtable();
063: ProviderContext pc = getProviderContext();
064: String property = null;
065:
066: property = FONT_FACE1;
067: tags.put(FONT_FACE1, getStringProperty(FONT_FACE1));
068: property = PRODUCT_NAME;
069: tags.put(PRODUCT_NAME, getStringProperty(PRODUCT_NAME));
070: tags.put(PARENT_CONTAINER_NAME, pc.getDefaultChannelName());
071: // templates
072:
073: tags.put(MENUBAR, getTemplate(MENUBAR_TEMPLATE));
074: tags.put(CONTENT_LAYOUT, getTemplate(CONTENT_LAYOUT_TEMPLATE));
075: tags.put(TOOLBAR_ROLLOVER, getTemplate(TOOLBAR_ROLLOVER_JS));
076: tags.put(DESKTOP_URL, pc.getDesktopURL(req));
077: tags.put(BULLET_COLOR, getTemplate(BULLET_COLOR_JS));
078: tags.put(BANNER, getTemplate(BANNER_TEMPLATE));
079:
080: // error tags (if any)
081: String err = pc.decodeURLParameter(req.getParameter("error"));
082: if (err != null) {
083: tags.put(ERR_MESSAGE, err);
084: tags
085: .put("inlineError",
086: getTemplate("inlineError.template"));
087: } else {
088: // no error, put in dummy tags so lookup doesn't fail
089: tags.put(ERR_MESSAGE, "");
090: tags.put(INLINE_ERROR, "");
091: }
092:
093: // theme attributes
094:
095: try {
096: tags.put(BG_COLOR, Theme.getAttribute(getName(), pc,
097: BG_COLOR));
098: tags.put(TITLE_BAR_COLOR, Theme.getAttribute(getName(), pc,
099: TITLE_BAR_COLOR));
100: tags.put(BORDER_COLOR, Theme.getAttribute(getName(), pc,
101: BORDER_COLOR));
102: tags.put(FONT_COLOR, Theme.getAttribute(getName(), pc,
103: FONT_COLOR));
104: tags.put(BORDER_WIDTH, Theme.getAttribute(getName(), pc,
105: BORDER_WIDTH));
106: tags.put(FONT_FACE, Theme.getAttribute(getName(), pc,
107: FONT_FACE));
108: if (Theme.getSelectedName(getName(), pc).equals(
109: Theme.CUSTOM_THEME)) {
110: tags.put(THEME_CHANNEL,
111: getStringProperty("customThemeChannel"));
112: } else {
113: tags.put(THEME_CHANNEL,
114: getStringProperty("presetThemeChannel"));
115: }
116: } catch (ProviderContextException pce) {
117: throw new ProviderException(
118: "TemplateContainerProvider.getStardardTags(): failed to obtain theme related attribute ",
119: pce);
120: }
121: return tags;
122: }
123:
124: /*
125: * get the help link for the provider
126: *
127: * @param provider provider name
128: * @return a string of the help link
129: */
130: protected String getHelpLink(String key, HttpServletRequest req)
131: throws ProviderException {
132: try {
133: URL helpLink = getHelp(req, key);
134: if (helpLink != null) {
135: return helpLink.toString();
136: } else {
137: return "";
138: }
139: } catch (Throwable t) {
140: throw new ProviderException(
141: "DesktopProvider.getHelpLink(): could not get help URL for "
142: + key, t);
143: }
144:
145: }
146:
147: }
|