org.tentackle.appworx
Class Security

java.lang.Object
  extended by org.tentackle.db.DbObject
      extended by org.tentackle.appworx.AppDbObject
          extended by org.tentackle.appworx.Security
All Implemented Interfaces:
Serializable, Cloneable, Comparable<DbObject>, ContextDependable

public class Security
extends AppDbObject

A security rule.

Any object, whether it is a database object (AppDbObject) or any other class (for example a dialog) can be secured by rules. Security rules grant or deny a permission to a grantee object or a grantee class. Optionally, rules can be restricted to some context object or context class. Grantees and contexts must be of type AppDbObject. The permission is an integer associated to a permission type, which is also an integer identifying the permission scheme. Permission types can be application specific, for example "invoiceable". Security rules also have a priority, can explain the denial to the user by means of a message text and can easily be extended by the application. Furthermore, rules may optionally be restricted to an application database context.

Author:
harald
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.tentackle.db.DbObject
DbObject.CopyAllToDbLogger, DbObject.IdComparator<T extends DbObject>, DbObject.NameComparator<T extends DbObject>, DbObject.NameIdComparator<T extends DbObject>
 
Field Summary
static int EXEC
          allow to execute
static String FIELD_ALLOWED
          database column name for allowed
static String FIELD_CONTEXTCLASS
          database column name for contextClass
static String FIELD_CONTEXTID
          database column name for contextId
static String FIELD_EXTENDEDRULE
          database column name for extendedRule
static String FIELD_GRANTCLASS
          database column name for grantClass
static String FIELD_GRANTID
          database column name for grantId
static String FIELD_MESSAGE
          database column name for message
static String FIELD_OBJECTCLASS
          database column name for objectClass
static String FIELD_OBJECTID
          database column name for objectId
static String FIELD_PERMISSION
          database column name for permission
static String FIELD_PERMISSIONTYPE
          database column name for permissionType
static String FIELD_PRIORITY
          database column name for priority
static int NONE
          no permission at all
static int READ
          allow for read
static String TABLENAME
          database tablename
static int TYPE_DATA
          permissiontype "data", i.e.
static int TYPE_PROGRAM
          java executable class, i.e.
static int WRITE
          allow for write, create, delete
 
Fields inherited from class org.tentackle.appworx.AppDbObject
FIELD_EDITEDBY, FIELD_EDITEDEXPIRY, FIELD_EDITEDSINCE, FIELD_NORMTEXT, TX_DELETE_ALL_IN_CONTEXT, TX_SAVE_COPY_IN_CONTEXT, TX_TRANSFER_EDITEDBY, VERIFIED_DUPLICATE
 
Fields inherited from class org.tentackle.db.DbObject
BEGIN, COMMIT, DELETE, DELETEALL, FIELD_ID, FIELD_SERIAL, FIELD_TABLESERIAL, idComparator, INSERT, lazyMethodInterval, nameComparator, nameIdComparator, TX_DELETE_LIST, TX_DELETE_MISSING_IN_LIST, TX_DELETE_OBJECT, TX_DUMMY_UPDATE, TX_INSERT_OBJECT, TX_INSERT_PLAIN, TX_SAVE, TX_SAVE_LIST, TX_UPDATE_OBJECT, TX_UPDATE_PLAIN, TX_UPDATE_SERIAL, TX_UPDATE_SERIAL_AND_TABLESERIAL, TX_UPDATE_TABLESERIAL, UPDATE
 
Constructor Summary
Security()
          Creates a security rule (without db context).
Security(ContextDb db)
          Creates a security rule.
 
Method Summary
static List<Security> createSecurityForObjectInOtherDb(AppDbObject fromObject, AppDbObject toObject)
          Creates security rules for objects created by AppDbObject.createCopyInContextDb(org.tentackle.appworx.ContextDb).
The method copies the rules from one object to another (logically the same) object in another context.
 int deleteByGrantee(long grantId)
          Delete all rules for given grantee.
Notice that among all objects of grantee-classes (usually one for the user and one for the roles) the IDs must be unique!
 int deleteByObject(AppDbObject object)
          Deletes all rules for given AppDbObject.
 int deleteByObject(long objectId, String objectClass)
          Deletes all rules for given objectId and objectClass.
 int deleteObjectRulesByGrantClass(String grantClass)
          Deletes all rules for given grantClass.
