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

Last change on this file since 29058 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
RevLine 
[24993]1package org.greenstone.gsdl3.util;
2
3import org.w3c.dom.Element;
[27617]4import org.w3c.dom.NodeList;
[24993]5
6public class UserContext
7{
8 protected String _userID = null;
[27617]9 protected String _username = null;
[24993]10 protected String _lang = null;
[27077]11 protected String[] _groups = null;
12
13 public UserContext()
14 {
15 }
16
[24993]17 public UserContext(Element xmlRequest)
18 {
[27617]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 }
[24993]29 }
[26123]30
[27617]31 public UserContext(String lang, String username, String userID, String[] groups)
[26123]32 {
[27617]33 _userID = userID;
34 _username = username;
[26123]35 _lang = lang;
[27077]36 _groups = groups;
[26123]37 }
[27077]38
[27617]39 public void setUsername(String username)
40 {
41 _username = username;
42 }
43
[24993]44 public void setLanguage(String lang)
45 {
46 _lang = lang;
47 }
[27077]48
[24993]49 public void setUserID(String userID)
50 {
51 _userID = userID;
52 }
[27077]53
54 public void setGroups(String[] groups)
55 {
56 _groups = groups;
57 }
58
[24993]59 public String getLanguage()
60 {
[27077]61 if (_lang != null)
[24993]62 {
63 return _lang;
64 }
65 return "";
66 }
[27077]67
[24993]68 public String getUserID()
69 {
[27077]70 if (_userID != null)
[24993]71 {
72 return _userID;
73 }
74 return "";
75 }
[27077]76
[27617]77 public String getUsername()
78 {
79 if (_username != null)
80 {
81 return _username;
82 }
83 return "";
84 }
85
[27077]86 public String[] getGroups()
87 {
88 if (_groups != null)
89 {
90 return _groups;
91 }
92 return new String[0];
93 }
[24993]94}
Note: See TracBrowser for help on using the repository browser.