source: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/UserContext.java@ 28965

Last change on this file since 28965 was 27617, checked in by sjm84, 11 years ago

Various improvements and fixes mostly to do with adding depositor functionality

  • Property svn:executable set to *
File size: 1.6 KB
Line 
1package org.greenstone.gsdl3.util;
2
3import org.w3c.dom.Element;
4import org.w3c.dom.NodeList;
5
6public class UserContext
7{
8 protected String _userID = null;
9 protected String _username = null;
10 protected String _lang = null;
11 protected String[] _groups = null;
12
13 public UserContext()
14 {
15 }
16
17 public UserContext(Element xmlRequest)
18 {
19 NodeList elems = xmlRequest.getElementsByTagName("userContext");
20
21 if (elems.getLength() > 0)
22 {
23 Element userContext = (Element) elems.item(0);
24 _userID = userContext.getAttribute(GSXML.USER_ID_ATT);
25 _username = userContext.getAttribute(GSXML.USERNAME_ATT);
26 _lang = userContext.getAttribute(GSXML.LANG_ATT);
27 _groups = userContext.getAttribute(GSXML.GROUPS_ATT).split(",");
28 }
29 }
30
31 public UserContext(String lang, String username, String userID, String[] groups)
32 {
33 _userID = userID;
34 _username = username;
35 _lang = lang;
36 _groups = groups;
37 }
38
39 public void setUsername(String username)
40 {
41 _username = username;
42 }
43
44 public void setLanguage(String lang)
45 {
46 _lang = lang;
47 }
48
49 public void setUserID(String userID)
50 {
51 _userID = userID;
52 }
53
54 public void setGroups(String[] groups)
55 {
56 _groups = groups;
57 }
58
59 public String getLanguage()
60 {
61 if (_lang != null)
62 {
63 return _lang;
64 }
65 return "";
66 }
67
68 public String getUserID()
69 {
70 if (_userID != null)
71 {
72 return _userID;
73 }
74 return "";
75 }
76
77 public String getUsername()
78 {
79 if (_username != null)
80 {
81 return _username;
82 }
83 return "";
84 }
85
86 public String[] getGroups()
87 {
88 if (_groups != null)
89 {
90 return _groups;
91 }
92 return new String[0];
93 }
94}
Note: See TracBrowser for help on using the repository browser.