hudson.model
Class User

java.lang.Object
  extended by hudson.model.AbstractModelObject
      extended by hudson.model.User
All Implemented Interfaces:
ModelObject, Saveable, SearchableModelObject, SearchItem, AccessControlled, Comparable<User>

@ExportedBean
public class User
extends AbstractModelObject
implements AccessControlled, Saveable, Comparable<User>

Represents a user.

In Hudson, User objects are created in on-demand basis; for example, when a build is performed, its change log is computed and as a result commits from users who Hudson has never seen may be discovered. When this happens, new User object is created.

If the persisted record for an user exists, the information is loaded at that point, but if there's no such record, a fresh instance is created from thin air (this is where UserPropertyDescriptor.newInstance(User) is called to provide initial UserProperty objects.

Such newly created User objects will be simply GC-ed without ever leaving the persisted record, unless save() method is explicitly invoked (perhaps as a result of a browser submitting a configuration.)

Author:
Kohsuke Kawaguchi

Field Summary
 
Fields inherited from interface hudson.model.Saveable
NOOP
 
Method Summary
 void addProperty(UserProperty p)
          Updates the user object by adding a property.
 boolean canDelete()
          With ADMINISTER permission, can delete users with persisted data but can't delete self.
 void checkPermission(Permission permission)
          Convenient short-cut for getACL().checkPermission(permission)
static void clear()
          Stop gap work around.
 int compareTo(User that)
           
