arlut.csd.ganymede
Class PermissionMatrixDBField

java.lang.Object
  |
  +--arlut.csd.ganymede.DBField
        |
        +--arlut.csd.ganymede.PermissionMatrixDBField
All Implemented Interfaces:
db_field, perm_field, java.rmi.Remote

public class PermissionMatrixDBField
extends DBField
implements perm_field

PermissionMatrixDBField is a subclass of DBField for the storage and handling of permission matrix fields (used only in the Role DBObjects) in the DBStore on the Ganymede server.

The Ganymede client talks to PermissionMatrixDBFields through the perm_field RMI interface.

This class differs a bit from most subclasses of DBField in that the normal setValue()/getValue() methods are non-functional. Instead, there are special methods used to set or access permission information from the specially coded Hashtable held by a PermissionMatrixDBField. This Hashtable maps strings encoded by the matrixEntry() methods to PermEntry objects, which hold create, edit, view, and delete bits.

PermissionMatrixDBField's methods encode part of the server's permissions logic, including the restrictions on what bits can be set in a Role's permission matrix based on the rights granted in the client's GanymedeSession. We determine what GanymedeSession we are operating in for that case by asking our DBEditObject owner.


Field Summary
(package private) static boolean debug
           
(package private)  boolean defined
           
(package private)  java.util.Hashtable matrix
           
 
Fields inherited from class arlut.csd.ganymede.DBField
fieldcode, owner, value
 
Constructor Summary
(package private) PermissionMatrixDBField(arlut.csd.ganymede.DBObject owner, java.io.DataInput in, arlut.csd.ganymede.DBObjectBaseField definition)
          Receive constructor.
(package private) PermissionMatrixDBField(arlut.csd.ganymede.DBObject owner, arlut.csd.ganymede.DBObjectBaseField definition)
          No-value constructor.
  PermissionMatrixDBField(arlut.csd.ganymede.DBObject owner, arlut.csd.ganymede.PermissionMatrixDBField field)
          Copy constructor.
 
Method Summary
 boolean allowablePermEntry(short baseID, short fieldID, arlut.csd.ganymede.PermEntry entry)
          This method is used to check that the given operation can be set by the current administrator.
 java.lang.Object checkpoint()
          This method is used to basically dump state out of this field so that the DBEditSet checkpoint() code can restore it later if need be.
private  void clean()
          This internal method is used to cull out any entries in this permissions field that are non-operative, either by referring to an object/field type that does not exist, or by being redundant.
 java.lang.Object clone()
           
 arlut.csd.ganymede.ReturnVal copyFieldTo(arlut.csd.ganymede.DBField target, boolean local)
          This method copies the current value of this DBField to target.
(package private) static java.lang.String debugdecode(java.util.Hashtable matrix)
          This method generates a string version of the debugdump output.
 void debugdump()
          This method does a dump to System.err of the permission contents held in this field.
private static void debugdump(java.util.Hashtable matrix)
          This method does a dump to System.err of the permission contents held in matrix.
 void debugdump(arlut.csd.ganymede.PermissionMatrixDBField me)
          This method does a dump to System.err of the permission contents held in PermissionMatrixDBField me.
static void debugdump(arlut.csd.ganymede.PermMatrix matrix)
           
static java.lang.String decodeBaseName(java.lang.String entry)
          This utility method extracts the DBObjectBase name from a coded permission entry held in a PermMatrix/PermissionMatrixDBField Matrix.
static java.lang.String decodeFieldName(java.lang.String entry)
          This utility method extracts the DBObjectBaseField name from a coded permission entry held in a PermMatrix/PermissionMatrixDBField Matrix.
(package private)  void emit(java.io.DataOutput out)
          This method is responsible for writing out the contents of this field to an binary output stream.
