Cernunnos Manual


${checksum()}

Description:

Returns the Checksum value of the resource specified by LOCATION. This component currently uses the Adler32 algorythim.

Reagents:

Name XPath Description Reagent Type Expected Type Required
CONTEXT @context Optional context from which missing elements of the LOCATION will be inferred if it is relative. The default is the value of the 'Attributes.ORIGIN' request attribute. PHRASE java.lang.String No
LOCATION descendant-or-self::text() Optional location of a resource; if omitted, the value of the 'Attributes.LOCATION' request attribute will be used. LOCATION may be a filesystem path or a URL, and may be absolute or relative; if a relative value is provided, it will be resolved based on the value of CONTEXT. PHRASE java.lang.String No

Examples:

Takes a web address as a parameter (e.g. 'www.yahoo.com'); computes the checksum value of the document at the specified address, then copies that document to a local file called 'markup.html' and finally compares the checksum value of the local document against the previous, online checksum value:

 
       
        <with-attribute key="onlineChecksum" value="${checksum(http://${$1})}"> 
          <copy-file location="http://${$1}/" to-file="markup.html"/>  
          <with-attribute key="localChecksum" value="${checksum(markup.html)}"> 
            <groovy> 
              <script>if (onlineChecksum == localChecksum) { println 'Both checksum values are the same: ' + onlineChecksum; } else { println 'The checksum values are different:\n\tonline=' + onlineChecksum + '\n\tlocal=' + localChecksum; }</script> 
            </groovy> 
          </with-attribute> 
        </with-attribute>