static User current()
          Gets the User object representing the currently logged-in user, or null if the current user is anonymous.
 void delete()
          Deletes the data directory and removes this user from Hudson.
 void doConfigSubmit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Accepts submission from the configuration page.
 void doDoDelete(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Deletes this user from Hudson.
 void doRssAll(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
           
 void doRssFailed(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
           
 void doRssLatest(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
           
 void doSubmitDescription(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Accepts the new description.
static User get(String idOrFullName)
          Gets the User object by its id or full name.
static User get(String idOrFullName, boolean create)
          Gets the User object by its id or full name.
 String getAbsoluteUrl()
          The URL of the user page.
 ACL getACL()
          Obtains the ACL associated with this object.
static Collection<User> getAll()
          Gets all the users.
 List<UserProperty> getAllProperties()
          List of all UserPropertys exposed primarily for the remoting API.
 Api getApi()
          Exposed remote API.
 RunList getBuilds()
          Gets the list of Builds that include changes by this user, by the timestamp order.
 String getDescription()
           
 String getDisplayName()
          Returns the user name.
 Object getDynamic(String token)
           
 String getFullName()
          Gets the human readable name of this user.
 String getId()
           
 Set<AbstractProject<?,?>> getProjects()
          Gets all the AbstractProjects that this user has committed to.
 Map<Descriptor<UserProperty>,UserProperty> getProperties()
          Gets the user properties configured for this user.
<T extends UserProperty>
T
getProperty(Class<T> clazz)
          Gets the specific property, or null.
 String getSearchUrl()
          Returns the URL of this item relative to the parent SearchItem.
static User getUnknown()
          Gets the fallback "unknown" user instance.
 String getUrl()
           
 boolean hasPermission(Permission permission)
          Convenient short-cut for getACL().hasPermission(permission)
static void reload()
          Reloads the configuration from disk.
 void save()
          Save the settings to a file.
 void setFullName(String name)
          Sets the human readable name of thie user.
 String toString()
           
 
Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

compareTo

public int compareTo(User that)
Specified by:
compareTo in interface Comparable<User>

getId

@Exported
public String getId()

getUrl

public String getUrl()

getSearchUrl

public String getSearchUrl()
Description copied from interface: SearchItem
Returns the URL of this item relative to the parent SearchItem.

Specified by:
getSearchUrl in interface SearchItem
Returns:
URL like "foo" or "foo/bar". The path can end with '/'. The path that starts with '/' will be interpreted as the absolute path (within the context path of Hudson.)

getAbsoluteUrl

@Exported(visibility=999)
public String getAbsoluteUrl()
The URL of the user page.


getFullName

@Exported(visibility=999)
public String getFullName()
Gets the human readable name of this user. This is configurable by the user.

Returns:
never null.

setFullName

public void setFullName(String name)
Sets the human readable name of thie user.


getDescription

@Exported
public String getDescription()

getProperties

public Map<Descriptor<UserProperty>,UserProperty> getProperties()
Gets the user properties configured for this user.


addProperty

public void addProperty(UserProperty p)
                 throws IOException
Updates the user object by adding a property.

Throws:
IOException

getAllProperties

@Exported(name="property",
          inline=true)
public List<UserProperty> getAllProperties()
List of all UserPropertys exposed primarily for the remoting API.


getProperty

public <T extends UserProperty> T getProperty(Class<T> clazz)
Gets the specific property, or null.


doSubmitDescription

public void doSubmitDescription(org.kohsuke.stapler.StaplerRequest req,
                                org.kohsuke.stapler.StaplerResponse rsp)
                         throws IOException,
                                javax.servlet.ServletException
Accepts the new description.

Throws:
IOException
javax.servlet.ServletException

getUnknown

public static User getUnknown()
Gets the fallback "unknown" user instance.

This is used to avoid null User instance.


get

public static User get(String idOrFullName,
                       boolean create)
Gets the User object by its id or full name.

Parameters:
create - If true, this method will never return null for valid input (by creating a new User object if none exists.) If false, this method will return null if User object with the given name doesn't exist.

get

public static User get(String idOrFullName)
Gets the User object by its id or full name.


current

public static User current()
Gets the User object representing the currently logged-in user, or null if the current user is anonymous.

Since:
1.172

getAll

public static Collection<User> getAll()
Gets all the users.


reload

public static void reload()
Reloads the configuration from disk.


clear

public static void clear()
Stop gap work around. Don't use it. To be removed in the trunk.


getDisplayName

public String getDisplayName()
Returns the user name.

Specified by:
getDisplayName in interface ModelObject

getBuilds

public RunList getBuilds()
Gets the list of Builds that include changes by this user, by the timestamp order. TODO: do we need some index for this?


getProjects

public Set<AbstractProject<?,?>> getProjects()
Gets all the AbstractProjects that this user has committed to.

Since:
1.191

toString

public String toString()
Overrides:
toString in class Object

save

public void save()
          throws IOException
Save the settings to a file.

Specified by:
save in interface Saveable
Throws:
IOException - if the persistence failed.

delete

public void delete()
            throws IOException
Deletes the data directory and removes this user from Hudson.

Throws:
IOException - if we fail to delete.

getApi

public Api getApi()
Exposed remote API.


doConfigSubmit

public void doConfigSubmit(org.kohsuke.stapler.StaplerRequest req,
                           org.kohsuke.stapler.StaplerResponse rsp)
                    throws IOException,
                           javax.servlet.ServletException,
                           Descriptor.FormException
Accepts submission from the configuration page.

Throws:
IOException
javax.servlet.ServletException
Descriptor.FormException

doDoDelete

public void doDoDelete(org.kohsuke.stapler.StaplerRequest req,
                       org.kohsuke.stapler.StaplerResponse rsp)
                throws IOException,
                       javax.servlet.ServletException
Deletes this user from Hudson.

Throws:
IOException
javax.servlet.ServletException

doRssAll

public void doRssAll(org.kohsuke.stapler.StaplerRequest req,
                     org.kohsuke.stapler.StaplerResponse rsp)
              throws IOException,
                     javax.servlet.ServletException
Throws:
IOException
javax.servlet.ServletException

doRssFailed

public void doRssFailed(org.kohsuke.stapler.StaplerRequest req,
                        org.kohsuke.stapler.StaplerResponse rsp)
                 throws IOException,
                        javax.servlet.ServletException
Throws:
IOException
javax.servlet.ServletException

doRssLatest

public void doRssLatest(org.kohsuke.stapler.StaplerRequest req,
                        org.kohsuke.stapler.StaplerResponse rsp)
                 throws IOException,
                        javax.servlet.ServletException
Throws:
IOException
javax.servlet.ServletException

getACL

public ACL getACL()
Description copied from interface: AccessControlled
Obtains the ACL associated with this object.

Specified by:
getACL in interface AccessControlled
Returns:
never null.

checkPermission

public void checkPermission(Permission permission)
Description copied from interface: AccessControlled
Convenient short-cut for getACL().checkPermission(permission)

Specified by:
checkPermission in interface AccessControlled

hasPermission

public boolean hasPermission(Permission permission)
Description copied from interface: AccessControlled
Convenient short-cut for getACL().hasPermission(permission)

Specified by:
hasPermission in interface AccessControlled

canDelete

public boolean canDelete()
With ADMINISTER permission, can delete users with persisted data but can't delete self.


getDynamic

public Object getDynamic(String token)


Copyright © 2004-2013 Hudson. All Rights Reserved.