net.dpml.transit
Interface ResourceHost


public interface ResourceHost

An interface that represents locations where the artifacts can be downloaded.

Version:
1.0.1
Author:
Digital Product Meta Library

Method Summary
 boolean checkPresence(Artifact artifact, boolean knownOnly)
          Checks if the Artifact is present on the resource host.
 Date download(Artifact artifact, OutputStream dest)
          Downloads the given artifact to the directory indicated.
 String getHostName()
          Returns the hostname of the resource host.
 int getPriority()
          Returns the priority of the resource host.
 URL getURL()
          Returns the full host url.
 boolean isEnabled()
          Return true if the resource host has been enabled.
 boolean isTrusted()
          Returns true if the ResourceHost is considered trusted.
 void upload(Artifact artifact, InputStream source)
          Uploads the given file to the resource host as an artifact.
 

Method Detail

download

public Date download(Artifact artifact,
                     OutputStream dest)
              throws IOException
Downloads the given artifact to the directory indicated.

The cachedir argument is the root cache directory, and the ResourceHost class is responsible for the creation of the directory structure of the group if nonexistent.

If the knownOnly argument is true, then only attempt download if the group is known to exist on this resource host.

Parameters:
artifact - the artifact that is requested to be downloaded.
dest - The output stream where to write the downloaded content.
Returns:
the lastModified date of the downloaded artifact.
Throws:
IOException - if an IO related error occurs

upload

public void upload(Artifact artifact,
                   InputStream source)
            throws IOException
Uploads the given file to the resource host as an artifact.

Parameters:
artifact - the artifact destination specification.
source - The input stream from where to read the content to be uploaded.
Throws:
IOException - if an IO related error occurs

checkPresence

public boolean checkPresence(Artifact artifact,
                             boolean knownOnly)
Checks if the Artifact is present on the resource host.

Performs a check to see if the artifact exists on the resource host. If knownOnly is set to true, then the implementation will only consult the knownGroups table, and if found there, it is considered found without checking at the resource host itself. If knownOnly is false, however, a connection will be established to the resource host and a check of the actual resource existence.

Parameters:
artifact - the artifact for which the method checks its presence.
knownOnly - does not perform a remote connection, and instead lookup the group table, and if not found there it will return false.
Returns:
true if the artifact can be located, false otherwise.

getHostName

public String getHostName()
Returns the hostname of the resource host.

This does not include any of the path, but does include any port number of this resource host.

Returns:
the hostname

getURL

public URL getURL()
Returns the full host url.

Returns:
the host url

isEnabled

public boolean isEnabled()
Return true if the resource host has been enabled.

Returns:
true if the resource host is enabled, false if not.

isTrusted

public boolean isTrusted()
Returns true if the ResourceHost is considered trusted.

Returns:
true if the host is trusted

getPriority

public int getPriority()
Returns the priority of the resource host. A high number indicates a more important host that should take precendence over a host with lower number.

Returns:
the host priority