Expresso 5-6

com.jcorporate.expresso.services.dbobj
Class UserGroup

java.lang.Object
  extended bycom.jcorporate.expresso.core.dataobjects.BaseDataObject
      extended bycom.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
          extended bycom.jcorporate.expresso.core.dbobj.DBObject
              extended bycom.jcorporate.expresso.core.dbobj.SecuredDBObject
                  extended bycom.jcorporate.expresso.services.dbobj.SecurityDBObject
                      extended bycom.jcorporate.expresso.services.dbobj.UserGroup
All Implemented Interfaces:
Cacheable, ContextNested, DataObject, LookupInterface, Securable, Serializable

public class UserGroup
extends SecurityDBObject

UserGroup is a grouping of a number of users for security purposes. UserGroups are equivalent to 'roles' in other terminology.

Since:
Expresso 1.0
Author:
Michael Nash
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.jcorporate.expresso.core.dbobj.DBObject
DBObject.FieldError, DBObject.FieldUpdate
 
Field Summary
static String ADMIN_GROUP
           
static String ALL_USERS_GROUP
          used as default group for all users who register and their reg domain has no other group set
static String DEMO_GROUP
           
static int GROUP_DESCRIP_MAX_LEN
           
static String GROUP_DESCRIPTION
           
static String GROUP_NAME_FIELD
           
static int GROUP_NAME_MAX_LEN
           
static String NOT_REG_USERS_GROUP
           
static String TABLE_NAME
           
static String UNKNOWN_USERS_GROUP
          groups created as part of DBTool.setupSecurity bootstrap
 
Fields inherited from class com.jcorporate.expresso.services.dbobj.SecurityDBObject
SECURITY_CONTEXT, SECURITY_OBJECTS
 
Fields inherited from class com.jcorporate.expresso.core.dbobj.SecuredDBObject
ADD, ALL_FUNCTIONS, CACHE_NAME, CACHE_TTY, DELETE, SEARCH, SYSTEM_ACCOUNT, SYSTEM_ACCOUNT_NAME, UPDATE
 
Fields inherited from class com.jcorporate.expresso.core.dbobj.DBObject
ATTRIBUTE_ERROR, ATTRIBUTE_ERROR_MESSAGE, ATTRIBUTE_PAGE_LIMIT, BIG_DECIMAL_ZERO, EMAIL_MASK, EVENT_ADD, EVENT_DELETE, EVENT_UPDATE, FLOAT_MASK, INT_MASK, IS_CHECK_RELATIONAL_INTEGRITY, UPDATE_CHANGED_ONLY, WHERE_KEYWORD
 
Fields inherited from class com.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
anyFieldsDistinct, anyFieldsToRetrieve, appendCustomWhere, caseSensitiveQuery, customWhereClause, dbKey, distinctFields, localConnection, LONGBINARY_READ_DEFAULT_SIZE, maxRecords, myClassName, myUpdates, offsetRecord, recordSet, retrieveFields, sMetadataMap, sortKeys
 
Fields inherited from class com.jcorporate.expresso.core.dataobjects.BaseDataObject
currentStatus, globalMask
 
Fields inherited from interface com.jcorporate.expresso.core.dataobjects.DataObject
STATUS_CURRENT, STATUS_DELETED, STATUS_NEW, STATUS_UPDATED
 
Constructor Summary
UserGroup()
          construct object with superuser privileges
UserGroup(ControllerRequest request)
          For using DBObjects within Controllers.
UserGroup(DBConnection localConnection)
          constructor for db transactions; object will have superuser privileges unless you separately call setRequestingUid()
UserGroup(int uid)
          Initializes the usergroup with the permissions of the given user.
 
Method Summary
protected  void checkAllReferredToBy()
          Check referential integrity of objects referring to this object
 void delete()
          Extend the super.delete() method to first delete the GroupMembers elements that refer to the group being deleted
static List getAllGroups()
          convenience method
static UserGroup getGroup(String groupname)
           
 String getGroupDescription()
          convenience method
 String getGroupName()
          convenience method
 Vector getValues()
          Gets the valid values, specifically it returns a map of GroupNames to GroupDescriptions
 void populateDefaultValues()
          Populates the default user groups.
 void setGroupName(String groupName)
          convenience method
protected  void setupFields()
          Method to set up the fields for this database object.
 
Methods inherited from class com.jcorporate.expresso.services.dbobj.SecurityDBObject
overrideDataContext, setDataContext, setDBName
 
