oracle.mail.sdk.rule
Class RuleParser

java.lang.Object
  |
  +--oracle.mail.sdk.rule.RuleParser

public class RuleParser
extends java.lang.Object

This class provides APIs to store, retrieve and validate rules. Before using this class, you need an OESContext object that has been authenticated.

Since:
9.0
See Also:
OESContext

Constructor Summary
RuleParser()
          Default Constructor
RuleParser(oracle.mail.OESContext thecontext)
          Constructs a RuleParser object with a given authentication context

 

Method Summary
 oracle.xml.parser.v2.XMLDocument fileToDoc(java.lang.String fileName)
          Parse rule data in XML text from a file and return an XMLDocument object.
 java.lang.String getRule()
          Gets a user level rule as XML text as a regular mail user
 java.lang.String getRule(long userid)
          Deprecated. use of numerical userid is no longer supported, use String getRule(String name, String ruleType) instead
 java.lang.String getRule(java.lang.String name, java.lang.String ruleType)
          Retrieves rule as XML text as an administrator
 java.io.InputStream getRuleAsStream(long userid)
          Deprecated. use of numerical userid is no longer supported, use String getRule(String name, Strin ruleType) instead
 Account getRuleObjects()
          Retrieves rule data as Java objects as a regular mail user
 Account getRuleObjects(java.io.InputStream ruleStream)
          Deprecated. use getRuleObjects(Reader) instead
 Account getRuleObjects(long userid)
          Deprecated. use of numerical userid is no longer supported, use getRuleObjects() or getRuleObjects(String name, String ruleType) instead
 Account getRuleObjects(java.io.Reader ruleReader)
          Retreives rule data in Java objects given a Reader
 Account getRuleObjects(java.lang.String name, java.lang.String ruleType)
          Retrieves rule data in Java objects for a user as an administrator
static int loadRule(java.lang.String filename)
          Deprecated. user of static method to load rule is no longer supported. Use instance method setRule() instead.
 void renameUpdate(java.lang.String oldUsername, java.lang.String newUsername, oracle.mail.ldap.ESDSContext dctx, java.sql.Connection conn)
          Perform rule update as a result of a rename.
static java.lang.String retrieveRule(long userid)
          Deprecated. use of numeric userid is no longer supported, as well as access from static methods. Use instance method getRule() to retrieve rules instead.
 void setAuthContext(oracle.mail.OESContext oes)
          Sets authentication context.
 void setConnection(java.sql.Connection conn)
          Deprecated. Database connection will be managed internally. There's no need to call this method anymore.
static void setDBProperties(java.util.Properties dbinfo)
          Deprecated. use OESContext to access LDAP directory instead, which takes care of managing database connect info internally
 void setDebugMode(boolean mode)
          Change debug setting (stdout based logging)
 void setRule(oracle.xml.parser.v2.XMLDocument rule)
          Validate and save rule data in persistent storage.
 void setRuleObjects(Account rules)
          Saves rule to the directory given an Account object
 void setValidation(boolean toValidate)
          Sets rule validation mode.
 oracle.xml.parser.v2.XMLDocument stringToDoc(java.lang.String str)
          Parses rule data in XML text and return an XMLDocument object.
static int writeRule(java.lang.String ruleStr)
          Deprecated. use of static method is no longer supported. Use instance method setRule() instead

 

Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

RuleParser

public RuleParser()
           throws java.lang.Exception
Default Constructor

RuleParser

public RuleParser(oracle.mail.OESContext thecontext)
           throws java.lang.Exception
Constructs a RuleParser object with a given authentication context
Parameters:
thecontext - the authenticated OESContext object
See Also:
OESContext
Method Detail

setDBProperties

public static void setDBProperties(java.util.Properties dbinfo)
                            throws java.sql.SQLException
Deprecated. use OESContext to access LDAP directory instead, which takes care of managing database connect info internally
Set database connection property object directly

retrieveRule

public static java.lang.String retrieveRule(long userid)
Deprecated. use of numeric userid is no longer supported, as well as access from static methods. Use instance method getRule() to retrieve rules instead.
Get Rules from database identified by userid
Parameters:
userid - user ID
Returns:
rules as XML text in String format

loadRule

public static int loadRule(java.lang.String filename)
Deprecated. user of static method to load rule is no longer supported. Use instance method setRule() instead.
Upload a rule document from an external source, a filename or an URL
Parameters:
filename - name of file containing XML text
Returns:
possible error code

writeRule

public static int writeRule(java.lang.String ruleStr)
Deprecated. use of static method is no longer supported. Use instance method setRule() instead
Store a rules XML text in string to the database
Parameters:
ruleStr - rule XML text in String
Returns:
possible error code

setDebugMode

public void setDebugMode(boolean mode)
                  throws java.lang.Exception
Change debug setting (stdout based logging)
Parameters:
mode - the debug mode, true for stdout logging, false otherwise

setValidation

public void setValidation(boolean toValidate)
Sets rule validation mode. Use non-validating mode to save a partially constructed rule.
Parameters:
whether - to validate rules input

setAuthContext

