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:
10: import javax.servlet.http.HttpServletRequest;
11:
12: import com.sun.portal.providers.context.ProviderContext;
13: import com.sun.portal.providers.context.ProviderContextException;
14:
15: /**
16: * this class provides generic access to STRING DP properties
17: */
18:
19: public class DPTag implements ReadTag, WriteTag {
20:
21: private ProviderContext context = null;
22: private String channel = null;
23:
24: public void init(String channel, ProviderContext context,
25: HttpServletRequest req) throws TagException {
26: this .channel = channel;
27: if (context == null) {
28: throw new TagException(
29: "DPTag.init(): provider context was null");
30: }
31: // set desktop context
32: this .context = context;
33:
34: }
35:
36: public void set(String key, String newValue) throws TagException {
37: if (newValue.equals(get(key))) {
38: return;
39: }
40:
41: try {
42: List localeFilters = context.getLocalePropertiesFilters();
43: context.setStringProperty(channel, key, newValue,
44: localeFilters);
45: } catch (ProviderContextException pce) {
46: throw new TagException(
47: "DPTag.set(): Failed to set property " + key);
48: }
49: return;
50: }
51:
52: public String get(String key) throws TagException {
53: try {
54: return context.getStringProperty(channel, key, true);
55: } catch (ProviderContextException pce) {
56: throw new TagException(
57: "DPTag.get(): Failed to get property " + key);
58: }
59: }
60: }
|