This will NOT delete any class-based rules (with grantId = 0) !
 int deleteObjectRulesByGrantClassAndContext(String grantClass, long contextId, String contextClass)
          Deletes all rules for given grantClass and Context.
 int deleteObjectRulesByObjectClass(String objectClass)
          Delete all object-related rules for given objectClass.
This will NOT delete any class-based rules (with objectId = 0) !
 int deleteObjectRulesByObjectClassAndContext(String objectClass, long contextId, String contextClass)
          Delete all rules for given objectClass and Context.
This will NOT delete any class-based rules (with objectId = 0) !
 boolean evaluate(ContextDb contextDb, int permission)
          Evaluates a rule.
 boolean getAllowed()
          Gets the db attribute allowed
 AppDbObjectClassVariables getAppDbObjectClassVariables()
          Gets the application oriented class variables for this object.
Class variables for classes derived from AppDbObject are kept in an instance of AppDbObjectClassVariables.
 String getContextClass()
          Gets the db attribute contextClass
 long getContextId()
          Gets the db attribute contextId
 AppDbObject getContextObject()
          Gets the application context's object.
The object will be loaded in its valid context.
 Binary getExtendedRule()
          Gets the db attribute extendedRule
 boolean getFields(ResultSetWrapper rs)
          Retrieves the values of all fields (all columns of the database table) in the given ResultSetWrapper and stores them in the object's attributes.
 FormTableEntry getFormTableEntry()
          Gets the table entry for viewing lists of this object in a FormTable.
The default implementation returns an AppDbObjectDefaultTableEntry.
 String getFormTableName()
          Gets the tablename used in to initialize the table's gui (columns, sizes, etc...).
 String getGrantClass()
          Gets the db attribute grantClass
 AppDbObject getGrantee()
          Gets the grantee.
 long getGrantId()
          Gets the db attribute grantId
 String getMessage()
          Gets the db attribute message
 AppDbObject getObject()
          Gets the object this rule applies to.
The object is retrieved in its valid context.
 String getObjectClass()
          Gets the db attribute objectClass
 long getObjectId()
          Gets the db attribute objectId
 int getPermission()
          Gets the db attribute permission
 int getPermissionType()
          Gets the db attribute permissionType
 int getPriority()
          Gets the db attribute priority
 boolean isCountingModification(int modType)
          Changes in Security usually force caches, etc...
 boolean isTracked()
          Overridden cause of "--tracked".
 String orderBy()
          All selects are sorted by priority!
static String permissionToString(int type, int permission)
          Converts a permission and its type to a string.
 int prepareInsertStatement()
          Prepares the insert statement.
 boolean prepareSetFields()
          Prepares the object's attributes before the object is saved to the database.
 int prepareUpdateStatement()
          Prepare the update statement.
 Security select(long id)
          Selects a rule by ID.
 List<Security> selectByGrantId(long grantId)
          Selects all rules for a given grantId.
Notice that among all objects of grantee-classes (usually one for the user and one for the roles) the IDs must be unique!
 TrackedArrayList<Security> selectByObject(AppDbObject object)
          Select all rules for given object.
 TrackedArrayList<Security> selectByObject(long objectId, String objectClass)
          Select all rules for given objectId and objectClass.
 void setAllowed(boolean allowed)
          Sets the db attribute allowed
 void setContextClass(String contextClass)
          Sets the db attribute contextClass
 void setContextId(long contextId)
          Sets the db attribute contextId
 void setContextObject(AppDbObject contextObject)
          Sets the application context's object.
 void setExtendedRule(Binary extendedRule)
          Sets the db attribute extendedRule
 int setFields(PreparedStatementWrapper st)
          Sets the values of all fields (all columns of the database table) in the given PreparedStatementWrapper from the object's attributes.
 void setGrantClass(String grantClass)
          Sets the db attribute grantClass
 void setGrantee(AppDbObject grantee)
          Sets the grantee.
 void setGrantId(long grantId)
          Sets the db attribute grantId
 void setMessage(String message)
          Sets the db attribute message
 void setObject(AppDbObject object)
          Sets the object this rule applies to.
Setting the null object also clears the objectClass making the rule invalid.
 void setObjectClass(Class clazz)
          Sets the class to be secured.
If the class is an AppDbObject only the basename will be stored.
 void setObjectClass(String objectClass)
          Sets the db attribute objectClass
 void setObjectId(long objectId)
          Sets the db attribute objectId
 void setPermission(int permission)
          Sets the db attribute permission
 void setPermissionType(int permissionType)
          Sets the db attribute permissionType
 void setPriority(int priority)
          Sets the db attribute priority
 String toString()
          for debugging only
 
