org.jasig.portal.car
Class ProcessIfTagHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.jasig.portal.car.ProcessIfTagHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class ProcessIfTagHandler
extends org.xml.sax.helpers.DefaultHandler

Handles a "processIf" tag looking for the following attributes and blocking SAX events from reaching nested tags if the specified requirements are not met.

  fname = the functional name whose version is to be checked
  version = value is one of lessThan, greaterThan, lessThanOrEqual,
    greaterThanOrEqual, equalTo, or notEqualTo.
  major = the revision level major part
  minor = the revision level minor part
  micro = the revision level micro part
  setMajor = optional, the new revision level major part
  setMinor = optional, the new revision level minor part
  setMicro = optional, the new revision level micro part
 
The contents of the processIf tag are only processed if the version of the specified fname matches the requirements as specified in the version, major, minor, and micro attributes. If the setMajor, setMinor, and setMicro attributes are specified then and additional test is performed to determine if processing will occur. This test involves attempting to set the version of the fname to that specified. If unable to then processing will be skipped for this block. This is done to allow the same CAR to be deployed on all servers in a multi-server deployment but only have on of the servers perform the processing of the block and affect the database. There is no limit on the number of processIf blocks that can occur in a deployment descriptor. All other nested tags are supported within the processIf tag. The processIf tag can not be nested inside of itself.

Version:
$Revision: 1.2 $
Author:
Mark Boyd

Field Summary
private  ParsingContext ctx
           
private  boolean enabled
           
private static java.lang.String EQU
           
private static java.lang.String GTR_THAN
           
private static java.lang.String GTR_THAN_OR_EQU
           
private static java.lang.String LESS_THAN
           
private static java.lang.String LESS_THAN_OR_EQU
           
private static org.apache.commons.logging.Log log
           
private static java.lang.String NOT_EQU
           
private  RoutingHandler routingHandler
           
 
Constructor Summary
ProcessIfTagHandler(ParsingContext ctx, RoutingHandler routingHandler)
           
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
           
private  boolean evaluate(java.lang.String testType, java.lang.String fname, int major, int minor, int micro)
          Determines if the version specified and the version recorded in the system indicate that the block should be processed.
(package private)  void setAttributes(org.xml.sax.Attributes atts)
          Passes the attributes of the processIf tag that is currently being parsed to this handler allowing it to determine if it should allow SAX events to be passed to the contained tag handlers or not.
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

enabled

private boolean enabled

routingHandler

private RoutingHandler routingHandler

ctx

private ParsingContext ctx

LESS_THAN

private static final java.lang.String LESS_THAN
See Also:
Constant Field Values

GTR_THAN

private static final java.lang.String GTR_THAN
See Also:
Constant Field Values

LESS_THAN_OR_EQU

private static final java.lang.String LESS_THAN_OR_EQU
See Also:
Constant Field Values

GTR_THAN_OR_EQU

private static final java.lang.String GTR_THAN_OR_EQU
See Also:
Constant Field Values

EQU

private static final java.lang.String EQU
See Also:
Constant Field Values

NOT_EQU

private static final java.lang.String NOT_EQU
See Also:
Constant Field Values
Constructor Detail

ProcessIfTagHandler

ProcessIfTagHandler(ParsingContext ctx,
                    RoutingHandler routingHandler)
Method Detail

setAttributes

void setAttributes(org.xml.sax.Attributes atts)
Passes the attributes of the processIf tag that is currently being parsed to this handler allowing it to determine if it should allow SAX events to be passed to the contained tag handlers or not.

Parameters:
atts -

evaluate

private boolean evaluate(java.lang.String testType,
                         java.lang.String fname,
                         int major,
                         int minor,
                         int micro)
Determines if the version specified and the version recorded in the system indicate that the block should be processed.

Parameters:
testType -
fname -
major -
minor -
micro -
Returns:
true if the block should be processed.

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException