© 2002 BEA Systems, Inc.


com.bea.campaign
Class ScenarioHelper

java.lang.Object
  |
  +--com.bea.campaign.ScenarioHelper

public class ScenarioHelper
extends java.lang.Object

Utility helper class for campaigns and scenarios.


Field Summary
static int FALSE
          Database indicator for false in NUMBER columns.
static long GOAL_CHECK_TIME
          Deprecated. Use CampaignServiceMBean.getGoalCheckTime() instead.
static java.lang.String LOG_APP_NAME
          The logging application name.
static boolean LOG_VERBOSE
          Deprecated. Use Debug instead.
static int TRUE
          Database indicator for true in NUMBER columns.
 
Constructor Summary
ScenarioHelper()
           
 
Method Summary
static java.lang.String checkAttribute(org.w3c.dom.Element e, java.lang.String name, java.lang.String val)
          Check if the value of the element's required attribute is the desired value.
static java.lang.String checkAttribute(org.w3c.dom.Element e, java.lang.String name, java.lang.String[] vals)
          Check if the value of the element's required attribute is in the list of possible values.
static java.lang.String checkAttribute(org.w3c.dom.Element e, java.lang.String name, java.lang.String val1, java.lang.String val2)
          Check if the value of the element's required attribute is one of the desired values.
static void close(java.sql.Connection con)
          Close a connection, ignoring any errors.
static void close(java.sql.ResultSet rs)
          Close a result set, ignoring any errors.
static void close(java.sql.Statement stmt)
          Close a statement, ignoring any errors.
static java.lang.String getAttribute(org.w3c.dom.Element e, java.lang.String name)
          Get the value of an element's required attribute.
static boolean getBoolean(java.sql.ResultSet rs, int index)
          Get a boolean from a numeric column.
static java.lang.String getCampaignId(Event evt)
          Get the campaign id from an Event.
static java.lang.String getCharacterData(org.w3c.dom.Element e)
          Get the character data contained in the element.
static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
          Get a default DocumentBuilder.
static javax.xml.parsers.DocumentBuilder getDocumentBuilder(boolean validate)
          Get an either validating or non-validating DocumentBuilder.
static java.sql.Timestamp getISO8601Date(org.w3c.dom.Element e)
          Get a date from a the ISO 8601 formatted character data contained in an element.
static java.lang.String getNodeType(org.w3c.dom.Node n)
          Get the node's type as a string.
static java.lang.String getNodeType(short type)
          Get a string describing the Node type.
static java.lang.String getTagName(org.w3c.dom.Element e)
          Get the non-namespace-prefixed tag name of an element.
static java.lang.String getUserId(Event evt)
          Get the user id from an Event.
static ProfileWrapper getUserProfileWrapper(java.lang.String userId, javax.servlet.http.HttpServletRequest req)
          Get a user profile wrapper for the given user id from the given request.
static void log(int level, java.lang.String mesg, java.lang.Throwable ex)
          Deprecated. Use WLS logging instead
static void logDebug(java.lang.String mesg)
          Deprecated. Use Debug instead
static void logDebug(java.lang.String mesg, java.lang.Throwable ex)
          Deprecated. Use Debug instead
static void logError(java.lang.String mesg)
          Deprecated. Use WLS logging instead
static void logError(java.lang.String mesg, java.lang.Throwable ex)
          Deprecated. Use WLS logging instead
static void logInfo(java.lang.String mesg)
          Deprecated. Use WLS logging instead
static void logInfo(java.lang.String mesg, java.lang.Throwable ex)
          Deprecated. Use WLS logging instead
static void logVerbose(java.lang.String mesg)
          Deprecated. Use Debug instead
static void logVerbose(java.lang.String mesg, java.lang.Throwable ex)
          Deprecated. Use Debug instead
static void logWarning(java.lang.String mesg)
          Deprecated. Use WLS logging instead
static void logWarning(java.lang.String mesg, java.lang.Throwable ex)
          Deprecated. Use WLS logging instead
static org.w3c.dom.Document parse(javax.xml.parsers.DocumentBuilder parser, org.xml.sax.InputSource src)
          Parse an input source, using the DefaultEntityResolver.
static org.w3c.dom.Document parse(org.xml.sax.InputSource src)
          Parse an input source, using the DefaultEntityResolver.
static org.w3c.dom.Document parse(org.xml.sax.InputSource src, boolean validate)
          Parse an input source, using the DefaultEntityResolver.
static org.w3c.dom.Document parse(java.io.Reader in)
          Parse an input stream, using the DefaultEntityResolver.
static org.w3c.dom.Document parse(java.io.Reader in, boolean validate)
          Parse an input stream, using the DefaultEntityResolver.
static void setBoolean(java.sql.PreparedStatement stmt, int index, boolean b)
          Set a boolean in a numeric column.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_APP_NAME

public static final java.lang.String LOG_APP_NAME
The logging application name.

TRUE

public static final int TRUE
Database indicator for true in NUMBER columns.

