01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05:
06: package com.sun.portal.providers.userinfo.tag;
07:
08: import java.util.*;
09: import java.util.logging.Logger;
10: import java.util.logging.Level;
11:
12: import javax.servlet.http.HttpServletRequest;
13:
14: import com.sun.portal.providers.context.ProviderContext;
15: import com.sun.portal.desktop.context.ContextException;
16: import com.sun.portal.log.common.PortalLogger;
17:
18: /**
19: * this class provides generic access to STRING service attributes with subattributes
20: */
21:
22: public class LocalizedAttributeTag implements ReadTag, WriteTag {
23:
24: private ProviderContext context = null;
25: private static Logger logger = PortalLogger
26: .getLogger(LocalizedAttributeTag.class);
27:
28: public void init(String channel, ProviderContext context,
29: HttpServletRequest req) throws TagException {
30:
31: if (context == null) {
32: throw new TagException(
33: "AttributeTag.init(): provider context was null");
34: }
35:
36: // set desktop context
37: this .context = context;
38:
39: }
40:
41: public void set(String key, String newValue) throws TagException {
42: if (newValue.equals(get(key))) {
43: return;
44: }
45: context.setStringAttribute(key, newValue);
46: return;
47: }
48:
49: public String get(String key) throws TagException {
50: String val;
51: Locale locale = context.getLocale();
52: int idx = key.indexOf(";");
53: String nonL10Nkey;
54: if (idx < 0) {
55: nonL10Nkey = key;
56: } else {
57: nonL10Nkey = key.substring(0, idx);
58: }
59: val = context.getStringAttribute(nonL10Nkey, locale);
60: logger.log(Level.FINEST, "PSCR_CSPPUIT0010", new Object[] {
61: nonL10Nkey, val });
62: return val;
63:
64: }
65: }
|