Methods inherited from class org.tentackle.appworx.AppDbObject
allowsHistory, allowsTreeChildObjects, allowsTreeParentObjects, clearEditedBy, containsPattern, copy, copyCollection, copyLazyValues, countCacheAccess, countModification, createCopyInContextDb, dropTransferable, expireCache, extractTreePath, extractTreePathObjects, filterAppDbObjects, findDuplicate, finishModification, finishNotUpdated, getBaseContext, getCache, getCacheAccessCount, getCacheAccessTime, getClassPath, getContextDb, getCopiedObject, getDbObjectClassVariables, getEditedBy, getEditedByObject, getEditedExpiry, getEditedSince, getHistory, getMultiName, getNormText, getPanelObject, getRemoteDelegate, getSecurityManager, getSecurityResult, getSelectAllInContextCursorStatementId, getSelectAllInContextStatementId, getSelectByNormTextCursorStatementId, getSelectByNormTextStatementId, getSelectEditedByStatementId, getSingleName, getSqlContextCondition, getToolTipText, getToolTipText, getTransferable, getTransferEditedByStatementId, getTransientData, getTreeChildObjects, getTreeChildObjects, getTreeExpandMaxDepth, getTreeParentObjects, getTreeParentObjects, getTreeRoot, getTreeText, getTreeText, getUpdateEditedByOnlyStatementId, getUpdateEditedByStatementId, getUpdateEditedByTimeout, initModification, invalidateLazyValues, isCacheable, isCached, isComposite, isEditedLocked, isExpired, isInstantiatable, isLoggingHistory, isPermissionAccepted, isPermissionDefault, isPermissionDenied, isReferenced, isShowable, isShowableLazy, loadClass, loadComposites, loadComposites, logHistory, makeQbfPlugin, makeQbfPlugin, makeValidContext, markCacheAccess, newByClass, newByClassBaseName, newObject, newPanel, panelExists, permissionType, prepareSelectEditedByStatement, prepareTransferEditedByStatement, prepareUpdateEditedByOnlyStatement, prepareUpdateEditedByStatement, presetQbfParameter, readFromResultSetWrapper, resultAllInContext, resultAllInContextCursor, resultByNormText, resultByNormTextCursor, save, saveCopyInContextDb, saveInContextDb, searchQbf, searchQbfCursor, select, select, select, selectAll, selectAllInContext, selectAllInContext, selectAllInContextCached, selectAllInContextCursor, selectAllInValidContext, selectAllInValidContext, selectByNormText, selectByNormTextCursor, selectByTemplate, selectCached, selectCached, selectCached, selectInValidContext, selectInValidContext, selectInValidContext, selectInValidContext, selectInValidContext, selectInValidContext, selectLocked, selectLocked, selectLocked, selectLocked, setCacheAccessCount, setCacheAccessTime, setClassPath, setContextDb, setContextId, setDb, setEditedBy, setEditedByObject, setEditedExpiry, setEditedSince, setExpired, setNormText, setSelectAllInContextCursorStatementId, setSelectAllInContextStatementId, setSelectByNormTextCursorStatementId, setSelectByNormTextStatementId, setSelectEditedByStatementId, setTransferEditedByStatementId, setTransientData, setUpdateEditedByOnlyStatementId, setUpdateEditedByStatementId, stopTreeExpansion, transferEditedBy, updateEditedBy, updateEditedBy, updateEditedByOnly, updateObject, verify
 