FALSE

public static final int FALSE
Database indicator for false in NUMBER columns.

LOG_VERBOSE

public static final boolean LOG_VERBOSE
Deprecated. Use Debug instead.
Does this log verbose messages.

This is always initialized to false now.

See Also:
Debug

GOAL_CHECK_TIME

public static final long GOAL_CHECK_TIME
Deprecated. Use CampaignServiceMBean.getGoalCheckTime() instead.
How often should the campaign service check campaign goals, in milliseconds.

This is always set to 300,000ms (5 minutes).

Constructor Detail

ScenarioHelper

public ScenarioHelper()
Method Detail

getUserProfileWrapper

public static ProfileWrapper getUserProfileWrapper(java.lang.String userId,
                                                   javax.servlet.http.HttpServletRequest req)
                                            throws ProfileNotFoundException,
                                                   java.rmi.RemoteException
Get a user profile wrapper for the given user id from the given request.

This will first try the profile in the request/session, then it will attempt to retrieve a profile.

See Also:
SessionHelper

getUserId

public static java.lang.String getUserId(Event evt)
Get the user id from an Event.

This checks the following event attributes, in this order:

  1. user-id
  2. user_id
  3. userId
  4. userid
  5. USERID


getCampaignId

public static java.lang.String getCampaignId(Event evt)
Get the campaign id from an Event.

This checks the following event attributes, in this order:

  1. campaign_id
  2. campaignId
  3. campaignid
  4. CAMPAIGNID


getDocumentBuilder

public static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
                                                            throws org.xml.sax.SAXException
Get a default DocumentBuilder.

getDocumentBuilder

public static javax.xml.parsers.DocumentBuilder getDocumentBuilder(boolean validate)
                                                            throws org.xml.sax.SAXException
Get an either validating or non-validating DocumentBuilder.

parse

public static org.w3c.dom.Document parse(javax.xml.parsers.DocumentBuilder parser,
                                         org.xml.sax.InputSource src)
                                  throws org.xml.sax.SAXException,
                                         java.io.IOException
Parse an input source, using the DefaultEntityResolver.

Parameters:
parser - the document builder to use.
src - the input source.
Returns:
a DOM Document of the XML.
Throws:
org.xml.sax.SAXException - thrown on a parse error.
java.io.IOException - thrown on an error reading the input source.

parse

public static org.w3c.dom.Document parse(org.xml.sax.InputSource src,
                                         boolean validate)
                                  throws org.xml.sax.SAXException,
                                         java.io.IOException
Parse an input source, using the DefaultEntityResolver.

Parameters:
src - the input source.
validate - true to validate, false to not.
Returns:
a DOM Document of the XML.
Throws:
org.xml.sax.SAXException - thrown on a parse error.
java.io.IOException - thrown on an error reading the input source.

parse

public static org.w3c.dom.Document parse(org.xml.sax.InputSource src)
                                  throws org.xml.sax.SAXException,
                                         java.io.IOException
Parse an input source, using the DefaultEntityResolver.

Parameters:
src - the input source.
Returns:
a DOM Document of the XML.
Throws:
org.xml.sax.SAXException - thrown on a parse error.
java.io.IOException - thrown on an error reading the input source.

parse

public static org.w3c.dom.Document parse(java.io.Reader in,
                                         boolean validate)
                                  throws org.xml.sax.SAXException,
                                         java.io.IOException
Parse an input stream, using the DefaultEntityResolver.

Parameters:
in - the input stream.
validate - true to validate, false to not.
Returns:
a DOM Document of the XML.
Throws:
org.xml.sax.SAXException - thrown on a parse error.
java.io.IOException - thrown on an error reading the input source.

parse

public static org.w3c.dom.Document parse(java.io.Reader in)
                                  throws org.xml.sax.SAXException,
                                         java.io.IOException
Parse an input stream, using the DefaultEntityResolver.

Parameters:
in - the input stream.
validate - true to validate, false to not.
Returns:
a DOM Document of the XML.
Throws:
org.xml.sax.SAXException - thrown on a parse error.
java.io.IOException - thrown on an error reading the input source.

getTagName

public static java.lang.String getTagName(org.w3c.dom.Element e)
Get the non-namespace-prefixed tag name of an element.

See Also:
DomHelper.getTagName(org.w3c.dom.Element)

getAttribute

public static java.lang.String getAttribute(org.w3c.dom.Element e,
                                            java.lang.String name)
                                     throws java.lang.IllegalArgumentException
Get the value of an element's required attribute.

Parameters:
e - the element.
name - the attribute name.
Returns:
the attribute value.
Throws:
java.lang.IllegalArgumentException - thrown if the attribute is not set.

checkAttribute

public static java.lang.String checkAttribute(org.w3c.dom.Element e,
                                              java.lang.String name,
                                              java.lang.String[] vals)
                                       throws java.lang.IllegalArgumentException
Check if the value of the element's required attribute is in the list of possible values.

