com.softwareag.centrasite.policy.model
Class PolicyContext

java.lang.Object
  extended by com.softwareag.centrasite.policy.model.PolicyContext

public class PolicyContext
extends java.lang.Object

Defines a set of methods that can be used by the current Policy's rule executed to get details from the Policy Engine. For example, the object that the policy is applied to, the event that triggered the policy etc.

Every time a policy is executed in the policy engine, an instance of this class is instantiated with the relevant details.


Constructor Summary
PolicyContext(javax.xml.registry.infomodel.RegistryObject regObject)
           
 
Method Summary
 java.lang.Object addContextInfo(java.lang.String key, java.lang.Object value)
          Adds a parameter (key-value pair) to the PolicyContext.
 java.util.Map<java.lang.String,java.lang.Object> getAdditionalInfo()
          Returns a Map representation of the additional parameters set by Handler and Collector frameworks.
 javax.xml.registry.infomodel.RegistryObject getAppliedObject()
          Returns the RegistryObject in which the policy is applied.
 java.lang.String getAppliedObjectId()
          Returns the string representation of the RegistryObject that is applied.
 java.util.List<javax.xml.registry.infomodel.RegistryObject> getAppliedObjects()
          Returns all the objects that are applicable for the onTrigger event that triggered the policy Execution.
 java.util.Map<java.lang.String,java.lang.Object> getContextInfo()
          Returns the instance of java.util.Map that contains custom parameters set by the Policy Engine.
 java.lang.Object getContextInfo(java.lang.String key)
          Returns the value for the given key set by the Policy Engine.
 javax.xml.registry.infomodel.Concept getEventType()
          Returns the Event that triggered the policy execution
 java.util.Date getExecutionDate()
          Returns the execution date in the Date format.
 Policy getPolicy()
          Returns the current policy instance that is being executed.
 java.util.List<com.centrasite.jaxr.importexport.IEventCallback> getPolicyCallbackList()
          returns the Import/Export related callback instances if applicable
 java.lang.String getSessionId()
          Returns the session ID from the Policy Engine.
 javax.xml.registry.infomodel.User getUser()
          Returns the user who performed an action that results in the policy execution.
 void setAdditionalInfo(java.util.Map<java.lang.String,java.lang.Object> additionalInfo)
          Set a Map representation of the additional parameters set by Handler and Collector frameworks.
 void setAppliedObject(javax.xml.registry.infomodel.RegistryObject appliedObject)
          Set the RegistryObject in which the policy is applied.
 void setAppliedObjects(java.util.List<javax.xml.registry.infomodel.RegistryObject> appliedObjects)
          Set a Map representation of the additional parameters set by Handler and Collector frameworks.
 void setContextInfo(java.util.Map<java.lang.String,java.lang.Object> contextInfo)
          A set of parameters (key-value pairs) to the PolicyContext.
 void setEventType(javax.xml.registry.infomodel.Concept eventType)
          A set of parameters (key-value pairs) to the PolicyContext.
 void setPolicy(Policy policy)
          Sets the current policy instance that is being executed.
 void setPolicyCallbackList(java.util.List<com.centrasite.jaxr.importexport.IEventCallback> policyCallbackList)
          Set the Import/Export callback instances.
 void setSessionId(java.lang.String sessionId)
          Set the current session ID.
 void setUser(javax.xml.registry.infomodel.User user)
          Sets the user who performed an action that resulted in the policy execution.
 java.lang.String toString()
          Returns String representation of the PolicyContext.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PolicyContext

public PolicyContext(javax.xml.registry.infomodel.RegistryObject regObject)
Method Detail

getAppliedObject

public javax.xml.registry.infomodel.RegistryObject getAppliedObject()
Returns the RegistryObject in which the policy is applied.

Returns:
a RegistryObject

setAppliedObject

public void setAppliedObject(javax.xml.registry.infomodel.RegistryObject appliedObject)
Set the RegistryObject in which the policy is applied. It is used by the Policy Engine internally. This operation should not be invoked anywhere else.

Parameters:
appliedObject - - JAXR representation of the object in which the policy is applied

getAppliedObjectId

public java.lang.String getAppliedObjectId()
Returns the string representation of the RegistryObject that is applied.

Returns:
String representation of the RegistryObject key

getSessionId

public java.lang.String getSessionId()
Returns the session ID from the Policy Engine. The session ID is common for all the policies executed as an outcome of an event.

Returns:
String representation of the RegistryObject key

setSessionId

public void setSessionId(java.lang.String sessionId)
Set the current session ID. It is used by the Policy Engine internally. This operation should not be invoked anywhere else.

Parameters:
sessionId - - Session ID from the Policy Engine

getUser

public javax.xml.registry.infomodel.User getUser()
Returns the user who performed an action that results in the policy execution.