Methods inherited from class org.tentackle.db.DbObject
_delete, _save, alwaysPrepare, assertLazyNotWithinTX, attributesModified, beginTx, clone, compareTo, copyAllToDb, copyToDb, countModification, createModificationLog, delete, deleteLinkedObjects, deleteList, deleteMissingInList, deleteObject, deletePlain, dummyUpdate, equals, getClassBaseName, getClassName, getDb, getDeleteStatementId, getDummyUpdateStatementId, getExpirationBacklog, getExpiredTableSerials, getFieldCount, getIcon, getId, getIdSource, getInsertStatementId, getMultiName, getRemoteDelegateId, getSelectAllStatementId, getSelectExpiredTableSerials1StatementId, getSelectExpiredTableSerials2StatementId, getSelectLockedStatementId, getSelectSerialStatementId, getSelectStatementId, getSerial, getSingleName, getSqlAllFields, getSqlPrefix, getSqlPrefixWithDot, getSqlSelectAllFields, getTableName, getTableSerial, getUpdateSerialAndTableSerialStatementId, getUpdateSerialStatementId, getUpdateStatementId, getUpdateTableSerialStatementId, hashCode, insert, insertObject, insertPlain, isDeleted, isEditable, isEditableLazy, isEntity, isGettingFieldCount, isIdValid, isLazyElapsed, isListModified, isLoggingModification, isModified, isNew, isPartial, isReferencedLazy, isRemovable, isRemovableLazy, isSaveable, isTableSerialValid, isTxObject, isUpdatingSerialEvenIfNotModified, isVirgin, loadLinkedObjects, logModification, markDeleted, markListDeleted, newByClass, newByClass, newByClassWrapped, newId, prepareDeleteStatement, prepareDummyUpdateStatement, prepareSelectLockedStatement, prepareSelectSerialStatement, prepareSelectStatement, prepareUpdateSerialAndTableSerialStatement, prepareUpdateSerialStatement, prepareUpdateTableSerialStatement, readFromResultSetWrapper, reload, reloadLocked, reserveId, saveLinkedObjects, saveList, saveList, select, select, selectAll, selectAll, selectAllCursor, selectAllCursor, selectAllResultSet, selectExpiredTableSerials, selectExpiredTableSerials, selectModification, selectNext, selectSerial, selectSerial, setAlwaysPrepare, setDeleteStatementId, setDummyUpdateStatementId, setId, setInsertStatementId, setModified, setSelectAllStatementId, setSelectExpiredTableSerials1StatementId, setSelectExpiredTableSerials2StatementId, setSelectLockedStatementId, setSelectSerialStatementId, setSelectStatementId, setSerial, setTableSerial, setUpdateSerialAndTableSerialStatementId, setUpdateSerialStatementId, setUpdateStatementId, setUpdateTableSerialStatementId, sync, syncObject, toGenericString, update, updateFieldCount, updateFields, updatePlain, updateSerial, updateSerialAndTableSerial, updateTableSerial
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_DATA

public static final int TYPE_DATA
permissiontype "data", i.e. AppDbObject

See Also:
Constant Field Values

TYPE_PROGRAM

public static final int TYPE_PROGRAM
java executable class, i.e. program logic

See Also:
Constant Field Values

NONE

public static final int NONE
no permission at all

See Also:
Constant Field Values

READ

public static final int READ
allow for read

See Also:
Constant Field Values

WRITE

public static final int WRITE
allow for write, create, delete

See Also:
Constant Field Values

EXEC

public static final int EXEC
allow to execute

See Also:
Constant Field Values

TABLENAME

public static final String TABLENAME
database tablename

See Also:
Constant Field Values

FIELD_OBJECTCLASS

public static final String FIELD_OBJECTCLASS
database column name for objectClass

See Also:
Constant Field Values

FIELD_OBJECTID

public static final String FIELD_OBJECTID
database column name for objectId

See Also:
Constant Field Values

FIELD_CONTEXTID

public static final String FIELD_CONTEXTID
database column name for contextId

See Also:
Constant Field Values

FIELD_CONTEXTCLASS

public static final String FIELD_CONTEXTCLASS
database column name for contextClass

See Also:
Constant Field Values

FIELD_GRANTID

public static final String FIELD_GRANTID
database column name for grantId

See Also:
Constant Field Values

FIELD_GRANTCLASS

public static final String FIELD_GRANTCLASS
database column name for grantClass

See Also:
Constant Field Values

FIELD_PRIORITY

public static final String FIELD_PRIORITY
database column name for priority

See Also:
Constant Field Values

FIELD_PERMISSIONTYPE

public static final String FIELD_PERMISSIONTYPE
database column name for permissionType

See Also:
Constant Field Values

FIELD_PERMISSION

public static final String FIELD_PERMISSION
database column name for permission

See Also:
Constant Field Values

FIELD_ALLOWED

public static final String FIELD_ALLOWED
database column name for allowed

See Also:
Constant Field Values

FIELD_MESSAGE

public static final String FIELD_MESSAGE
database column name for message

See Also:
Constant Field Values

FIELD_EXTENDEDRULE

public static final String FIELD_EXTENDEDRULE
database column name for extendedRule

