com.waveset.object
Class RoleAttribute

java.lang.Object
  extended bycom.waveset.util.AbstractXmlObject
      extended bycom.waveset.object.RoleAttribute
All Implemented Interfaces:
java.lang.Comparable, javax.naming.Referenceable, XmlObject

public class RoleAttribute
extends AbstractXmlObject
implements java.lang.Comparable

An object representing a Role Attribute.

Role Attributes modify resource account attributes values. the following modifications are supported:

AttributeRequirement.REQ_DEFAULT = "Default value"; AttributeRequirement.REQ_FORCE = "Set to value"; AttributeRequirement.REQ_MERGE = "Merge with value"; AttributeRequirement.REQ_MERGE_WITH_CLEAR = "Merge with value, clear existing"; AttributeRequirement.REQ_REMOVE

All role attributes on a User are gathered, sorted by attribute and action, and applied. Conflicts may cause errors. The most common conflicts are:

- multiple default values (warn but not error) - multiple set values (error) MultipleAttributeSet exception - set with delete or merge (error) ConflictingAttributeSet exception - delete with merge (warning ?) ConflictingAttributeSet exception


Nested Class Summary
static class RoleAttribute.AttributeRequirement
           
 
Field Summary
static java.lang.String code_id
           
static java.lang.String EL_ATTRIBUTE_NAME
           
static java.lang.String EL_COMMENT
           
static java.lang.String EL_REQUIREMENT
           
static java.lang.String EL_RESOURCE
           
static java.lang.String EL_VALUE
           
static java.lang.String EL_VALUE_TYPE
           
static java.lang.String ELEMENT
          Name of the serialized XML element.
protected static Trace trace
           
 
Fields inherited from class com.waveset.util.AbstractXmlObject
_trace
 
Constructor Summary
RoleAttribute()
          Builds an empty Role Attribute.
RoleAttribute(org.w3c.dom.Element e)
          Builds a Rule from XML.
RoleAttribute(java.lang.String resourceName, java.lang.String attributeName, RoleAttribute.AttributeRequirement requirement, java.lang.Object value)
           
RoleAttribute(java.lang.String resourceName, java.lang.String attributeName, RoleAttribute.AttributeRequirement requirement, ObjectRef ruleRef)
           
 
Method Summary
static java.lang.String checkConflict(RoleAttribute potentialConflict, RoleAttribute ra)
          Check for a conflict between the two role attributes.
static java.util.List checkConflicts(java.util.List attrs)
          Check for conflicts in the list of role attributes.
 int compareTo(java.lang.Object o)
          Implement the comparable interface so that lists of these will have a reasonable contains() implementation.
 java.lang.Object eval(ExState state)
          Evaluate the rule in a given expression environment.
 java.lang.String getAttributeName()
           
 java.lang.Object getAttributeValue()
           
 ObjectCache getCache()
           
 java.lang.String getComments()
           
 java.lang.String getContainerName()
           
 java.lang.String getElementName()
          Return the element name.
 java.lang.String getName()
          Get the name.
 RoleAttribute.AttributeRequirement getRequirement()
           
static java.util.List getRequirementKeys()
           
static java.util.List getRequirementKeys(java.lang.Object bogus)
          Return a list with entries: localizedKey1 key1 ...
static java.util.List getRequirements()
           
 java.lang.String getResourceName()
           
 ObjectRef getResourceRef()
           
 int hashCode()
          Implement the hashCode for efficient map insertion.
 boolean isAuthoritative()
           
 boolean isClear()
           
 boolean isCSV()
           
 boolean isDefault()
           
 boolean isSameTargetAttribute(RoleAttribute ra)
          Return true if this attribute matches the resource and attribute name
 void parseXml(org.w3c.dom.Element e)
           
