edu.sdsc.inca.repository
Class Repository

java.lang.Object
  extended by edu.sdsc.inca.repository.Repository

public class Repository
extends java.lang.Object

The Repository class provides access to the contents of an Inca reporter repository--the catalog of Reporter packages and the packages themselves.


Field Summary
protected  java.net.URL baseUrl
           
protected  java.util.Properties[] catalog
           
static java.lang.String CATALOG_NAME
           
 
Constructor Summary
Repository(java.net.URL baseURL)
          Instantiates a repository accessed via a base URL.
Repository(java.net.URL baseURL, java.util.Properties[] catalog)
          Instantiates a repository with a catalog generated elsewhere.
 
Method Summary
 boolean equals(java.lang.String repositoryUrl)
          Returns true if the given repository url matches this repository url.
 boolean exists(java.lang.String propertyName, java.lang.String value)
          Return whether a package exists in the repository with a given property name and value.
 java.util.Properties[] getCatalog()
          Returns information about the contents of the repository.
 java.lang.String getLatestVersionOfPackage(java.lang.String packageName)
          Return the latest version of the specified package that exists in this repository or null if it doesn't exist.
 java.util.Properties getProperties(java.lang.String name, java.lang.String version)
          Retrieve the repository properties for the specified package and version.
 java.util.Properties[] getPropertiesByLookup(java.lang.String property, java.lang.String value)
          Returns properties for all packages that match the given property name and value.
static java.lang.String[] getPropertyValues(java.lang.String s)
          Splits a property value from a catalog reporter entry into a set of values.
 byte[] getReporter(java.lang.String path)
          Returns the contents of a file located via a specified path in the repository.
 ReporterPackage getReporterPackage(java.lang.String path)
          Returns a binary package located via a specified path in the repository.
 java.net.URL getURL()
          Returns the base URL through which this Repository is accessed.
static void main(java.lang.String[] args)
          The main for this class is a test program that lists the contents of one or more repositories listed on the command line.
 void refresh()
          Refresh the catalog contents by downloading the Packages.gz file and replacing the current contents.
 void setCatalog(java.util.Properties[] catalog)
          Force the repository catalog to be a specified set of reporters.
 java.lang.String toString()
          Override of the default toString method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CATALOG_NAME

public static final java.lang.String CATALOG_NAME
See Also:
Constant Field Values

baseUrl

protected java.net.URL baseUrl

catalog

protected java.util.Properties[] catalog
Constructor Detail

Repository

public Repository(java.net.URL baseURL)
           throws java.io.IOException
Instantiates a repository accessed via a base URL.

Parameters:
baseURL - the URL for the repository
Throws:
java.io.IOException - if the repository does not exist or has no catalog

Repository

public Repository(java.net.URL baseURL,
                  java.util.Properties[] catalog)
Instantiates a repository with a catalog generated elsewhere.

Parameters:
baseURL - the URL for the repository
catalog - an array of Properties, each element of which describes one reporter/package in the repository
Method Detail

equals

public boolean equals(java.lang.String repositoryUrl)
Returns true if the given repository url matches this repository url. This function will return true for file urls that match either file: or file:// formats.

Parameters:
repositoryUrl - A url that we are comparing to this repository.
Returns:
True if the given url matches the repository url and false otherwise.

exists

public boolean exists(java.lang.String propertyName,
                      java.lang.String value)
Return whether a package exists in the repository with a given property name and value.

Parameters:
propertyName - Name of the reporter package property.
value - Value we expect the property to equal
Returns:
true if a package exists in the repository with the given property else false.

getCatalog

public java.util.Properties[] getCatalog()
Returns information about the contents of the repository.

Returns:
an array of Properties, each element of which describes one reporter/package

getLatestVersionOfPackage

public java.lang.String getLatestVersionOfPackage(java.lang.String packageName)
Return the latest version of the specified package that exists in this repository or null if it doesn't exist.

Parameters:
packageName - The name of the package we are looking for.
Returns:
The latest version of the specified package or null if it does not exist.

getProperties

public java.util.Properties getProperties(java.lang.String name,
                                          java.lang.String version)
Retrieve the repository properties for the specified package and version.

Parameters:
name - The name of the package to retrieve properties on.
version - The version of the package to retrieve properties on.
Returns:
The properties of the specified package and version retrieved from the repository catalog.

getPropertiesByLookup

public java.util.Properties[] getPropertiesByLookup(java.lang.String property,
                                                    java.lang.String value)
Returns properties for all packages that match the given property name and value.

Parameters:
property - Name of the reporter package property.
value - Value we expect the property to equal.
Returns:
List of properties from packages that match the given property.

getReporter

public byte[] getReporter(java.lang.String path)
                   throws java.io.IOException
Returns the contents of a file located via a specified path in the repository.

Parameters:
path - the relative path to the file
Returns:
the file contents
Throws:
java.io.IOException

getReporterPackage

public ReporterPackage getReporterPackage(java.lang.String path)
                                   throws java.io.IOException
Returns a binary package located via a specified path in the repository.

Parameters:
path - the relative path to the package file
Returns:
the package contents
Throws:
java.io.IOException

getURL

public java.net.URL getURL()
Returns the base URL through which this Repository is accessed.

Returns:
the repository base URL

refresh

public void refresh()
             throws java.io.IOException
Refresh the catalog contents by downloading the Packages.gz file and replacing the current contents.

Throws:
java.io.IOException - if the repository does not exist or has no catalog

setCatalog

public void setCatalog(java.util.Properties[] catalog)
Force the repository catalog to be a specified set of reporters.

Parameters:
catalog - an array of Properties, each element of which describes one reporter/package in the repository

toString

public java.lang.String toString()
Override of the default toString method.

Overrides:
toString in class java.lang.Object

getPropertyValues

public static java.lang.String[] getPropertyValues(java.lang.String s)
Splits a property value from a catalog reporter entry into a set of values.

Parameters:
s - A property value from a catalog reporter entry
Returns:
A set of zero or more individual values split out from the passed value

main

public static void main(java.lang.String[] args)
The main for this class is a test program that lists the contents of one or more repositories listed on the command line.