See Also:
Constant Field Values
Constructor Detail

Security

public Security(ContextDb db)
Creates a security rule.

Parameters:
db - the database context

Security

public Security()
Creates a security rule (without db context).

Method Detail

permissionToString

public static String permissionToString(int type,
                                        int permission)
Converts a permission and its type to a string.

Parameters:
type - the permission type
permission - the permission
Returns:
the text representation

createSecurityForObjectInOtherDb

public static List<Security> createSecurityForObjectInOtherDb(AppDbObject fromObject,
                                                              AppDbObject toObject)
                                                       throws ApplicationException
Creates security rules for objects created by AppDbObject.createCopyInContextDb(org.tentackle.appworx.ContextDb).
The method copies the rules from one object to another (logically the same) object in another context.

Parameters:
fromObject -
toObject -
Returns:
the created list of rules
Throws:
ApplicationException - if security instances could not be created

evaluate

public boolean evaluate(ContextDb contextDb,
                        int permission)
Evaluates a rule.

The method is only invoked for rules that apply to the object and/or class in question. Notice further, that due to servermode the given ContextDb may point to a different Db than this security rule. For example, if some extendedRule must load data from the db, it must handle that appropriately.

Parameters:
contextDb - the context-Db the object or class is used in, null = all
permission - the requested permission(s)
Returns:
true if rule fires, else this rules does not apply

getObject

public AppDbObject getObject()
Gets the object this rule applies to.
The object is retrieved in its valid context.

Returns:
the object, null if none (class rule)

setObject

public void setObject(AppDbObject object)
Sets the object this rule applies to.
Setting the null object also clears the objectClass making the rule invalid.

Parameters:
object - the object, null to clear

setObjectClass

public void setObjectClass(Class clazz)
Sets the class to be secured.
If the class is an AppDbObject only the basename will be stored. Otherwise the full qualified classname is used.

Parameters:
clazz - the objectclass

getGrantee

public AppDbObject getGrantee()
Gets the grantee.

Returns:
the grantee, null if grant class

setGrantee

public void setGrantee(AppDbObject grantee)
Sets the grantee.

Parameters:
grantee - the grantee, null to clear (all)

getContextObject

public AppDbObject getContextObject()
Gets the application context's object.
The object will be loaded in its valid context.

Returns:
the context object, null if no context (all)

setContextObject

public void setContextObject(AppDbObject contextObject)
Sets the application context's object.

Parameters:
contextObject - the context object, null to clear (all)

getFormTableEntry

public FormTableEntry getFormTableEntry()
Description copied from class: AppDbObject
Gets the table entry for viewing lists of this object in a FormTable.
The default implementation returns an AppDbObjectDefaultTableEntry. Should be overridden in subclasses.

Overrides:
getFormTableEntry in class AppDbObject
Returns:
the formtable entry
See Also:
AppDbObject.getFormTableName()

getFormTableName

public String getFormTableName()
Description copied from class: AppDbObject
Gets the tablename used in to initialize the table's gui (columns, sizes, etc...). The default implementation returns AppDbObject.formTableName. Should be overridden.

Overrides:
getFormTableName in class AppDbObject
Returns:
the table name
See Also:
AppDbObject.getFormTableEntry()

select

public Security select(long id)
Selects a rule by ID.

Overrides:
select in class AppDbObject
Parameters:
id - is the object id
Returns:
object if loaded, null if no such object

toString

public String toString()
for debugging only

Overrides:
toString in class DbObject
Returns:
the string value of this DbObject

orderBy

public String orderBy()
All selects are sorted by priority!

Overrides:
orderBy in class AppDbObject
Returns:
the order by appendix string, null if no order by

getAppDbObjectClassVariables

public AppDbObjectClassVariables getAppDbObjectClassVariables()
Description copied from class: AppDbObject
Gets the application oriented class variables for this object.
Class variables for classes derived from AppDbObject are kept in an instance of AppDbObjectClassVariables.

Notice: we cannot use a covariant method getDbObjectClassVariables() returning AppDbObjectClassVariables because super.getDbObjectClassVariables() is abstract and in that case covariance does not work. You will get the compiler error: "abstract method getDbObjectClassVariables() in org.tentackle.db.DbObject cannot be accessed directly"

Specified by:
getAppDbObjectClassVariables in class AppDbObject
Returns:
the class variables
See Also:
DbObject.getDbObjectClassVariables()