static java.util.ArrayList parseXmlList(org.w3c.dom.Element e)
          Builds an ArrayList of reference objects by parsing the XML representation of a reference list.
 void removeAuthoritativeValue(GenericObject view, java.lang.String path, java.lang.Object value)
          Remove the values for an authoritative role attribute from the current view value.
 void resolveResourceRef()
          The resource, if any, that's tracked by this RoleAttribute can become stale.
 void setAttributeName(java.lang.String s)
           
 void setAttributeValue(java.lang.Object o)
           
 void setCache(ObjectCache cache)
           
 void setComments(java.lang.String s)
           
 void setContainerName(java.lang.String name)
           
 void setCSV(boolean b)
           
 void setName(java.lang.String name)
           
 void setRequirement(RoleAttribute.AttributeRequirement ar)
           
 void setResource(java.lang.String nameOrId)
           
 void setResourceRef(ObjectRef or)
           
 boolean setViewAttribute(GenericObject view, java.lang.String path, java.lang.Object value)
          Put the given object in the view at the given path.
static void sortToEvaluationOrder(java.util.List attrs)
          Sort a List of role attributes.
 java.lang.String toString()
          Our string representation is :
 void toXml(java.lang.StringBuffer b, int indent)
          Serialize into a buffer with optional indentation.
 
Methods inherited from class com.waveset.util.AbstractXmlObject
addXmlHeader, cloneObject, dump, dumpFile, getReference, println, setTrace, toIdentityString, toVerboseString, toVerboseString, toXml, toXml, toXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values

ELEMENT

public static final java.lang.String ELEMENT
Name of the serialized XML element.

See Also:
Constant Field Values

trace

protected static final Trace trace

EL_RESOURCE

public static final java.lang.String EL_RESOURCE
See Also:
Constant Field Values

EL_REQUIREMENT

public static final java.lang.String EL_REQUIREMENT
See Also:
Constant Field Values

EL_VALUE

public static final java.lang.String EL_VALUE
See Also:
Constant Field Values

EL_VALUE_TYPE

public static final java.lang.String EL_VALUE_TYPE
See Also:
Constant Field Values

EL_COMMENT

public static final java.lang.String EL_COMMENT
See Also:
Constant Field Values

EL_ATTRIBUTE_NAME

public static final java.lang.String EL_ATTRIBUTE_NAME
See Also:
Constant Field Values
Constructor Detail

RoleAttribute

public RoleAttribute()
Builds an empty Role Attribute.


RoleAttribute

public RoleAttribute(org.w3c.dom.Element e)
              throws WavesetException
Builds a Rule from XML.


RoleAttribute

public RoleAttribute(java.lang.String resourceName,
                     java.lang.String attributeName,
                     RoleAttribute.AttributeRequirement requirement,
                     java.lang.Object value)
              throws WavesetException

RoleAttribute

public RoleAttribute(java.lang.String resourceName,
                     java.lang.String attributeName,
                     RoleAttribute.AttributeRequirement requirement,
                     ObjectRef ruleRef)
              throws WavesetException
Method Detail

getElementName

public java.lang.String getElementName()
Description copied from class: AbstractXmlObject
Return the element name.

Specified by:
getElementName in interface XmlObject
Specified by:
getElementName in class AbstractXmlObject

getName

public java.lang.String getName()
Get the name.


setName

public void setName(java.lang.String name)

getComments

public java.lang.String getComments()

setComments

public void setComments(java.lang.String s)

getAttributeName

public java.lang.String getAttributeName()

setAttributeName

public void setAttributeName(java.lang.String s)

getAttributeValue

public java.lang.Object getAttributeValue()

setAttributeValue

public void setAttributeValue(java.lang.Object o)

getRequirement

public RoleAttribute.AttributeRequirement getRequirement()

setRequirement

public void setRequirement(RoleAttribute.AttributeRequirement ar)

getRequirements

public static java.util.List getRequirements()

getRequirementKeys

public static java.util.List getRequirementKeys(java.lang.Object bogus)
Return a list with entries: localizedKey1 key1 ... Used for the valueMap property of Select in forms


getRequirementKeys

public static java.util.List getRequirementKeys()

getResourceRef

public ObjectRef getResourceRef()

getResourceName

public java.lang.String getResourceName()

setResource

public void setResource(java.lang.String nameOrId)

setResourceRef

public void setResourceRef(ObjectRef or)

setCache

public void setCache(ObjectCache cache)

getCache

public ObjectCache getCache()

