Novell exteNd
Director 5.2 API

com.sssw.re.api
Interface EbiContext

All Superinterfaces:
EbiContext, EbiRequestContext

public interface EbiContext
extends EbiRequestContext

Stores information about the rule context and the user's portal environment. EbiContext stores the user's ID, the user's portal session, response and request objects appropriate to the current user agent or browser, and information about the content being requested.

Information that persists between requests is stored in the EbiSession object, which is available from the context. The session includes a "whiteboard" that holds values that a component needs to keep available. You give each whiteboard value a key, which you use to retrieve the value. If there is no session, the portal creates a session-independent whiteboard for storing your persistent data. For more information, see Using whiteboard values in Director online help.

In a portal component, you can get the rule EbiContext from the EbiPortalContext object "context", passed in from getComponentData(). Here is the method you need:

 com.sssw.re.api.EbiContext ctx =
     com.sssw.re.factory.EboFactory.createEbiContext(
     context.getEbiRequest().getHttpServletRequest(),
     context.getEbiResponse().getHttpServletResponse(),
     context.getServletContext());
 
You can also get a generic context object from com.sssw.re.factory.EboFactory.

See Also:
EbiPortalContext, EboFactory.createEbiContext(HttpServletRequest request, HttpServletResponse response, ServletContext servletContext)

Method Summary
 EbiContext fireRule(String ruleID)
          Executes a rule.
 EbiContext fireTemporaryRule(String ruleXML)
          Executes a rule that you supply in XML format.
 boolean getLog()
          Returns the Boolean variable log, which indicates whether or not logging is active for the current request.
 String getPipelineID()
          Gets the ID of the active rules pipeline.
 int getResponseType()
          Gets the HTTP response type the component will find in the response phrase.
 String getURLString()
          Gets the url String set on the context object.
 boolean isLog()
          Returns the Boolean variable log, which indicates whether or not logging is active for the current request.
 String merge(String string)
          Processes text that contains !valueOf expressions.
 String mergeEncoded(String string)
          Adds URL encoding to a merged text.
 void setLog(boolean log)
          Passes the boolean variable log, which indicates whether or not logging is active for the current request.
 void setPipelineID(String pipelineID)
          Sets the active pipeline for the portal context.
 void setResponseType(int responseType)
          Sets the HTTP response type, which describes the type of value the portal component will find in the response phrase.
 void setRuleID(String ruleID)
          Sets the rule ID for the current context.
 void setURLString(String url)
          Sets the url string for the current context.
 void setUserID(String userID)
          Sets the user ID associated with the context object.
 void validate()
          Fires the rules associated with the current rules pipeline for the current user.
 void validate(String pipelineID)
          Fires the rules associated with the specified rules pipeline for the current user.
 
Methods implemented from interface com.sssw.fw.api.EbiRequestContext
getContentType, getCookieValue, getResponsePhrase, getResponseStatus, getServletContext, getURI, hasQueryString, setContentType, setCookieValue, setRequestResponse, setResponsePhrase, setResponseStatus, setServletContext, setURI
 
Methods implemented from interface com.sssw.fw.api.EbiContext
cloneCopy, getAttributeNames, getBrowserInfo, getContextName, getEbiRequest, getEbiResponse, getEbiSession, getEbiSession, getEbiWhiteboard, getEJBContext, getException, getLocale, getPrincipal, getTemporaryData, getTemporaryValue, getValue, getValue, getValueNames, hasSession, hasValue, isNewSession, removeAllValues, removeValue, setEbiRequest, setEbiResponse, setEbiSession, setEJBContext, setException, setTemporaryValue, setValue
 

Method Detail

setUserID

public void setUserID(String userID)
Sets the user ID associated with the context object. It does not check whether the user ID is valid.

You might set the user ID if you are writing a login component. If your portal stores the user's ID in a cookie to save the trouble of logging on every time, you can retrieve the cookie and call setUserID().

Parameters:
userID - a String that holds a user ID

setRuleID

public void setRuleID(String ruleID)
Sets the rule ID for the current context.
Parameters:
rule - Rule to be set in the current context.
See Also:
EbiContext.fireRule(String ruleID)

setURLString

public void setURLString(String url)
Sets the url string for the current context.
Parameters:
String - whose value is a URL.
See Also:
EbiContext.getURLString()

fireRule

public EbiContext fireRule(String ruleID)
Executes a rule. The rules engine evaluates the rule's conditions and performs the specified action.

When firing a rule you need to handle the result of the rule's action. For implementation options see Handling the results of a rule in Director online help.

Parameters:
ruleID - the name of a rule stored in your Director project's resource set. Rules that you create in the Rules Designer in eXtend Workbench are saved to this location.
Returns:
This EbiContext object. Since you already have a reference to the context object when you call the method, you can ignore the return value.
See Also:
EbiRuleManager.fireRule(String ruleID, EbiContext context), EbiContext.fireTemporaryRule(String ruleXML), EbiRequestContext.getResponsePhrase(), EbiRequestContext.getResponseStatus(), EbiContext.getValue( String key)

fireTemporaryRule

