edu.sdsc.inca.repository
Class Repositories

java.lang.Object
  extended byedu.sdsc.inca.repository.Repositories

public class Repositories
extends java.lang.Object

Provides convenience methods for dealing with a set of Inca reporter repositories. This object may keep its persistence by writing the list of repositories to file.

Author:
Shava Smallen <ssmallen@sdsc.edu>

Field Summary
static java.lang.String DEFAULT_PATH
           
static java.lang.String DEPENDS_ATTR
           
static java.lang.String FILE_ATTR
           
static java.lang.String NAME_ATTR
           
static java.lang.String VERSION_ATTR
           
 
Constructor Summary
Repositories()
          Creates a Repositories object using the default repositories file to store its state.
Repositories(java.lang.String filePath)
          Creates a Repositories object using the provided filePath to read/save the list of repositories.
 
Method Summary
 void addRepository(Repository repo)
          Add a repository to the set.
 java.util.Properties[] getCatalog()
          Returns an array of Properties, each of which specifies the attributes of one reporter from the Agent's reporter repositories.
 java.lang.String getFilePath()
          Retrieve the path to the repositories file.
 java.lang.String getLatestVersionOfPackage(java.lang.String name)
          Return the latest version available for the named package in any of the repositories.
 Repository[] getRepositories()
          Returns the list of reporter repositories stored in the object.
 Repository getRepositoryForPackage(java.lang.String packageName, java.lang.String version)
          Return the repository that contains the specified package with the specified version.
 java.lang.String getRepositoryUrlForPackage(java.lang.String packageName, java.lang.String version)
          Translate the package name into a repository url.
 boolean hasPackageUpdated(java.lang.String name, java.lang.String version)
          Checks for a package update by iterating through all repositories and returns true if it finds a version of the package more recent than the specified one.
 void refresh()
          Refresh the current catalog contents of all repositories.
 void removeRepository(java.lang.String baseURL)
          Removes the repository with a particular URL from the set.
protected  void saveRepositories(java.lang.String filePath)
          Writes the set of repository URLs to a specified file.
 void setFilePath(java.lang.String filePath)
          Set the path to the repositories file.
 void setRepositories(Repository[] repos)
          Set the repositories the agent should download reporters from upon receiving a suite (if it hasn't downloaded them before).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PATH

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

DEPENDS_ATTR

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

FILE_ATTR

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

NAME_ATTR

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

VERSION_ATTR

public static final java.lang.String VERSION_ATTR
See Also:
Constant Field Values
Constructor Detail

Repositories

public Repositories()
             throws java.io.IOException
Creates a Repositories object using the default repositories file to store its state.

Throws:
java.io.IOException

Repositories

public Repositories(java.lang.String filePath)
             throws java.io.IOException
Creates a Repositories object using the provided filePath to read/save the list of repositories.

Parameters:
filePath - A path to a file containing newline delimited uris to Inca reporter repositories; null for none
Throws:
java.io.IOException
Method Detail

addRepository

public void addRepository(Repository repo)
Add a repository to the set.

Parameters:
repo - the repository to add

getCatalog

public java.util.Properties[] getCatalog()
Returns an array of Properties, each of which specifies the attributes of one reporter from the Agent's reporter repositories.

Returns:
a property set of every reporter in any repository

getFilePath

public java.lang.String getFilePath()
Retrieve the path to the repositories file.

Returns:
A string containing the path to the repositories file.

getLatestVersionOfPackage

public java.lang.String getLatestVersionOfPackage(java.lang.String name)
Return the latest version available for the named package in any of the repositories.

Parameters:
name - The name of the package to search for.
Returns:
The latest version of the named package or null if not found.

getRepositories

public Repository[] getRepositories()
Returns the list of reporter repositories stored in the object.

Returns:
A list of repository objects.

getRepositoryForPackage

public Repository getRepositoryForPackage(java.lang.String packageName,
                                          java.lang.String version)
Return the repository that contains the specified package with the specified version. If version is null, we get the latest version in all repositories.

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

getRepositoryUrlForPackage

public java.lang.String getRepositoryUrlForPackage(java.lang.String packageName,
                                                   java.lang.String version)
Translate the package name into a repository url. The first repository that contains the specified package will be returned.

Parameters:
packageName - A package name.
Returns:
A url to the specified package on a repository.

hasPackageUpdated

public boolean hasPackageUpdated(java.lang.String name,
                                 java.lang.String version)
Checks for a package update by iterating through all repositories and returns true if it finds a version of the package more recent than the specified one.

Returns:
True if the package was updated and false if it was not.

refresh

public void refresh()
             throws java.io.IOException
Refresh the current catalog contents of all repositories.

Throws:
java.io.IOException

removeRepository

public void removeRepository(java.lang.String baseURL)
Removes the repository with a particular URL from the set.

Parameters:
baseURL - the URL of the repository to remove

setFilePath

public void setFilePath(java.lang.String filePath)
                 throws java.io.IOException
Set the path to the repositories file.

Parameters:
filePath - A string containing the path to where the repositories file can be read/stored.
Throws:
java.io.IOException - on write error

setRepositories

public void setRepositories(Repository[] repos)
Set the repositories the agent should download reporters from upon receiving a suite (if it hasn't downloaded them before).

Parameters:
repos - A list of repositories.

saveRepositories

protected void saveRepositories(java.lang.String filePath)
                         throws java.io.IOException
Writes the set of repository URLs to a specified file.

Parameters:
filePath - the file to write
Throws:
java.io.IOException - on error