setContainerName

public void setContainerName(java.lang.String name)

getContainerName

public java.lang.String getContainerName()

isAuthoritative

public boolean isAuthoritative()

isDefault

public boolean isDefault()

isClear

public boolean isClear()

isCSV

public boolean isCSV()

setCSV

public void setCSV(boolean b)

eval

public java.lang.Object eval(ExState state)
                      throws WavesetException
Evaluate the rule in a given expression environment. This is the one that will normally be used, so the ExState can be reused across evaluations, and perform more complex reference and function resolution than we can do with our builtin RuleState. As a side-effect, the result is stored for possible later retrieval.

Throws:
WavesetException

setViewAttribute

public boolean setViewAttribute(GenericObject view,
                                java.lang.String path,
                                java.lang.Object value)
Put the given object in the view at the given path. This is a convenience method since we have the resource name and attribute name resolved here. Depending on the requirement, different actions can occur: REQ_DEFAULT - place in view if view has no value for this attribute REQ_FORCE - replace any value in view REQ_MERGE - add this to the view value, merging into a list if needed REQ_REMOVE - remove this value from the view

Parameters:
view - - the view to operate on
path - - the path of the attribute to update
Returns:
- true if the value was changed

removeAuthoritativeValue

public void removeAuthoritativeValue(GenericObject view,
                                     java.lang.String path,
                                     java.lang.Object value)
Remove the values for an authoritative role attribute from the current view value.


toXml

public void toXml(java.lang.StringBuffer b,
                  int indent)
Description copied from class: AbstractXmlObject
Serialize into a buffer with optional indentation. This must be implemented by the subclass.

Specified by:
toXml in interface XmlObject
Specified by:
toXml in class AbstractXmlObject

parseXml

public void parseXml(org.w3c.dom.Element e)
              throws WavesetException
Throws:
WavesetException

parseXmlList

public static java.util.ArrayList parseXmlList(org.w3c.dom.Element e)
                                        throws WavesetException
Builds an ArrayList of reference objects by parsing the XML representation of a reference list.

The provided element is expected to be the wrapper elements, its name is unimportant. We extract any elements contained in the wrapper.

Throws:
WavesetException

compareTo

public int compareTo(java.lang.Object o)
Implement the comparable interface so that lists of these will have a reasonable contains() implementation. To compare these objects, they must have an attribute and and resource name

Specified by:
compareTo in interface java.lang.Comparable

toString

public java.lang.String toString()
Our string representation is :


checkConflict

public static java.lang.String checkConflict(RoleAttribute potentialConflict,
                                             RoleAttribute ra)
Check for a conflict between the two role attributes. This can assume that the toString methods have returned the same name. The four merge options are all mapped to REQ_MERGE. The two force options are mapped to REQ_FORCE.


hashCode

public int hashCode()
Implement the hashCode for efficient map insertion. Make this work like compareTo


checkConflicts

public static java.util.List checkConflicts(java.util.List attrs)
Check for conflicts in the list of role attributes. Build a list of conflict error messages to return. A conflict is defined as two or more role attributes that reference the same attribute (resource and attribute name match) and have different values or conflicting operations. - multiple default values (warn but not error) - multiple set values (error) MultipleAttributeSet exception - set with delete or merge (error) ConflictingAttributeSet exception - delete with merge (warning ?) ConflictingAttributeSet exception The process is to build a hashmap, keyed by the toString() values of the attributes. If another value with the same key is found, check for a conflict - if that is found, add an error message.

Returns:
List of String messages, one per conflict.

sortToEvaluationOrder

public static void sortToEvaluationOrder(java.util.List attrs)
Sort a List of role attributes. The sort keys are: operator precedence (as defined by getRequirementsByPrecedence) resource attribute name object hashCode to make the sort stable.


isSameTargetAttribute

public boolean isSameTargetAttribute(RoleAttribute ra)
Return true if this attribute matches the resource and attribute name


resolveResourceRef

public void resolveResourceRef()
The resource, if any, that's tracked by this RoleAttribute can become stale. For example, the name tagging along with the resource... that name can be incorrect if the resource was ever renamed. rwagner