public EbiContext fireTemporaryRule(String ruleXML)
Executes a rule that you supply in XML format.

For more information, see Firing temporary rules in Director online help.

Parameters:
ruleXML - a String whose value is an XML rule definition
Returns:
This EbiContext object. Since you already have a reference to the context object when you call the method, you can ignore the return value.
See Also:
EbiRuleManager.fireTemporaryRule(String ruleXML, EbiContext context)

getLog

public boolean getLog()
Returns the Boolean variable log, which indicates whether or not logging is active for the current request.
Returns:
Boolean log; true means logging is active, false means logging is inactive.

getPipelineID

public String getPipelineID()
Gets the ID of the active rules pipeline. In the Rule Editor, you can specify a default pipeline that is automatically associated with your Ebicontext object.
Returns:
a String whose value is the pipeline ID
See Also:
EbiContext.setPipelineID(String pipelineID), EbiContext.validate()

getURLString

public String getURLString()
Gets the url String set on the context object.
Returns:
a String whose value is a URL String
See Also:
EbiContext.setPipelineID(String pipelineID )

getResponseType

public int getResponseType()
Gets the HTTP response type the component will find in the response phrase. These types are defined in EbiResponse: CONTENT, HTML, TEXT, and URL. Your component can use the type to determine what to do with the response phrase.

The type is valid only if a rule or other code set it.

Returns:
an integer indicating the type of information in the response phrase
See Also:
EbiResponse

isLog

public boolean isLog()
Returns the Boolean variable log, which indicates whether or not logging is active for the current request.
Returns:
Boolean log; true means logging is active, false means logging is inactive.
See Also:
EbiContext.getLog(), EbiContext.setLog(boolean log)

merge

public String merge(String string)
Processes text that contains !valueOf expressions. The merge() method finds !valueOf expressions in the passed template, gets the keyname associated with it, and gets the value of that key from the whiteboard. When you evaluate the expressions, the keyname must exist as a whiteboard key.

!valueOf expressions are typically used as parameters for conditions and actions. When you write a custom condition or action, you can call merge() to resolve !valueOf expressions in its properties. You can also use these expressions in content stored in the content management system.

For more information, see Using whiteboard values in Director online help.

Parameters:
template - a String that includes one or more !valueOf expressions
Returns:
a String where the !valueOf expressions have been replaced by values from the whiteboard. If template didn't include any !valueOf expressions, the original String is returned.
See Also:
EbiAction, EbiCondition, EboStringTemplate

mergeEncoded

public String mergeEncoded(String string)
Adds URL encoding to a merged text. (For more information, see java.net.URLEncoder.)
Parameters:
template - A String that includes one or more !valueOf expressions
Returns:
A String where the !valueOf expressions have been replaced by encoded values from the whiteboard. If template didn't include any !valueOf expression, an encoded version of the original String is returned.
See Also:
EbiContext.merge(String string)

setLog

public void setLog(boolean log)
Passes the boolean variable log, which indicates whether or not logging is active for the current request.
Parameters:
Boolean - log; true means logging is active, false means logging is inactive.

setPipelineID

public void setPipelineID(String pipelineID)
Sets the active pipeline for the portal context. The pipeline runs its rules when you call the validate() method.
Parameters:
pipelineID - a String containing a valid pipeline ID
See Also:
EbiContext.validate(), EbiContext.getPipelineID()

setResponseType

public void setResponseType(int responseType)
Sets the HTTP response type, which describes the type of value the portal component will find in the response phrase. These types are defined in EbiResponse: CONTENT, HTML, TEXT, and URL. Your component can use the type to determine what to do with the response phrase.

Typically, code that sets the response phrase should also set the response type.

Parameters:
responseType - an integer, as defined in EbiResponse, identifying the type of information in the response phrase
See Also:
EbiResponse, EbiRequestContext.setResponsePhrase( String phrase )

validate

public void validate()
              throws com.sssw.re.exception.EboValidateException
Fires the rules associated with the current rules pipeline for the current user. The results of the rules are typically available as the response phrase, status, and type.

Pipelines are a series of steps with rules associated with them. The pipeline takes session information, such as the user and the user's group, and checks them against criteria specified in rules.

For more information, see Developing pipelines in Director online help.
Throws:
com.sssw.re.exception.EboValidateException - when the pipeline is null
See Also:
EbiRequestContext.getResponsePhrase(), EbiRequestContext.getResponseStatus(), EbiContext.getResponseType(), EbiContext.setPipelineID(String pipelineID)

validate

public void validate(String pipelineID)
              throws com.sssw.re.exception.EboValidateException
Fires the rules associated with the specified rules pipeline for the current user. The results of the rules are typically available as the response phrase, status, and type.

Pipelines are a series of steps with rules associated with them. The pipeline takes session information, such as the user and the user's group, and checks them against criteria specified in rules. For more information, see Developing pipelines in Director online help.

Throws:
com.sssw.re.exception.EboValidateException - when the pipeline is not valid
See Also:
EbiRequestContext.getResponsePhrase(), EbiRequestContext.getResponseStatus(), EbiContext.getResponseType()

Novell exteNd
Director 5.2 API