Methods inherited from class com.jcorporate.expresso.core.dbobj.SecuredDBObject
add, canRequesterAdd, canRequesterDelete, canRequesterRead, canRequesterUpdate, checkAllowed, copyAttributes, count, createSecurityCache, deleteAll, find, getRequestingUid, getString, getString, getString, getString, getString, getString, getSystemUid, instantiate, isAllowed, retrieve, search, searchAndRetrieveList, searchAndRetrieveList, setRequestingUid, update
 
Methods inherited from class com.jcorporate.expresso.core.dbobj.DBObject
addDetail, addField, addField, addFieldError, addFoundKeys, addIfNeeded, addIndex, addKey, addOrUpdate, addSortKey, addTransition, addVirtualField, addVirtualField, addVirtualField, addVirtualField, average, basicAdd, cacheIsChangedComparison, checkAllRefs, checkAllRefsPublic, checkDeleteDetailPerm, checkField, checkRef, checkRef, clear, clearDistinctFields, clearError, clearFieldsToRetrieve, clearSortKeys, containsWildCards, delete, deleteAll, deleteDetails, denotesRange, equals, forKey, formatDateTime, get, getAllAttributes, getAttribute, getAttributesIterator, getBooleanFieldValue, getCacheSize, getCacheStatsMap, getCacheUtil, getCheckZeroUpdate, getCustomWhereClause, getDataContext, getDataField, getDataTransferObject, getDBName, getDetails, getDistinctFieldCount, getDistinctFields, getField, getFieldBigDecimal, getFieldBoolean, getFieldByte, getFieldByteArray, getFieldData, getFieldDate, getFieldDecimalFormatted, getFieldDouble, getFieldErrorMessage, getFieldFloat, getFieldInt, getFieldLong, getFieldMetaData, getFieldShort, getFieldsToRetrieveCount, getFilterClass, getFoundCount, getFoundKeysArray, getIndexArray, getISOValuesDefault, getISOValuesDefault, getISOValuesDefault, getKey, getKeyFieldListIterator, getLength, getLengthInt, getLocalConnection, getLocale, getLogger, getLookupObject, getMax, getMax, getMaxRecords, getMyKeys, getMyUpdatesArray, getOffsetRecord, getPatternMatcher, getPrecision, getSerializedForm, getStringFilter, getThisDBbj, getThisDBObj, getValidValueDescrip, getValidValues, getValidValuesList, getValuesDefault, getValuesDefault, getValuesDefault, hasError, hasErrors, haveAllKeys, initialize, isCached, isChanged, isDistinct, isEmpty, isFieldDistinct, isFieldNull, isFieldsToRetrieve, isFieldToRetrieve, isMultiValued, isReadOnly, isSecret, isVirtual, loadFromConnection, logChange, max, min, newInstance, noNewLine, noQuotes, notifyListeners, referredToBy, removeAttribute, removeFromCache, retrieveFromCache, saveBinaryField, search, set, setAttribute, setCacheSize, setCharset, setCheckZeroUpdate, setConnection, setConnection, setCustomWhereClause, setCustomWhereClause, setDataField, setDataTransferObject, setDefaultValue, setDescription, setField, setField, setField, setField, setField, setField, setField, setField, setField, setField, setFieldData, setFieldData, setFieldDistinct, setFieldsToRetrieve, setFilterClass, setFilterClass, setKeys, setLocale, setLookupField, setLookupObject, setMask, setMaxRecords, setMultiValued, setName, setOffsetRecord, setReadOnly, setSchema, setSecret, setSortKey, setStringFilter, setStringFiltersOnAll, setTargetDbSchema, setTargetTable, sqlAggrFunction, sum, toDebugString, update, updateAll, updateAll, verify
 
Methods inherited from class com.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
addInParam, addOutParam, buildWhereClause, buildWhereClauseBuffer, checkZeroUpdate, constructNewMetaData, createAndExecuteSearch, createAndRunStoreProcedure, getConnectionPool, getCustomStringFieldValue, getDef, getDistinctFieldArrayList, getExecutor, getFieldsToRetrieveIterator, getJDBCMetaData, getJDBCUtil, getMappedDataContext, getMetaData, getQueryInterface, getSerialForm, loadFromConnection, makeLimitationStub, quoteIfNeeded, runStoredProcedure, runStoredProcedureAndRetrieveList, selectFieldString, setCaseSensitiveQuery, setDBConnectionPool, setMappedDataContext, setOriginalDBName, setTargetStoreProcedure
 
Methods inherited from class com.jcorporate.expresso.core.dataobjects.BaseDataObject
getGlobalMask, getStatus, isGlobalMasked, setFieldsWithDefaults, setGlobalMask, setStatus
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GROUP_NAME_FIELD

