mysql
Class PermissionSql

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

public class PermissionSql
extends AbstractSql

A class that holds various permissions for users.

   CREATE TABLE "perm" (
   propid    | character varying(255) |
   user      | character varying(255) |
   permision | smallint               |
   su        | boolean                |
   
In this setup, the columns have the following meanings:


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static String DEFPERMISSIONFIELD
          The key to the object name in the database.
private static String DEFPROPIDFIELD
          The key to the object name in the database.
private static String DEFSUFIELD
          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_PERMISSIONFIELD
          The key to the object name in the database.
static String KEY_PROPIDFIELD
          The key to the object name in the database.
static String KEY_SUFIELD
          The key to the object name in the database.
static String KEY_USERFIELD
          The key to the object name in the database.
 
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
PermissionSql(Map<String,String> prop)
          Constructs a new proposal sql.
 
Method Summary
 PermissionCollection addProposalPermissions(PermissionCollection permit, String user)
          Add to a PermissionCollection the permissions for the user on all additional proposals.
 boolean setMainUserPermission(String proposal, String pi)
          For the pi, we set all permission to true plus the su-filed.
private  boolean setRow(String prop, String user, short perm, boolean su)
           
 boolean setTeamUserPermission(String proposal, String coi)
          Set permissions for a standard user (team member).
 boolean setUserPermission(String proposal, String coi, EnumSet<DataPermission.Access> perms)
           
 
Methods inherited from class mysql.AbstractSql
getPassword, getTable, getUserName, init, 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_PROPIDFIELD

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

See Also:
Constant Field Values

KEY_USERFIELD

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

See Also:
Constant Field Values

KEY_PERMISSIONFIELD

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

See Also:
Constant Field Values

KEY_SUFIELD

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

See Also:
Constant Field Values

DEFTABLE

private static final String DEFTABLE
The default table name.

See Also:
Constant Field Values

DEFPROPIDFIELD

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

See Also:
Constant Field Values

DEFUSERFIELD

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

See Also:
Constant Field Values

DEFPERMISSIONFIELD

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

See Also:
Constant Field Values

DEFSUFIELD

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

See Also:
Constant Field Values
Constructor Detail

PermissionSql

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

Method Detail

addProposalPermissions

public PermissionCollection addProposalPermissions(PermissionCollection permit,
                                                   String user)
Add to a PermissionCollection the permissions for the user on all additional proposals. The database is queried and permissions in the form of
:user:propid,
       
Please note that expired targets are not added here, refer to #addExpiredPermissions

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

setMainUserPermission

public boolean setMainUserPermission(String proposal,
                                     String pi)
For the pi, we set all permission to true plus the su-filed.


setTeamUserPermission

public boolean setTeamUserPermission(String proposal,
                                     String coi)
Set permissions for a standard user (team member).


setUserPermission

public boolean setUserPermission(String proposal,
                                 String coi,
                                 EnumSet<DataPermission.Access> perms)

setRow

private boolean setRow(String prop,
                       String user,
                       short perm,
                       boolean su)