mysql
Class UserSql

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by mysql.AbstractSql
                  extended by mysql.UserSql
All Implemented Interfaces:
Cloneable, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying

public class UserSql
extends AbstractSql

A class that allows access to a database containing the different users on STELLA. It contains contact information for the automatic notification system as well as some default settings in terms of color

 CREATE TABLE "user" 
    user   | character varying(255) | not null
    affil  | character varying(255) |
    pubkey | text                   |
    email  | character varying(255) |
    farbe  | character varying(255) |
    notify | text                   |
    passwd | character varying(255) |
    Indexes:
    "user_pkey" PRIMARY KEY, btree ("user")
    Triggers:
    _st1_logtrigger_8 AFTER INSERT OR DELETE OR UPDATE ON "user" FOR EACH ROW EXECUTE PROCEDURE _st1.logtrigger('_st1', '8', 'kvvvvvv')
 
In this setup, the columns have the following meanings:


Nested Class Summary
static class UserSql.AddUser
          Adds a new user with the command line.
private static class UserSql.SqlProfile
          A user profile that is constructed from a database entry.
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static EnumSet<DataPermission.Access> AFFILACCESS
          The default action on affil-data.
private  EnumSet<UserProfile.Affil> affilallow
          The set of allowed affiliations.
private static String DEFAFFILALLOWED
          The coma-separated list of allowed affiliations.
private static String DEFAFFILFIELD
          The key to the object name in the database.
private static String DEFCOLORFIELD
          The key to the object name in the database.
private static String DEFEMAILFIELD
          The key to the object name in the database.
private static String DEFNOTIFYALLOWED
          The coma-separated list of allowed notification triggers.
private static String DEFNOTIFYFIELD
          The key to the object name in the database.
private static String DEFPASSWDFIELD
          The key to the object name in the database.
private static String DEFPUBKEYFIELD
          The key to the object name in the database.
private static String DEFTABLE
          The default table name.
private static String DEFUSERFIELD
          The key to the object name in the database.
static String KEY_AFFILALLOWED
          The key to the allowed affiliations.
static String KEY_AFFILFIELD
          The key to the object name in the database.
static String KEY_COLORFIELD
          The key to the object name in the database.
static String KEY_EMAILFIELD
          The key to the object name in the database.
static String KEY_NOTIFYALLOWED
          The key to the allowed notify actions.
static String KEY_NOTIFYFIELD
          The key to the object name in the database.
static String KEY_PASSWDFIELD
          The key to the object name in the database.
static String KEY_PUBKEYFIELD
          The key to the object name in the database.
static String KEY_USERFIELD
          The key to the object name in the database.
private  EnumSet<UserProfile.Notifies> notifyallow
          The set of allowed notifications.
 
Fields inherited from class mysql.AbstractSql
KEY_TABLE
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Constructor Summary
UserSql(Map<String,String> prop)
          Constructs a new proposal sql.
 
Method Summary
 PermissionCollection addUserPermissions(PermissionCollection permit, String user)
          Add to a PermissionCollection the permissions for the user of the given name.
 boolean addUserProfile(String username, List<UserProfile.Affil> aa, javax.mail.Address email, Collection<UserProfile.Notifies> notify)
          Adds a new user to the table.
 boolean addUserProfile(String username, List<UserProfile.Affil> aa, javax.mail.Address email, Collection<UserProfile.Notifies> notify, boolean mail)
          Adds a new user to the table.
 boolean addUserProfile(String username, List<UserProfile.Affil> affil, javax.mail.Address email, Collection<UserProfile.Notifies> notify, Color paint, boolean mail)
          Adds a new user to the table.
private  UserProfile fromNextRow(ResultSet single)
          Returns the next user profile parsed from the result set.
private static UserProfile fromNextRow(ResultSet single, String f1, String f2, String f3, String f4, String f5, String f6, String f7)
          Returns the next user profile parsed from the result set.
static List<UserProfile> getAllUserProfiles()
          Returns all user profiles found.
static List<UserProfile> getAllUserProfiles(String table)
          Returns all user profiles found.
private  int getMemberCount(UserProfile.Affil affil)
          Returns the number of entries to the queried affiliation.
 UserProfile getUserProfile(String name)
          Returns the user profile from the user name.
 void init()
          Convert the properties of allowed affiliations and notifications into enum-sets.
 
Methods inherited from class mysql.AbstractSql
getPassword, getTable, getUserName, isEntry
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 

Field Detail

KEY_USERFIELD

public static final String KEY_USERFIELD
The key to the object name in the database.

See Also:
Constant Field Values

KEY_AFFILFIELD

public static final String KEY_AFFILFIELD
The key to the object name in the database.

See Also:
Constant Field Values

KEY_PUBKEYFIELD

public static final String KEY_PUBKEYFIELD
The key to the object name in the database.

See Also:
Constant Field Values

KEY_EMAILFIELD

public static final String KEY_EMAILFIELD
The key to the object name in the database.

See Also:
Constant Field Values

KEY_COLORFIELD

public static final String KEY_COLORFIELD
The key to the object name in the database.

See Also:
Constant Field Values

KEY_NOTIFYFIELD

