01: // Copyright %G% Sun Microsystems, Inc. All Rights Reserved.
02: // "%W% %E% Sun Microsystems"
03:
04: package com.sun.portal.wireless.taglibs.commprefs;
05:
06: import com.sun.portal.log.common.PortalLogger;
07: import com.sun.portal.wireless.taglibs.base.Context;
08: import com.sun.portal.wireless.taglibs.base.ContextTag;
09:
10: import javax.servlet.http.HttpServletRequest;
11: import javax.servlet.jsp.JspException;
12: import java.util.logging.Level;
13: import java.util.logging.Logger;
14:
15: public class ABPrefsContextTag extends ContextTag {
16: private static Logger logger = PortalLogger
17: .getLogger(ABPrefsContextTag.class);
18:
19: public Context findContext() throws Exception {
20:
21: String configNameKey = ABPrefsContext.CONTEXT_TYPE
22: + "configName";
23: String ssoAdapterKey = ABPrefsContext.CONTEXT_TYPE
24: + "ssoAdapter";
25:
26: computeConfigName(pageContext, configNameKey, ssoAdapterKey,
27: ABPrefsContext.SSO_CONFIG_TYPE);
28:
29: return ABPrefsContext.getPrefsContext(pageContext);
30: }
31:
32: /**
33: * Remove the context this tag represents from all places
34: * it is referred from.
35: *
36: */
37: public void reset() {
38: logger.log(Level.FINE, "PSMA_CSPWTP0001");
39: Context.reset(pageContext, ABPrefsContext.CONTEXT_CLASS_NAME,
40: ABPrefsContext.CONTEXT_CACHE_CLASS_NAME,
41: ABPrefsContext.CONTEXT_TYPE);
42: }
43:
44: /**
45: * If the context's config needs saving, save and continue evaluating the page
46: *
47: * @return EVAL_PAGE
48: * @exception javax.servlet.jsp.JspException
49: */
50: public int doEndTag() throws JspException {
51:
52: try {
53: HttpServletRequest request = (HttpServletRequest) pageContext
54: .getRequest();
55: ABPrefsContext context = (ABPrefsContext) findContext();
56: context.writeConfiguration(request);
57: } catch (Exception e) {
58: logger.log(Level.WARNING, "PSMA_CSPWTP0002", e);
59: // throw JSPException
60: }
61: return super.doEndTag();
62: }
63:
64: }
|