isCountingModification

public boolean isCountingModification(int modType)
Changes in Security usually force caches, etc... to be reloaded.

Overrides:
isCountingModification in class DbObject
Parameters:
modType - is one of the modtypes INSERT, UPDATE, DELETE, ...
Returns:
always true
See Also:
ModificationCounter

selectByGrantId

public List<Security> selectByGrantId(long grantId)
Selects all rules for a given grantId.
Notice that among all objects of grantee-classes (usually one for the user and one for the roles) the IDs must be unique!

Parameters:
grantId - the grantee's object ID
Returns:
the rules
Wurblet:
selectByGrantId AppDbSelectList $mapfile $remote --sort grantId

selectByObject

public TrackedArrayList<Security> selectByObject(long objectId,
                                                 String objectClass)
Select all rules for given objectId and objectClass.

Parameters:
objectId - the object's ID
objectClass - the object's class
Returns:
the rules
Wurblet:
selectByObject AppDbSelectList $mapfile $remote --sort --tracked objectId objectClass

selectByObject

public TrackedArrayList<Security> selectByObject(AppDbObject object)
Select all rules for given object.

Parameters:
object - the object
Returns:
the rules

deleteByGrantee

public int deleteByGrantee(long grantId)
Delete all rules for given grantee.
Notice that among all objects of grantee-classes (usually one for the user and one for the roles) the IDs must be unique!

Parameters:
grantId - the grantee's object ID
Returns:
the number of deleted rules
Wurblet:
deleteByGrantee AppDbDeleteBy $mapfile $remote grantId

deleteByObject

public int deleteByObject(long objectId,
                          String objectClass)
Deletes all rules for given objectId and objectClass.

Parameters:
objectId - the object's ID
objectClass - the object's class
Returns:
the number of deleted rules
Wurblet:
deleteByObject AppDbDeleteBy $mapfile $remote objectId objectClass

deleteByObject

public int deleteByObject(AppDbObject object)
Deletes all rules for given AppDbObject.

Parameters:
object - the database object
Returns:
the number of deleted rules

deleteObjectRulesByObjectClass

public int deleteObjectRulesByObjectClass(String objectClass)
Delete all object-related rules for given objectClass.
This will NOT delete any class-based rules (with objectId = 0) !

Parameters:
objectClass - the object class
Returns:
the number of deleted rules
Wurblet:
deleteObjectRulesByObjectClass AppDbDeleteBy $mapfile $remote objectId:!=:0 objectClass

deleteObjectRulesByObjectClassAndContext

public int deleteObjectRulesByObjectClassAndContext(String objectClass,
                                                    long contextId,
                                                    String contextClass)
Delete all rules for given objectClass and Context.
This will NOT delete any class-based rules (with objectId = 0) !

Parameters:
objectClass - the object class
contextId - the ID of the context object
contextClass - the class of the context object
Returns:
the number of deleted rules
Wurblet:
deleteObjectRulesByObjectClassAndContext AppDbDeleteBy $mapfile $remote objectId:!=:0 objectClass contextId contextClass

deleteObjectRulesByGrantClass

public int deleteObjectRulesByGrantClass(String grantClass)
Deletes all rules for given grantClass.
This will NOT delete any class-based rules (with grantId = 0) !

Parameters:
grantClass - the grantee class
Returns:
the number of deleted rules
Wurblet:
deleteObjectRulesByGrantClass AppDbDeleteBy $mapfile $remote grantId:!=:0 grantClass

deleteObjectRulesByGrantClassAndContext

public int deleteObjectRulesByGrantClassAndContext(String grantClass,
                                                   long contextId,
                                                   String contextClass)
Deletes all rules for given grantClass and Context. This will NOT delete any class-based rules (with grantId = 0) !

Parameters:
grantClass - the grantee class
contextId - the ID of the context object
contextClass - the class of the context object
Returns:
the number of deleted rules
Wurblet:
deleteObjectRulesByGrantClassAndContext AppDbDeleteBy $mapfile $remote grantId:!=:0 grantClass contextId contextClass

isTracked

public boolean isTracked()
Overridden cause of "--tracked".

Overrides:
isTracked in class DbObject
Returns:
true = setters check for modification

getObjectClass

public String getObjectClass()
Gets the db attribute objectClass

Returns:
classbasename if database class, else full classname

setObjectClass

public void setObjectClass(String objectClass)
Sets the db attribute objectClass