public static final String GROUP_NAME_FIELD
See Also:
Constant Field Values

GROUP_DESCRIPTION

public static final String GROUP_DESCRIPTION
See Also:
Constant Field Values

GROUP_NAME_MAX_LEN

public static final int GROUP_NAME_MAX_LEN
See Also:
Constant Field Values

GROUP_DESCRIP_MAX_LEN

public static final int GROUP_DESCRIP_MAX_LEN
See Also:
Constant Field Values

TABLE_NAME

public static final String TABLE_NAME
See Also:
Constant Field Values

ALL_USERS_GROUP

public static final String ALL_USERS_GROUP
used as default group for all users who register and their reg domain has no other group set

See Also:
SimpleRegistration, Constant Field Values

DEMO_GROUP

public static final String DEMO_GROUP
See Also:
Constant Field Values

UNKNOWN_USERS_GROUP

public static final String UNKNOWN_USERS_GROUP
groups created as part of DBTool.setupSecurity bootstrap

See Also:
Constant Field Values

NOT_REG_USERS_GROUP

public static final String NOT_REG_USERS_GROUP
See Also:
Constant Field Values

ADMIN_GROUP

public static final String ADMIN_GROUP
See Also:
Constant Field Values
Constructor Detail

UserGroup

public UserGroup()
          throws DBException
construct object with superuser privileges

See Also:
SecuredDBObject

UserGroup

public UserGroup(int uid)
          throws DBException
Initializes the usergroup with the permissions of the given user.

Parameters:
uid - the User's uid
Throws:
DBException - upon instantion error

UserGroup

public UserGroup(ControllerRequest request)
          throws DBException
For using DBObjects within Controllers. Initializes based upon the current user and the requested db. [Of course this can be modified later]

Parameters:
request - - The controller request handed to you by the framework.

UserGroup

public UserGroup(DBConnection localConnection)
          throws DBException
constructor for db transactions; object will have superuser privileges unless you separately call setRequestingUid()

Parameters:
localConnection - the connection which should be used, typically because of an ongoing transaction
Method Detail

checkAllReferredToBy

protected void checkAllReferredToBy()
                             throws DBException
Check referential integrity of objects referring to this object

Overrides:
checkAllReferredToBy in class DBObject
Throws:
DBException - If the integrity cannot be verified

delete

public void delete()
            throws DBException
Extend the super.delete() method to first delete the GroupMembers elements that refer to the group being deleted

Specified by:
delete in interface DataObject
Overrides:
delete in class SecuredDBObject
Throws:
DBException - if delete is not allowed for the current user

setupFields

protected void setupFields()
                    throws DBException
Description copied from class: DBObject
Method to set up the fields for this database object. This method should be defined in the implementing object and should make calls to addField, addKey, setMultiValued, etc. as required to define the content of the DBObject. Each setupFields method should call "super.setupFields()" so that field definitions can be "inheritcable"

Overrides:
setupFields in class DBObject
Throws:
DBException - If there is an error setting up the fields as requested. For example, if a field allowing null is requested as part of the key
See Also:
SecuredDBObject

getValues

public Vector getValues()
                 throws DBException
Gets the valid values, specifically it returns a map of GroupNames to GroupDescriptions

Specified by:
getValues in interface LookupInterface
Overrides:
getValues in class DBObject
Returns:
a vector of valid values.
Throws:
DBException - upon error.
See Also:
DBObject.getValidValues(java.lang.String)

populateDefaultValues

public void populateDefaultValues()
                           throws DBException
Populates the default user groups.

Overrides:
populateDefaultValues in class DBObject
Throws:
DBException - Upon add error, never if it isn't overridden.

getGroupName

public String getGroupName()
                    throws DBException
convenience method

Returns:
name of group
Throws:
DBException - upon error

setGroupName

public void setGroupName(String groupName)
                  throws DBException
convenience method

Parameters:
groupName - the new gropu name
Throws:
DBException - upon error

getGroup

public static UserGroup getGroup(String groupname)
                          throws DBException
Parameters:
groupname - the new group name
Returns:
group for this name, or null if not found; uses "default" dbcontext
Throws:
DBException - upon error

getGroupDescription

public String getGroupDescription()
                           throws DBException
convenience method

Returns:
java.lang.String the group description
Throws:
DBException - upon error

getAllGroups

public static List getAllGroups()
                         throws DBException
convenience method

Returns:
list of all groups
Throws:
DBException - upon error

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.