01: package com.teamkonzept.webman.mainint.events;
02:
03: import com.teamkonzept.lib.TKException;
04: import com.teamkonzept.web.TKEvent;
05: import com.teamkonzept.web.TKHTMLTemplate;
06: import com.teamkonzept.web.TKHttpInterface;
07: import com.teamkonzept.webman.mainint.events.*;
08: import de.webman.acl.*;
09: import de.webman.acl.*;
10: import java.util.Properties;
11: import org.apache.log4j.Category;
12:
13: // $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/webman/mainint/events/TKUserEvent.java,v 1.6 2001/08/21 10:38:11 mischa Exp $
14:
15: /**
16: * Simple extension of <CODE>TKEvent</CODE> to provide
17: * correct, Webman-specific login information.
18: *
19: * @since 1.0
20: * @author $Author: mischa $
21: * @version $Revision: 1.6 $
22: */
23: public class TKUserEvent extends TKEvent {
24: /** Logging Framework */
25: private static Category cat = Category
26: .getInstance(TKUserEvent.class);
27:
28: public static final String LOGIN = "LOGIN";
29:
30: /**
31: * selected language of the current user
32: */
33: String selectedLanguage = null;
34: boolean calledGetSelectedLanguage = false;
35:
36: public TKUserEvent(TKHttpInterface http) {
37: super (http);
38: }
39:
40: /**
41: * gibt die Sprache des Users zurueck
42: * falls diese schon einmal ermittelt wurde,
43: * wird das ergebnis des letzten aufrufes zurückgegeben
44: * das hat (abhängig von dem anteil sprachspezifischer tags)
45: * performanzverbesserungen um die 20% zur folge
46: */
47: public String getSelectedLanguage() {
48: // test if this method was called earlier
49: // this is better than to test ( selectedLanguage == null )
50: // to avoid repeating failures in login.getProperties while generating
51: if (!calledGetSelectedLanguage) {
52: // mark that this method is called
53: calledGetSelectedLanguage = true;
54: try {
55: LoginFactory factory = LoginFactory.getInstance();
56: Login login = factory.getLogin(getRemoteUser());
57:
58: Properties props = login.getProperties();
59: selectedLanguage = (String) props.get("LANGUAGE");
60: } catch (Exception e) {
61: // das kann beim Generieren passieren, da gibt es keinen User
62: cat.debug("TKUserEvent : " + e);
63: return null;
64: }
65: }
66: return selectedLanguage;
67: }
68:
69: public void prepTemplate(TKHTMLTemplate template) {
70: super .prepTemplate(template);
71:
72: try {
73: template.set(LOGIN, LoginFactory.getInstance().getLogin(
74: getRemoteUser()).getName());
75: } catch (TKException x) {
76: template.set(LOGIN, getRemoteUser());
77: }
78: }
79:
80: }
|