(package private)  void emitXML(arlut.csd.ganymede.XMLDumpContext xmlOut)
          This method is used when the database is being dumped, to write out this field to disk.
 boolean equals(java.lang.Object obj)
          fancy equals method really does check for value equality
 arlut.csd.ganymede.DBField getCopy(arlut.csd.ganymede.DBObject newOwner)
          This method is used to return a copy of this field, with the field's owner set to newOwner.
 java.lang.String getDiffString(arlut.csd.ganymede.DBField orig)
          Returns a String representing the change in value between this field and orig.
 java.lang.String getEncodingString()
          We don't try and give a comprehensive encoding string for permission matrices, let's just give enough so they know what we are.
 arlut.csd.ganymede.PermMatrix getMatrix()
          Return a serializable, read-only copy of this field's permission matrix
 arlut.csd.ganymede.PermEntry getPerm(arlut.csd.ganymede.Base base)
          Returns a PermEntry object representing this PermMatrix's permissions on the base <base>
 arlut.csd.ganymede.PermEntry getPerm(arlut.csd.ganymede.Base base, arlut.csd.ganymede.BaseField field)
          Returns a PermEntry object representing this PermMatrix's permissions on the field <field> in base <base>
 arlut.csd.ganymede.PermEntry getPerm(short baseID)
          Returns a PermEntry object representing this PermMatrix's permissions on the base <baseID>
 arlut.csd.ganymede.PermEntry getPerm(short baseID, short fieldID)
          Returns a PermEntry object representing this PermMatrix's permissions on the field <fieldID> in base <baseID>
 arlut.csd.ganymede.PermMatrix getTemplateMatrix()
          Return a serializable, read-only copy of the maximum permissions that can be set for this field's permission matrix.
 java.lang.Object getValue()
          We always return null here..
 java.lang.Object getValueLocal()
          Returns an Object carrying the value held in this field.

This is intended to be used within the Ganymede server, it bypasses the permissions checking that getValues() does.
 java.lang.String getValueString()
          Returns a String representing the value of this field.
private  boolean isBasePerm(java.lang.String matrixEntry)
          Returns true if the given String encodes the identity of a DBObjectBase and not a field within a DBObjectBase.
 boolean isDefined()
          Returns true if this field has a value associated with it, or false if it is an unfilled 'placeholder'.
static boolean isValidCode(java.lang.String entry)
          This method returns true if the given PermMatrix/ PermissionMatrixDBField key refers to a currently valid DBObjectBase/ DBObjectBaseField in the loaded schema.
 java.lang.Object key()
          we don't really want to hash according to our permission contents, so just hash according to our containing object's i.d.
private  java.lang.String matrixEntry(short baseID)
          Private method to generate a key for use in our internal Hashtable, used to encode the permission for a given DBObjectBase.
private  java.lang.String matrixEntry(short baseID, short fieldID)
          Private method to generate a key for use in our internal Hashtable, used to encode the permission for a given DBObjectBase and DBObjectBaseField.
(package private)  void receive(java.io.DataInput in, arlut.csd.ganymede.DBObjectBaseField definition)
          This method is responsible for reading in the contents of this field from an binary input stream.
 arlut.csd.ganymede.ReturnVal resetPerms()
          Resets the permissions in this PermissionMatrixDBField to the empty set.
 void rollback(java.lang.Object oldval)
          This method is used to basically force state into this field.
 arlut.csd.ganymede.ReturnVal setFieldPerms(short baseID, arlut.csd.ganymede.PermEntry entry, boolean includeBuiltins)
          Sets the permission entry for all fields in base <baseID> to PermEntry <entry>
 arlut.csd.ganymede.ReturnVal setPerm(arlut.csd.ganymede.Base base, arlut.csd.ganymede.BaseField field, arlut.csd.ganymede.PermEntry entry)
          Sets the permission entry for base <base>, field <field> to PermEntry <entry>
 arlut.csd.ganymede.ReturnVal setPerm(arlut.csd.ganymede.Base base, arlut.csd.ganymede.PermEntry entry)
          Sets the permission entry for base <baseID> to PermEntry <entry>.
 arlut.csd.ganymede.ReturnVal setPerm(short baseID, arlut.csd.ganymede.PermEntry entry)
          Sets the permission entry for this matrix for base <baseID> to PermEntry <entry>
 arlut.csd.ganymede.ReturnVal setPerm(short baseID, short fieldID, arlut.csd.ganymede.PermEntry entry)
          Sets the permission entry for base <baseID>, field <fieldID> to PermEntry <entry>.
 arlut.csd.ganymede.ReturnVal setUndefined(boolean local)
          This method is used to mark a field as undefined when it is checked out for editing.
 arlut.csd.ganymede.ReturnVal setValue(java.lang.Object value, boolean local, boolean noWizards)
          we don't allow setValue..
 arlut.csd.ganymede.ReturnVal verifyNewValue(java.lang.Object v)
          Overridable method to verify that an object submitted to this field has an appropriate value.
 boolean verifyTypeMatch(java.lang.Object v)
          Overridable method to determine whether an Object submitted to this field is of an appropriate type.
 
