jpl.eda.archive.server
Class Product

java.lang.Object
  extended byjpl.eda.archive.server.Product

public class Product
extends java.lang.Object

This class represents the interface to a product's references.

This class uses the following property to populate the prodId and Identifier elements of a product's profile:

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

Field Summary
static java.lang.String FILE_DATA_LOCAL
          Constant for FILE_DATA_LOCAL
static java.lang.String FILE_DATA_REMOTE
          Constant for FILE_DATA_REMOTE
static java.lang.String FILE_METADATA
          Constant for FILE_METADATA
 
Constructor Summary
Product(jpl.eda.util.JDBC_DB db, Dataset dataset)
          Constructor given a database connection and dataset information.
Product(jpl.eda.util.JDBC_DB db, Dataset dataset, int productId)
          Deprecated. Replaced by a combination of Product(JDBC_DB, Dataset) and load(int).
 
Method Summary
 void add(java.lang.String productName, java.lang.String productOwner)
          This method adds the product to the product metadata table after generating an unique identifier and determining the version.
 void addReferences()
          Add the product item references to the product reference table.
 void delete()
          Delete all references to the associated product.
 Dataset getDataset()
          This method returns the Dataset associated with the product.
 int getProductId()
          This method returns the product identifier of the currently loaded product.
 ProductList getProductList()
          This method returns the product item list for the currently loaded product.
 java.util.HashMap getProductMetadata()
          This method creates and returns a hash map of element/value pairs for the currently loaded product.
 java.lang.String getProductName()
          This method returns the product name of the currently loaded product.
 java.lang.String getProductOwner()
          This method returns the product user name of the owner of the currently loaded product.
 jpl.eda.profile.Profile getProductProfile()
          This method creates and returns a Profile object representing the currently loaded product.
 java.lang.String getProductReceivedTime()
          This method returns the product received time of the currently loaded product.
 java.lang.String getProductStatusType()
          This method returns the product status type of the currently loaded product.
 int getProductVersion()
          This method returns the product version of the currently loaded product.
 void load(int productId)
          This method retrieves the product information for the given product identified by the identifier and then loads that information into the local variables.
 void load(java.lang.String productName)
          This method retrieves the product information for the given product with the latest version identified by name and then loads that information into the local variables.
 void load(java.lang.String productName, int productVersion)
          This method retrieves the product information for the given product identified by name and version and then loads that information into the local variables.
static void main(java.lang.String[] argv)
          Execute the Product class via the command-line.
 void updateLength(java.lang.String archiveRef, long length)
          Update the product item length in the product reference table.
 void updateStatus()
          Update the product status to NORMAL in the product metadata table.
 boolean validName(java.lang.String name)
          This method will determine whether the product name is valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_METADATA

public static final java.lang.String FILE_METADATA
Constant for FILE_METADATA

See Also:
Constant Field Values

FILE_DATA_LOCAL

public static final java.lang.String FILE_DATA_LOCAL
Constant for FILE_DATA_LOCAL

See Also:
Constant Field Values

FILE_DATA_REMOTE

public static final java.lang.String FILE_DATA_REMOTE
Constant for FILE_DATA_REMOTE

See Also:
Constant Field Values
Constructor Detail

Product

public Product(jpl.eda.util.JDBC_DB db,
               Dataset dataset)
        throws ProductException
Constructor given a database connection and dataset information. Initializes the class for adding or retrieving product information.

Parameters:
db - The database connection.
dataset - The dataset information.
Throws:
ProductException - If the data type list cannot be retrieved from the database.

Product

public Product(jpl.eda.util.JDBC_DB db,
               Dataset dataset,
               int productId)
        throws ProductException
Deprecated. Replaced by a combination of Product(JDBC_DB, Dataset) and load(int).

Constructor given a database connection, dataset information and product identifier.

Parameters:
db - The database connection.
dataset - The dataset information.
productId - The product identifier.
Throws:
ProductException - If the product cannot be retrieved from the database.
Method Detail

