com.sonymobile.jenkins.plugins.teamview
Class UserUtil

java.lang.Object
  extended by com.sonymobile.jenkins.plugins.teamview.UserUtil

public final class UserUtil
extends Object

Utility methods for reading users. Most utility methods in User are private, so there are copies of those here. Let's keep our fingers crossed that they don't change too much in core down the road.

Author:
Robert Sandell <robert.sandell@sonymobile.com>

Method Summary
static void checkViewsReadPermission(String idOrFullName)
          Checks that the current user has access to the provided user's views.
static hudson.XmlFile getConfigFile(String idOrFullName)
          The user configuration file.
protected static File getConfigFileFor(String idOrFullName)
          The config file for the user.
protected static File getRootDir()
          Gets the directory where Hudson stores user information.
protected static String toStorageId(String idOrFullName)
          Performs a bunch of string replacing to get to what the user id directory would be named.
static List<hudson.model.View> unmarshalViews(String idOrFullName)
          Reads the user from disk and returns the MyViewsProperty inside.
static boolean userExists(String idOrFullName)
          Checks if there is a config.xml file for the provided user id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

unmarshalViews

public static List<hudson.model.View> unmarshalViews(String idOrFullName)
                                              throws IOException,
                                                     ParserConfigurationException,
                                                     SAXException,
                                                     TransformerException
Reads the user from disk and returns the MyViewsProperty inside.

Parameters:
idOrFullName - the user id.
Returns:
the views property.
Throws:
IOException - if so.
TransformerException - if something goes wrong in the XML to String transformation.
SAXException - if something goes wrong in the initial parsing of the config file.
ParserConfigurationException - if a DocumentBuilder cannot be created.

userExists

public static boolean userExists(String idOrFullName)
Checks if there is a config.xml file for the provided user id.

Parameters:
idOrFullName - the user name
Returns:
true if so.

getRootDir

protected static File getRootDir()
Gets the directory where Hudson stores user information.

Returns:
jenkins-root/users

getConfigFile

public static hudson.XmlFile getConfigFile(String idOrFullName)
The user configuration file.

Parameters:
idOrFullName - the user id
Returns:
The config file for the user

getConfigFileFor

protected static File getConfigFileFor(String idOrFullName)
The config file for the user.

Parameters:
idOrFullName - the user id
Returns:
the file pointer, even if it doesn't exist

toStorageId

protected static String toStorageId(String idOrFullName)
Performs a bunch of string replacing to get to what the user id directory would be named. Copied from User.get(String, boolean)

Parameters:
idOrFullName - the user id
Returns:
the converted string

checkViewsReadPermission

public static void checkViewsReadPermission(String idOrFullName)
Checks that the current user has access to the provided user's views.

Parameters:
idOrFullName - id of the user to get the views from.


Copyright © 2004-2013. All Rights Reserved.