Methods inherited from class arlut.csd.ganymede.DBField
addElement, addElement, addElement, addElementLocal, addElements, addElements, addElements, addElements, addElementsLocal, cleanup, containsElement, containsElement, containsElementLocal, deleteAllElements, deleteElement, deleteElement, deleteElement, deleteElement, deleteElement, deleteElement, deleteElementLocal, deleteElementLocal, deleteElements, deleteElements, deleteElements, deleteElementsLocal, getComment, getElement, getFieldDef, getFieldDef, getFieldDef, getFieldInfo, getFieldTemplate, getID, getMaxArraySize, getName, getNameSpace, getObjTypeID, getOwner, getType, getTypeDesc, getValue, getValues, getValuesLocal, getVectorDiff, getVectVal, getXMLName, indexOfValue, isBuiltIn, isEditable, isEditable, isEditInPlace, isVector, isVisible, key, mark, mark, rescanThisField, setElement, setElement, setElement, setElementLocal, setOwner, setValue, setValue, setValueLocal, size, toString, unmark, unmark, verifyReadPermission, verifyWritePermission
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface arlut.csd.ganymede.db_field
addElement, addElements, containsElement, deleteAllElements, deleteElement, deleteElement, deleteElements, getComment, getElement, getFieldInfo, getFieldTemplate, getID, getName, getType, getTypeDesc, getValues, isBuiltIn, isEditable, isEditInPlace, isVector, isVisible, setElement, setValue, size
 

Field Detail

debug

static final boolean debug
See Also:
Constant Field Values

defined

boolean defined

matrix

java.util.Hashtable matrix
Constructor Detail

PermissionMatrixDBField

PermissionMatrixDBField(arlut.csd.ganymede.DBObject owner,
                        java.io.DataInput in,
                        arlut.csd.ganymede.DBObjectBaseField definition)
                  throws java.io.IOException

Receive constructor. Used to create a PermissionMatrixDBField from a DBStore/DBJournal DataInput stream.


PermissionMatrixDBField

PermissionMatrixDBField(arlut.csd.ganymede.DBObject owner,
                        arlut.csd.ganymede.DBObjectBaseField definition)

No-value constructor. Allows the construction of a 'non-initialized' field, for use where the DBObjectBase definition indicates that a given field may be present, but for which no value has been stored in the DBStore.

Used to provide the client a template for 'creating' this field if so desired.


PermissionMatrixDBField

public PermissionMatrixDBField(arlut.csd.ganymede.DBObject owner,
                               arlut.csd.ganymede.PermissionMatrixDBField field)
Copy constructor.

Method Detail

isDefined

public boolean isDefined()
Returns true if this field has a value associated with it, or false if it is an unfilled 'placeholder'.

Specified by:
isDefined in interface db_field
Overrides:
isDefined in class DBField
See Also:
db_field

setUndefined

public arlut.csd.ganymede.ReturnVal setUndefined(boolean local)

