提交 5d92508e 编写于 作者: K kohsuke

doc improvement.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3379 71c3de6d-444a-0410-be80-ed276b4c234a
上级 254eeab5
...@@ -50,8 +50,13 @@ public class User extends AbstractModelObject { ...@@ -50,8 +50,13 @@ public class User extends AbstractModelObject {
private User(String id) { private User(String id) {
this.id = id; this.id = id;
this.fullName = id; // fullName defaults to name this.fullName = id; // fullName defaults to name
load();
}
// load the other data from disk if it's available /**
* Loads the other data from disk if it's available.
*/
private synchronized void load() {
XmlFile config = getConfigFile(); XmlFile config = getConfigFile();
try { try {
if(config.exists()) if(config.exists())
...@@ -60,6 +65,7 @@ public class User extends AbstractModelObject { ...@@ -60,6 +65,7 @@ public class User extends AbstractModelObject {
LOGGER.log(Level.SEVERE, "Failed to load "+config,e); LOGGER.log(Level.SEVERE, "Failed to load "+config,e);
} }
properties.clear();
// allocate default instances if needed. // allocate default instances if needed.
// doing so after load makes sure that newly added user properties do get reflected // doing so after load makes sure that newly added user properties do get reflected
for (UserPropertyDescriptor d : UserProperties.LIST) { for (UserPropertyDescriptor d : UserProperties.LIST) {
...@@ -138,21 +144,28 @@ public class User extends AbstractModelObject { ...@@ -138,21 +144,28 @@ public class User extends AbstractModelObject {
rsp.sendRedirect("."); // go to the top page rsp.sendRedirect("."); // go to the top page
} }
/**
* Gets the fallback "unknown" user instance.
* <p>
* This is used to avoid null {@link User} instance.
*/
public static User getUnknown() { public static User getUnknown() {
return get("unknown"); return get("unknown");
} }
public static User get(String name) { /**
if(name==null) * Gets the {@link User} object by its id.
*/
public static User get(String id) {
if(id==null)
return null; return null;
name = name.replace('\\', '_').replace('/', '_'); id = id.replace('\\', '_').replace('/', '_');
synchronized(byName) { synchronized(byName) {
User u = byName.get(name); User u = byName.get(id);
if(u==null) { if(u==null) {
u = new User(name); u = new User(id);
byName.put(name,u); byName.put(id,u);
} }
return u; return u;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册