jpl.eda.archive
Class ArchiveProductHandler

java.lang.Object
  extended byjpl.eda.archive.ArchiveProductHandler
All Implemented Interfaces:
jpl.eda.product.LargeProductQueryHandler, jpl.eda.product.QueryHandler

public class ArchiveProductHandler
extends java.lang.Object
implements jpl.eda.product.LargeProductQueryHandler

This class implements the LargeProductQueryHandler interface enabling a Product Server to access the Catalog and Archive Service (CAS).

In order to use this handler the following property must be specified for the Product Server as follows:

This class uses the following property:

The above property may be defined in the Product Server's properties element.

Version:
$Revision: 1.3 $
Author:
S. Hardman

Constructor Summary
ArchiveProductHandler()
           
 
Method Summary
 void close(java.lang.String id)
          Notify the server that a particular file transfer has completed.
static void main(java.lang.String[] argv)
          Execute the large product handler.
 jpl.eda.xmlquery.XMLQuery query(jpl.eda.xmlquery.XMLQuery xmlQuery)
          Query for the result set associated with the given product.
 byte[] retrieveChunk(java.lang.String id, long offset, int length)
          Retrieve a fragment of the data from the specified file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArchiveProductHandler

public ArchiveProductHandler()
Method Detail

query

public jpl.eda.xmlquery.XMLQuery query(jpl.eda.xmlquery.XMLQuery xmlQuery)
                                throws jpl.eda.product.ProductException

Query for the result set associated with the given product. The result set will consist of each file associated with the product that is locally archived. Files which are stored as remote references are not added to the result set. The query should resemble the following:

The characters making up the "CAS.ProductId" data element may be of any case and the {product_id} value may be any valid integer equaling the product identifier of an object residing in the Archive Service.

Specified by:
query in interface jpl.eda.product.QueryHandler
Parameters:
xmlQuery - The XMLQuery object containing the query.
Throws:
jpl.eda.product.ProductException - If the property is not set, the Archive Service cannot be accessed or the server returns an exception.

retrieveChunk

public byte[] retrieveChunk(java.lang.String id,
                            long offset,
                            int length)
                     throws jpl.eda.product.ProductException
Retrieve a fragment of the data from the specified file.

Specified by:
retrieveChunk in interface jpl.eda.product.LargeProductQueryHandler
Parameters:
id - The unique identifier for the file which is the archive reference.
offset - Skip into the file the specified number of bytes.
length - The number of bytes to read from the file.
Returns:
A fragment of the data in the file.
Throws:
jpl.eda.product.ProductException - If the server throws an exception.

close

public void close(java.lang.String id)
           throws jpl.eda.product.ProductException
Notify the server that a particular file transfer has completed.

Specified by:
close in interface jpl.eda.product.LargeProductQueryHandler
Parameters:
id - The unique identifier for the object.
Throws:
jpl.eda.product.ProductException - If the server throws an exception.

main

public static void main(java.lang.String[] argv)
Execute the large product handler.

The command-line arguments are as follows:

The program exits with status 0 on success, 1 on failure.

Properties specified inside the tag in the .edarc.xml file are not available when executed from the command-line. In this case default values are used and/or properties specified inside the main tag.

Ideally, from an actual client of the Product Service, the calling application should be able to call the LargeResult.getInputStream() method instead of calling the retrieveChunk() method and managing the transfer as it is done in this method. The former is simpler, but the later offers more control and possibly better exception handling.

Parameters:
argv - The command-line arguments.


Copyright © 1999-2005 NASA Jet Propulsion Laboratory, California Institute of Technology. All Rights Reserved.