This method is used to mark a field as undefined when it is checked out for editing. Different subclasses of DBField may implement this in different ways, if simply setting the field's value member to null is not appropriate. Any namespace values claimed by the field will be released, and when the transaction is committed, this field will be released.

Overrides:
setUndefined in class DBField

decodeBaseName

public static java.lang.String decodeBaseName(java.lang.String entry)

This utility method extracts the DBObjectBase name from a coded permission entry held in a PermMatrix/PermissionMatrixDBField Matrix.


decodeFieldName

public static java.lang.String decodeFieldName(java.lang.String entry)

This utility method extracts the DBObjectBaseField name from a coded permission entry held in a PermMatrix/PermissionMatrixDBField Matrix.


isBasePerm

private boolean isBasePerm(java.lang.String matrixEntry)

Returns true if the given String encodes the identity of a DBObjectBase and not a field within a DBObjectBase.


isValidCode

public static boolean isValidCode(java.lang.String entry)

This method returns true if the given PermMatrix/ PermissionMatrixDBField key refers to a currently valid DBObjectBase/ DBObjectBaseField in the loaded schema.


debugdump

public void debugdump(arlut.csd.ganymede.PermissionMatrixDBField me)
This method does a dump to System.err of the permission contents held in PermissionMatrixDBField me.


debugdump

public static void debugdump(arlut.csd.ganymede.PermMatrix matrix)

debugdump

private static void debugdump(java.util.Hashtable matrix)
This method does a dump to System.err of the permission contents held in matrix.


debugdecode

static java.lang.String debugdecode(java.util.Hashtable matrix)
This method generates a string version of the debugdump output.


verifyTypeMatch

public boolean verifyTypeMatch(java.lang.Object v)
Description copied from class: DBField
Overridable method to determine whether an Object submitted to this field is of an appropriate type.

Specified by:
verifyTypeMatch in class DBField

verifyNewValue

public arlut.csd.ganymede.ReturnVal verifyNewValue(java.lang.Object v)
Description copied from class: DBField
Overridable method to verify that an object submitted to this field has an appropriate value.

Specified by:
verifyNewValue in class DBField

equals

public boolean equals(java.lang.Object obj)
fancy equals method really does check for value equality

Overrides:
equals in class DBField

copyFieldTo

public arlut.csd.ganymede.ReturnVal copyFieldTo(arlut.csd.ganymede.DBField target,
                                                boolean local)

This method copies the current value of this DBField to target. The target DBField must be contained within a checked-out DBEditObject in order to be updated. Any actions that would normally occur from a user manually setting a value into the field will occur.

Overrides:
copyFieldTo in class DBField
Parameters:
target - The DBField to copy this field's contents to.
local - If true, permissions checking is skipped.

key

public java.lang.Object key()
we don't really want to hash according to our permission contents, so just hash according to our containing object's i.d.

Overrides:
key in class DBField

getValue

public java.lang.Object getValue()
We always return null here..

Specified by:
getValue in interface db_field
Overrides:
getValue in class DBField
See Also:
db_field

getValueLocal

public java.lang.Object getValueLocal()
Returns an Object carrying the value held in this field.

This is intended to be used within the Ganymede server, it bypasses the permissions checking that getValues() does.

Overrides:
getValueLocal in class DBField

setValue

public arlut.csd.ganymede.ReturnVal setValue(java.lang.Object value,
                                             boolean local,
                                             boolean noWizards)
we don't allow setValue.. PermissionMatrixDBField doesn't allow direct setting of the entire matrix.. just use the get() and set() methods below.

Overrides:
setValue in class DBField
Parameters:
local - If true, permissions checking will be skipped
noWizards - If true, wizards will be skipped

getCopy

public arlut.csd.ganymede.DBField getCopy(arlut.csd.ganymede.DBObject newOwner)

This method is used to return a copy of this field, with the field's owner set to newOwner.

Specified by:
getCopy in class DBField

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