Parameters:
objectClass - classbasename if database class, else full classname

getObjectId

public long getObjectId()
Gets the db attribute objectId

Returns:
object id, 0=all or not a database class

setObjectId

public void setObjectId(long objectId)
Sets the db attribute objectId

Parameters:
objectId - object id, 0=all or not a database class

getContextId

public long getContextId()
Gets the db attribute contextId

Specified by:
getContextId in interface ContextDependable
Overrides:
getContextId in class AppDbObject
Returns:
ID of context object, 0 = all of contextClass

setContextId

public void setContextId(long contextId)
Sets the db attribute contextId

Parameters:
contextId - ID of context object, 0 = all of contextClass

getContextClass

public String getContextClass()
Gets the db attribute contextClass

Returns:
classbasename of ContextDb's Rootobject

setContextClass

public void setContextClass(String contextClass)
Sets the db attribute contextClass

Parameters:
contextClass - classbasename of ContextDb's Rootobject

getGrantId

public long getGrantId()
Gets the db attribute grantId

Returns:
ID of grantobject, 0 = all of grantClass

setGrantId

public void setGrantId(long grantId)
Sets the db attribute grantId

Parameters:
grantId - ID of grantobject, 0 = all of grantClass

getGrantClass

public String getGrantClass()
Gets the db attribute grantClass

Returns:
classbasename of grantobject

setGrantClass

public void setGrantClass(String grantClass)
Sets the db attribute grantClass

Parameters:
grantClass - classbasename of grantobject

getPriority

public int getPriority()
Gets the db attribute priority

Returns:
ordering, 0=first

setPriority

public void setPriority(int priority)
Sets the db attribute priority

Parameters:
priority - ordering, 0=first

getPermissionType

public int getPermissionType()
Gets the db attribute permissionType

Returns:
set of possible Permissions

setPermissionType

public void setPermissionType(int permissionType)
Sets the db attribute permissionType

Parameters:
permissionType - set of possible Permissions

getPermission

public int getPermission()
Gets the db attribute permission

Returns:
permissionbits according to permtype

setPermission

public void setPermission(int permission)
Sets the db attribute permission

Parameters:
permission - permissionbits according to permtype

getAllowed

public boolean getAllowed()
Gets the db attribute allowed

Returns:
false=denied, true=allowed

setAllowed

public void setAllowed(boolean allowed)
Sets the db attribute allowed

Parameters:
allowed - false=denied, true=allowed

getMessage

public String getMessage()
Gets the db attribute message

Returns:
user message

setMessage

public void setMessage(String message)
Sets the db attribute message

Parameters:
message - user message

getExtendedRule

public Binary getExtendedRule()
Gets the db attribute extendedRule

Returns:
extension object

setExtendedRule

public void setExtendedRule(Binary extendedRule)
Sets the db attribute extendedRule

Parameters:
extendedRule - extension object

prepareSetFields

public boolean prepareSetFields()
Prepares the object's attributes before the object is saved to the database. Should be overridden. The default implementation does nothing. Used to setup, check and align values.

Overridden to set the normtext from DbObject.toString().

Overridden to assert objectClass != null.

Overrides:
prepareSetFields in class AppDbObject
Returns:
true if proceed with save/insert/update, false if some error.

getFields

public boolean getFields(ResultSetWrapper rs)
Description copied from class: DbObject
Retrieves the values of all fields (all columns of the database table) in the given ResultSetWrapper and stores them in the object's attributes.

Specified by:
getFields in class DbObject
Parameters:
rs - the result set
Returns:
true if all fields retrieved

setFields

public int setFields(PreparedStatementWrapper st)
Description copied from class: DbObject
Sets the values of all fields (all columns of the database table) in the given PreparedStatementWrapper from the object's attributes.

Specified by:
setFields in class DbObject
Parameters:
st - the statement
Returns:
the number of fields set, -1 if error.

prepareInsertStatement

public int prepareInsertStatement()
Description copied from class: DbObject
Prepares the insert statement.

Specified by:
prepareInsertStatement in class DbObject
Returns:
the statememt id

prepareUpdateStatement

public int prepareUpdateStatement()
Description copied from class: DbObject
Prepare the update statement.

Specified by:
prepareUpdateStatement in class DbObject
Returns:
the statememt id


Copyright © 2001-2008 Harald Krake, Bergstr. 48, 78098 Triberg, Germany, harald@krake.de