public static final String KEY_NOTIFYFIELD
The key to the object name in the database.

See Also:
Constant Field Values

KEY_PASSWDFIELD

public static final String KEY_PASSWDFIELD
The key to the object name in the database.

See Also:
Constant Field Values

KEY_AFFILALLOWED

public static final String KEY_AFFILALLOWED
The key to the allowed affiliations.

See Also:
Constant Field Values

KEY_NOTIFYALLOWED

public static final String KEY_NOTIFYALLOWED
The key to the allowed notify actions.

See Also:
Constant Field Values

DEFTABLE

private static final String DEFTABLE
The default table name. Fuckin' reserved word used.

See Also:
Constant Field Values

DEFUSERFIELD

private static final String DEFUSERFIELD
The key to the object name in the database. Reserved word used.

See Also:
Constant Field Values

DEFAFFILFIELD

private static final String DEFAFFILFIELD
The key to the object name in the database.

See Also:
Constant Field Values

DEFPUBKEYFIELD

private static final String DEFPUBKEYFIELD
The key to the object name in the database.

See Also:
Constant Field Values

DEFEMAILFIELD

private static final String DEFEMAILFIELD
The key to the object name in the database.

See Also:
Constant Field Values

DEFCOLORFIELD

private static final String DEFCOLORFIELD
The key to the object name in the database.

See Also:
Constant Field Values

DEFNOTIFYFIELD

private static final String DEFNOTIFYFIELD
The key to the object name in the database.

See Also:
Constant Field Values

DEFPASSWDFIELD

private static final String DEFPASSWDFIELD
The key to the object name in the database.

See Also:
Constant Field Values

DEFAFFILALLOWED

private static final String DEFAFFILALLOWED
The coma-separated list of allowed affiliations.


DEFNOTIFYALLOWED

private static final String DEFNOTIFYALLOWED
The coma-separated list of allowed notification triggers.


AFFILACCESS

private static final EnumSet<DataPermission.Access> AFFILACCESS
The default action on affil-data.


affilallow

private EnumSet<UserProfile.Affil> affilallow
The set of allowed affiliations.


notifyallow

private EnumSet<UserProfile.Notifies> notifyallow
The set of allowed notifications.

Constructor Detail

UserSql

public UserSql(Map<String,String> prop)
Constructs a new proposal sql.

Method Detail

init

public void init()
Convert the properties of allowed affiliations and notifications into enum-sets.

Specified by:
init in interface Initializable
Overrides:
init in class AbstractSql

addUserPermissions

public PermissionCollection addUserPermissions(PermissionCollection permit,
                                               String user)
Add to a PermissionCollection the permissions for the user of the given name. Uses a global permission on user's PI targets plus specific permissions found in the permission table. Additionally adds the group-specific affiliations.

Returns:
The augmented permission collection.
Throws:
SecurityException - if the permission collection is read-only.

getUserProfile

public UserProfile getUserProfile(String name)
Returns the user profile from the user name.


fromNextRow

private UserProfile fromNextRow(ResultSet single)
                         throws SQLException
Returns the next user profile parsed from the result set. The result set is advanced to the next row. Null is returned if no more data has been encountered.

Throws:
SQLException

fromNextRow

private static UserProfile fromNextRow(ResultSet single,
                                       String f1,
                                       String f2,
                                       String f3,
                                       String f4,
                                       String f5,
                                       String f6,
                                       String f7)
                                throws SQLException
Returns the next user profile parsed from the result set. The result set is advanced to the next row. Null is returned if no more data has been encountered.

Throws:
SQLException

getAllUserProfiles

public static List<UserProfile> getAllUserProfiles()
Returns all user profiles found.


getAllUserProfiles

public static List<UserProfile> getAllUserProfiles(String table)
Returns all user profiles found.


addUserProfile

public boolean addUserProfile(String username,
                              List<UserProfile.Affil> aa,
                              javax.mail.Address email,
                              Collection<UserProfile.Notifies> notify)
Adds a new user to the table. If the color is not specified, we try to guess it from the affiliation. This method sends notification to the user on first entry.

Returns:
true, if user was added.
Throws:
IllegalArgumentException - If any of the input is not allowed. This applies to affil, email and notify.

addUserProfile

public boolean addUserProfile(String username,
                              List<UserProfile.Affil> aa,
                              javax.mail.Address email,
                              Collection<UserProfile.Notifies> notify,
                              boolean mail)
Adds a new user to the table. If the color is not specified, we try to guess it from the affiliation.

Returns:
true, if user was added.
Throws:
IllegalArgumentException - If any of the input is not allowed. This applies to affil, email and notify.

addUserProfile

public boolean addUserProfile(String username,
                              List<UserProfile.Affil> affil,
                              javax.mail.Address email,
                              Collection<UserProfile.Notifies> notify,
                              Color paint,
                              boolean mail)
Adds a new user to the table. If the color is not specified, we try to guess it from the affiliation.

Throws:
IllegalArgumentException - If any of the input is not allowed. This applies to affil, email and notify.

getMemberCount

private int getMemberCount(UserProfile.Affil affil)
Returns the number of entries to the queried affiliation.