emit

void emit(java.io.DataOutput out)
    throws java.io.IOException
Description copied from class: DBField

This method is responsible for writing out the contents of this field to an binary output stream. It is used in writing fields to the ganymede.db file and to the journal file.

This method only writes out the value contents of this field. The DBObject emit() method is responsible for writing out the field identifier information ahead of the field's contents.

Specified by:
emit in class DBField
java.io.IOException

receive

void receive(java.io.DataInput in,
             arlut.csd.ganymede.DBObjectBaseField definition)
       throws java.io.IOException
Description copied from class: DBField

This method is responsible for reading in the contents of this field from an binary input stream. It is used in reading fields from the ganymede.db file and from the journal file.

The code that calls receive() on this field is responsible for having read enough of the binary input stream's context to place the read cursor at the point in the file immediately after the field's id and type information has been read.

Specified by:
receive in class DBField
java.io.IOException

emitXML

void emitXML(arlut.csd.ganymede.XMLDumpContext xmlOut)
       throws java.io.IOException

This method is used when the database is being dumped, to write out this field to disk. It is mated with receiveXML().

Specified by:
emitXML in class DBField
java.io.IOException

getValueString

public java.lang.String getValueString()
Description copied from interface: db_field
Returns a String representing the value of this field.

Specified by:
getValueString in interface db_field
Specified by:
getValueString in class DBField

getEncodingString

public java.lang.String getEncodingString()
We don't try and give a comprehensive encoding string for permission matrices, let's just give enough so they know what we are.

Specified by:
getEncodingString in interface db_field
Specified by:
getEncodingString in class DBField
See Also:
db_field

getDiffString

public java.lang.String getDiffString(arlut.csd.ganymede.DBField orig)

Returns a String representing the change in value between this field and orig. This String is intended for logging and email, not for any sort of programmatic activity. The format of the generated string is not defined, but is intended to be suitable for inclusion in a log entry and in an email message.

If there is no change in the field, null will be returned.

Specified by:
getDiffString in class DBField

getMatrix

public arlut.csd.ganymede.PermMatrix getMatrix()
Return a serializable, read-only copy of this field's permission matrix

Specified by:
getMatrix in interface perm_field
See Also:
perm_field

getTemplateMatrix

public arlut.csd.ganymede.PermMatrix getTemplateMatrix()

Return a serializable, read-only copy of the maximum permissions that can be set for this field's permission matrix. This matrix is drawn from the union of delegatable roles that the client's adminPersona is a member of.

This method will return null if this perm_field is not associated with an object that is being edited, or if the client is logged into the server as supergash.

Specified by:
getTemplateMatrix in interface perm_field
See Also:
perm_field

getPerm

public arlut.csd.ganymede.PermEntry getPerm(short baseID,
                                            short fieldID)
Returns a PermEntry object representing this PermMatrix's permissions on the field <fieldID> in base <baseID>

Specified by:
getPerm in interface perm_field
See Also:
perm_field, PermMatrix

getPerm

public arlut.csd.ganymede.PermEntry getPerm(short baseID)
Returns a PermEntry object representing this PermMatrix's permissions on the base <baseID>

Specified by:
getPerm in interface perm_field
See Also:
perm_field, PermMatrix

getPerm

public arlut.csd.ganymede.PermEntry getPerm(arlut.csd.ganymede.Base base,
                                            arlut.csd.ganymede.BaseField field)
Returns a PermEntry object representing this PermMatrix's permissions on the field <field> in base <base>

Specified by:
getPerm in interface perm_field
See Also:
perm_field, PermMatrix

getPerm

public arlut.csd.ganymede.PermEntry getPerm(arlut.csd.ganymede.Base base)
Returns a PermEntry object representing this PermMatrix's permissions on the base <base>

Specified by:
getPerm in interface perm_field
See Also:
perm_field, PermMatrix

resetPerms

public arlut.csd.ganymede.ReturnVal resetPerms()

