01: /*
02: * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.desktop.context;
06:
07: import java.util.Set;
08: import java.util.Map;
09: import java.util.HashMap;
10: import java.util.Collections;
11:
12: import netscape.ldap.LDAPDN;
13:
14: public class CommunityUserMembershipThreadLocalizer {
15: private static final ThreadLocal threadLocal = new ThreadLocal();
16:
17: public static final void set(String userId, Set configKeys) {
18: userId = LDAPDN.normalize(userId.toLowerCase());
19:
20: // use synchronized map. community SDK may update
21: // the cache, but only after desktop is done
22: // accessing it. this is for access within the
23: // community sdk
24: Map m = Collections.synchronizedMap(new HashMap());
25: m.put(userId, configKeys);
26: threadLocal.set(m);
27: }
28:
29: public static final void reset() {
30: threadLocal.set(null);
31: }
32:
33: public static final Set get(String userId) {
34: userId = LDAPDN.normalize(userId.toLowerCase());
35: Map m = (Map) threadLocal.get();
36: if (m == null) {
37: return null;
38: }
39: return (Set) m.get(userId);
40: }
41: }
|