public void setAuthContext(oracle.mail.OESContext oes)
Sets authentication context. An authentication context is an OESContext object that has been used to authenticate a valid user against an LDAP directory.
Parameters:
oes - the OESContext object containing authentication info
See Also:
OESContext

setConnection

public void setConnection(java.sql.Connection conn)
Deprecated. Database connection will be managed internally. There's no need to call this method anymore.
Set JDBC connection
Parameters:
conn - the connection to use for database operations

stringToDoc

public oracle.xml.parser.v2.XMLDocument stringToDoc(java.lang.String str)
                                             throws java.lang.Exception
Parses rule data in XML text and return an XMLDocument object. This method can be used to construct a DOM object based on a rule specification in XML format.
Parameters:
str - rule data in XML text
Returns:
an XMLDocument object representing the XML data

fileToDoc

public oracle.xml.parser.v2.XMLDocument fileToDoc(java.lang.String fileName)
                                           throws java.lang.Exception
Parse rule data in XML text from a file and return an XMLDocument object. Note that single quotes are NOT escaped in the process. Therefore the caller must make sure the XML file has all the single quotes (') escaped to two single quotes('').
Parameters:
fileName - file containing XML text
Returns:
an XMLDocument object representing the XML data

getRuleAsStream

public java.io.InputStream getRuleAsStream(long userid)
                                    throws java.lang.Exception
Deprecated. use of numerical userid is no longer supported, use String getRule(String name, Strin ruleType) instead
Retreive rule document as InputStream given userid
Parameters:
userid - user ID
Returns:
rules in XML text as a InputStream

getRule

public java.lang.String getRule(java.lang.String name,
                                java.lang.String ruleType)
                         throws java.lang.Exception
Retrieves rule as XML text as an administrator
Parameters:
name - the fully qualified name of the rule owner, can be either a user email address, a domain name or an installation name eg. john.doe@oracle.com, dmv.gov, install1
ruleType - values from ownerType attribute: "user", "domain" or "system"
Returns:
rule content in XML text

getRule

public java.lang.String getRule()
                         throws java.lang.Exception
Gets a user level rule as XML text as a regular mail user
Returns:
rule content in XML text

getRule

public java.lang.String getRule(long userid)
                         throws java.lang.Exception
Deprecated. use of numerical userid is no longer supported, use String getRule(String name, String ruleType) instead
Retreive rule document as XML text given userid
Parameters:
userid - user ID
Returns:
rules in XML text as a String

getRuleObjects

public Account getRuleObjects(java.io.InputStream ruleStream)
                       throws java.io.IOException,
                              org.xml.sax.SAXException,
                              oracle.xml.parser.v2.XMLParseException
Deprecated. use getRuleObjects(Reader) instead
Retreive rule object tree given an InputStream
Parameters:
ruleStream - an InputStream containing rule XML text
Returns:
Account object containing rule data

getRuleObjects

public Account getRuleObjects(java.io.Reader ruleReader)
                       throws java.io.IOException,
                              org.xml.sax.SAXException,
                              oracle.xml.parser.v2.XMLParseException
Retreives rule data in Java objects given a Reader
Parameters:
ruleReader - a Reader object containing rule XML text
Returns:
Account object containing rule data
See Also:
Account

getRuleObjects

public Account getRuleObjects(long userid)
                       throws java.lang.Exception
Deprecated. use of numerical userid is no longer supported, use getRuleObjects() or getRuleObjects(String name, String ruleType) instead
Retreive rule object tree given userid
Parameters:
userid - user ID
Returns:
Account object containing rule data

getRuleObjects

public Account getRuleObjects(java.lang.String name,
                              java.lang.String ruleType)
                       throws java.lang.Exception
Retrieves rule data in Java objects for a user as an administrator
Parameters:
name - rule owner name, either a qualified username, domain name or installation name
ruleType - valid values in ownerType attribute: "user", "domain" or "system"
Returns:
Account object containing the rules
See Also:
Account

getRuleObjects

public Account getRuleObjects()
                       throws java.lang.Exception
Retrieves rule data as Java objects as a regular mail user
Returns:
Account object containing the rules
See Also:
Account

setRule

public void setRule(oracle.xml.parser.v2.XMLDocument rule)
             throws java.lang.Exception
Validate and save rule data in persistent storage. This method checks rule's validity if the parser is in validating mode, then saves it in persistent storage and cache the rules in executable form in the database. Passing in an empty rule object (with no rule lists) causes the method to remove all rules from the user.
Parameters:
rule - an XMLDocument object containing rule data
See Also:
XMLDocument

setRuleObjects

public void setRuleObjects(Account rules)
                    throws java.lang.Exception
Saves rule to the directory given an Account object
Parameters:
rules - an Account object containing rule data
See Also:
Account

renameUpdate

public void renameUpdate(java.lang.String oldUsername,
                         java.lang.String newUsername,
                         oracle.mail.ldap.ESDSContext dctx,
                         java.sql.Connection conn)
                  throws java.lang.Exception
Perform rule update as a result of a rename. This should be performed before the actual rename happens in LDAP.
Parameters:
oldUsername - old mail user ID (qualified)
newUsername - new name (qualified)
dctx - authenticated LDAP context
conn - JDBC database connection