Resets the permissions in this PermissionMatrixDBField to the empty set. Used by non-interactive clients to reset the Permission Matrix to a known state before setting permissions.

Returns null on success, or a failure-coded ReturnVal on permissions failure.

Specified by:
resetPerms in interface perm_field

setPerm

public arlut.csd.ganymede.ReturnVal setPerm(arlut.csd.ganymede.Base base,
                                            arlut.csd.ganymede.BaseField field,
                                            arlut.csd.ganymede.PermEntry entry)

Sets the permission entry for base <base>, field <field> to PermEntry <entry>

This operation will fail if this PermissionMatrixDBField is not editable.

Specified by:
setPerm in interface perm_field
See Also:
perm_field, PermEntry

setPerm

public arlut.csd.ganymede.ReturnVal setPerm(short baseID,
                                            short fieldID,
                                            arlut.csd.ganymede.PermEntry entry)

Sets the permission entry for base <baseID>, field <fieldID> to PermEntry <entry>.

This operation will fail if this PermissionMatrixDBField is not editable.

Specified by:
setPerm in interface perm_field
Parameters:
baseID - the object type to set permissions for
fieldID - the field to set permissions for. If fieldID < 0, the permission will be applied to the object as a whole rather than any individual field within the object
See Also:
perm_field, PermEntry

setPerm

public arlut.csd.ganymede.ReturnVal setPerm(arlut.csd.ganymede.Base base,
                                            arlut.csd.ganymede.PermEntry entry)

Sets the permission entry for base <baseID> to PermEntry <entry>.

This operation will fail if this PermissionMatrixDBField is not editable.

Specified by:
setPerm in interface perm_field
See Also:
perm_field, PermMatrix

setPerm

public arlut.csd.ganymede.ReturnVal setPerm(short baseID,
                                            arlut.csd.ganymede.PermEntry entry)

Sets the permission entry for this matrix for base <baseID> to PermEntry <entry>

This operation will fail if this PermissionMatrixDBField is not editable.

Specified by:
setPerm in interface perm_field
See Also:
perm_field, PermEntry

setFieldPerms

public arlut.csd.ganymede.ReturnVal setFieldPerms(short baseID,
                                                  arlut.csd.ganymede.PermEntry entry,
                                                  boolean includeBuiltins)

Sets the permission entry for all fields in base <baseID> to PermEntry <entry>

This operation will fail if this PermissionMatrixDBField is not editable.

Specified by:
setFieldPerms in interface perm_field
Parameters:
includeBuiltins - if true, this will set the permissions for the built-in fields to entry as well as the custom fields.

clean

private void clean()

This internal method is used to cull out any entries in this permissions field that are non-operative, either by referring to an object/field type that does not exist, or by being redundant.


matrixEntry

private java.lang.String matrixEntry(short baseID,
                                     short fieldID)

Private method to generate a key for use in our internal Hashtable, used to encode the permission for a given DBObjectBase and DBObjectBaseField.


matrixEntry

private java.lang.String matrixEntry(short baseID)

Private method to generate a key for use in our internal Hashtable, used to encode the permission for a given DBObjectBase.


checkpoint

public java.lang.Object checkpoint()

This method is used to basically dump state out of this field so that the DBEditSet checkpoint() code can restore it later if need be.

Overrides:
checkpoint in class DBField

rollback

public void rollback(java.lang.Object oldval)

This method is used to basically force state into this field.

It is used to place a value or set of values that were known to be good during the current transaction back into this field, without creating or changing this DBField's object identity.

Overrides:
rollback in class DBField

allowablePermEntry

public boolean allowablePermEntry(short baseID,
                                  short fieldID,
                                  arlut.csd.ganymede.PermEntry entry)

This method is used to check that the given operation can be set by the current administrator.

If fieldID < 0, entry will be checked against the administrator's applicable base permissions.


debugdump

public void debugdump()
This method does a dump to System.err of the permission contents held in this field.