Returns:
JAXR User

setUser

public void setUser(javax.xml.registry.infomodel.User user)
Sets the user who performed an action that resulted in the policy execution. It is used by the Policy Engine internally. This operation should not be invoked anywhere else.

Parameters:
user - - JAXR representation of the user who performed an action that resulted in the policy execution.

getPolicy

public Policy getPolicy()
Returns the current policy instance that is being executed.

Returns:
Policy instance

setPolicy

public void setPolicy(Policy policy)
Sets the current policy instance that is being executed. It is used by the Policy Engine internally. This operation should not be invoked anywhere else.

Parameters:
policy - - Policy instance that is being executed.

getContextInfo

public java.util.Map<java.lang.String,java.lang.Object> getContextInfo()
Returns the instance of java.util.Map that contains custom parameters set by the Policy Engine.

Returns:
Policy instance

getContextInfo

public java.lang.Object getContextInfo(java.lang.String key)
Returns the value for the given key set by the Policy Engine.

Parameters:
key - - String representation of the key
Returns:
Object value for the given key

addContextInfo

public java.lang.Object addContextInfo(java.lang.String key,
                                       java.lang.Object value)
Adds a parameter (key-value pair) to the PolicyContext. It is used by the Policy Engine internally. This operation should not be invoked anywhere else.

Parameters:
key - - String representation of the key
value - - String representation of the value
Returns:
previous value associated with the specified key, or null if there was no mapping for the key.

setContextInfo

public void setContextInfo(java.util.Map<java.lang.String,java.lang.Object> contextInfo)
A set of parameters (key-value pairs) to the PolicyContext. It is used by the Policy Engine internally. This operation should not be invoked anywhere else.

Parameters:
contextInfo - - Parameters represented in key-value pairs

getEventType

public javax.xml.registry.infomodel.Concept getEventType()
Returns the Event that triggered the policy execution

Returns:
Concept - Policy event type represented in Concept

setEventType

public void setEventType(javax.xml.registry.infomodel.Concept eventType)
A set of parameters (key-value pairs) to the PolicyContext. It is used by the Policy Engine internally. This operation should not be invoked anywhere else.

Parameters:
eventType - - Policy event type represented in Concept

toString

public java.lang.String toString()
Returns String representation of the PolicyContext. The returned value looks as follows. PolicyContext{appliedObject=${appliedObj String}, appliedObjectId='${uuid}', sessionId='${sessionId}', user='${user}', policy='${policy}', contextInfo=${contextInfo}, eventType=${eventType}, executionDate=${executionDate}} Here ${object} represents the string representation of the given object

Overrides:
toString in class java.lang.Object
Returns:
Concept - Policy event type represented in Concept

getExecutionDate

public java.util.Date getExecutionDate()
Returns the execution date in the Date format.

Returns:
Date - execution date

getAdditionalInfo

public java.util.Map<java.lang.String,java.lang.Object> getAdditionalInfo()
Returns a Map representation of the additional parameters set by Handler and Collector frameworks.

Returns:
Map - A set of key value pairs

setAdditionalInfo

public void setAdditionalInfo(java.util.Map<java.lang.String,java.lang.Object> additionalInfo)
Set a Map representation of the additional parameters set by Handler and Collector frameworks. The assertions can make use of this method to share information in a session for a particular Event. It needs to be used carefully as policy priorities will decide the order of execution. Also if two or more policies have the same priority then the order of execution is dynamic and cannot be predicted.

Parameters:
additionalInfo - - A set of key value pairs

setAppliedObjects

public void setAppliedObjects(java.util.List<javax.xml.registry.infomodel.RegistryObject> appliedObjects)
Set a Map representation of the additional parameters set by Handler and Collector frameworks. The assertions can make use of this method to share information in a session for a particular Event. It needs to be used carefully as policy priorities will decide the order of execution. Also if two or more policies have the same priority then the order of execution is dynamic and cannot be predicted.

Parameters:
appliedObjects - - A set of key value pairs

getAppliedObjects

public java.util.List<javax.xml.registry.infomodel.RegistryObject> getAppliedObjects()
Returns all the objects that are applicable for the onTrigger event that triggered the policy Execution.

Returns:
List - a list of RegistryObject instances

getPolicyCallbackList

public java.util.List<com.centrasite.jaxr.importexport.IEventCallback> getPolicyCallbackList()
returns the Import/Export related callback instances if applicable

Returns:
List - a list of IEventCallback instances

setPolicyCallbackList

public void setPolicyCallbackList(java.util.List<com.centrasite.jaxr.importexport.IEventCallback> policyCallbackList)
Set the Import/Export callback instances.

Parameters:
policyCallbackList - - a list of IEventCallback instances