Parameters:
e - the element.
name - the attribute name.
vals - the possible values.
Returns:
the attribute value.
Throws:
java.lang.IllegalArgumentException - thrown if the attribute is not set or it's value is not one of the possible values.

checkAttribute

public static java.lang.String checkAttribute(org.w3c.dom.Element e,
                                              java.lang.String name,
                                              java.lang.String val)
                                       throws java.lang.IllegalArgumentException
Check if the value of the element's required attribute is the desired value.

Parameters:
e - the element.
name - the attribute name.
val - the desired value.
Returns:
the attribute value.
Throws:
java.lang.IllegalArgumentException - thrown if the attribute is not set or it's value is not the desired value.

checkAttribute

public static java.lang.String checkAttribute(org.w3c.dom.Element e,
                                              java.lang.String name,
                                              java.lang.String val1,
                                              java.lang.String val2)
                                       throws java.lang.IllegalArgumentException
Check if the value of the element's required attribute is one of the desired values.

Parameters:
e - the element.
name - the attribute name.
val1 - the 1st desired value.
val2 - the 2st desired value.
Returns:
the attribute value.
Throws:
java.lang.IllegalArgumentException - thrown if the attribute is not set or it's value is not one of the desired values.

getCharacterData

public static java.lang.String getCharacterData(org.w3c.dom.Element e)
                                         throws java.lang.IllegalArgumentException
Get the character data contained in the element.

If the character data is a CDATA section, it will be returned intact. Otherwise, it will be trimmed of leading and trailing whitespace.

Parameters:
e - the element.
Returns:
the character data.
Throws:
java.lang.IllegalArgumentException - thrown if the element does not contain only character data.

getISO8601Date

public static java.sql.Timestamp getISO8601Date(org.w3c.dom.Element e)
                                         throws java.lang.IllegalArgumentException
Get a date from a the ISO 8601 formatted character data contained in an element.

Throws:
java.lang.IllegalArgumentException - thrown on an error.
See Also:
XMLDateTimeUtil

getNodeType

public static java.lang.String getNodeType(org.w3c.dom.Node n)
Get the node's type as a string.

getNodeType

public static java.lang.String getNodeType(short type)
Get a string describing the Node type.

close

public static void close(java.sql.Connection con)
Close a connection, ignoring any errors.

See Also:
JdbcHelper.close(java.sql.Connection)

close

public static void close(java.sql.Statement stmt)
Close a statement, ignoring any errors.

See Also:
JdbcHelper.close(java.sql.Statement)

close

public static void close(java.sql.ResultSet rs)
Close a result set, ignoring any errors.

See Also:
JdbcHelper.close(java.sql.ResultSet)

getBoolean

public static boolean getBoolean(java.sql.ResultSet rs,
                                 int index)
                          throws java.sql.SQLException
Get a boolean from a numeric column.

See Also:
TRUE, FALSE

setBoolean

public static void setBoolean(java.sql.PreparedStatement stmt,
                              int index,
                              boolean b)
                       throws java.sql.SQLException
Set a boolean in a numeric column.

See Also:
TRUE, FALSE

logVerbose

public static void logVerbose(java.lang.String mesg,
                              java.lang.Throwable ex)
Deprecated. Use Debug instead
Log a verbose campaign/scenario message.

See Also:
Debug

logVerbose

public static void logVerbose(java.lang.String mesg)
Deprecated. Use Debug instead
Log a verbose campaign/scenario message.

See Also:
Debug

logDebug

public static void logDebug(java.lang.String mesg,
                            java.lang.Throwable ex)
Deprecated. Use Debug instead
Log a debug campaign/scenario message.

See Also:
Debug

logDebug

public static void logDebug(java.lang.String mesg)
Deprecated. Use Debug instead
Log a debug campaign/scenario message.

See Also:
Debug

logInfo

public static void logInfo(java.lang.String mesg,
                           java.lang.Throwable ex)
Deprecated. Use WLS logging instead
Log an informational campaign/scenario message.

logInfo

public static void logInfo(java.lang.String mesg)
Deprecated. Use WLS logging instead
Log an informational campaign/scenario message.

logWarning

public static void logWarning(java.lang.String mesg,
                              java.lang.Throwable ex)
Deprecated. Use WLS logging instead
Log a warning campaign/scenario message.

logWarning

public static void logWarning(java.lang.String mesg)
Deprecated. Use WLS logging instead
Log a warning campaign/scenario message.

logError

public static void logError(java.lang.String mesg,
                            java.lang.Throwable ex)
Deprecated. Use WLS logging instead
Log an error campaign/scenario message.

logError

public static void logError(java.lang.String mesg)
Deprecated. Use WLS logging instead
Log an error campaign/scenario message.

log

public static void log(int level,
                       java.lang.String mesg,
                       java.lang.Throwable ex)
Deprecated. Use WLS logging instead
Log a verbose campaign/scenario message.

© 2002 BEA Systems, Inc.

Copyright © 2002 BEA Systems, Inc. All Rights Reserved