add

public void add(java.lang.String productName,
                java.lang.String productOwner)
         throws ProductException
This method adds the product to the product metadata table after generating an unique identifier and determining the version. The product reference list is also initialized.

Parameters:
productName - The name of the product.
productOwner - The owner of the product.
Throws:
ProductException - If the product cannot be inserted into the database.

addReferences

public void addReferences()
                   throws ProductException
Add the product item references to the product reference table.

Throws:
ProductException - If the insert to the database fails.

load

public void load(java.lang.String productName)
          throws ProductException
This method retrieves the product information for the given product with the latest version identified by name and then loads that information into the local variables.

Parameters:
productName - The name of the product.
Throws:
ProductException - If the product cannot be retrieved from the database.

load

public void load(java.lang.String productName,
                 int productVersion)
          throws ProductException
This method retrieves the product information for the given product identified by name and version and then loads that information into the local variables.

Parameters:
productName - The name of the product.
productVersion - The version of the product.
Throws:
ProductException - If the product cannot be retrieved from the database.

load

public void load(int productId)
          throws ProductException
This method retrieves the product information for the given product identified by the identifier and then loads that information into the local variables.

Parameters:
productId - The product identifier.
Throws:
ProductException - If the product cannot be retrieved from the database.

getDataset

public Dataset getDataset()
This method returns the Dataset associated with the product.

Returns:
The dataset information.

getProductId

public int getProductId()
This method returns the product identifier of the currently loaded product.

Returns:
The identifier.

getProductName

public java.lang.String getProductName()
This method returns the product name of the currently loaded product.

Returns:
The name.

getProductVersion

public int getProductVersion()
This method returns the product version of the currently loaded product.

Returns:
The version.

getProductStatusType

public java.lang.String getProductStatusType()
This method returns the product status type of the currently loaded product. Valid value include ADD_IN_PROGRESS, DELETE_IN_PROGRESS, CORRUPT, and NORMAL.

Returns:
The status type.

getProductReceivedTime

public java.lang.String getProductReceivedTime()
This method returns the product received time of the currently loaded product. This date/time value is in ISO 8601 format.

Returns:
The received time.

getProductOwner

public java.lang.String getProductOwner()
This method returns the product user name of the owner of the currently loaded product.

Returns:
The owner.

getProductList

public ProductList getProductList()
This method returns the product item list for the currently loaded product.

Returns:
The list.

getProductMetadata

public java.util.HashMap getProductMetadata()
This method creates and returns a hash map of element/value pairs for the currently loaded product.

Returns:
The hash map of element/value pairs.

getProductProfile

public jpl.eda.profile.Profile getProductProfile()
This method creates and returns a Profile object representing the currently loaded product.

Returns:
A Profile of the product.

delete

public void delete()
            throws ProductException
Delete all references to the associated product. This includes the product_metadata_? and product_reference_? table entries as well as any actual files in the repository. If any portion of this action fails, the status for the associated product will be set to CORRUPT.

Throws:
ProductException - If an error occurs deleting the files or their references

validName

public boolean validName(java.lang.String name)
This method will determine whether the product name is valid. A product name must begin with a letter, number or a period. Every other character in the name must be a letter, number, period, underscore, dash or colon.

Parameters:
name - The name of the product to validate.
Returns:
True or False.

updateLength

public void updateLength(java.lang.String archiveRef,
                         long length)
                  throws ProductException
Update the product item length in the product reference table.

Parameters:
archiveRef - The archive reference to the product item.
length - The length of the product item in bytes.
Throws:
ProductException - If the update to the database fails.

updateStatus

public void updateStatus()
                  throws ProductException
Update the product status to NORMAL in the product metadata table.

Throws:
ProductException - If the update to the database fails.

main

public static void main(java.lang.String[] argv)
Execute the Product class via the command-line.

The command-line arguments are as follows:

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

Parameters:
argv - The command-line arguments.


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