ch.interlis.ilirepository.impl
Class RepositoryAccess

java.lang.Object
  extended by ch.interlis.ilirepository.impl.RepositoryAccess

public class RepositoryAccess
extends java.lang.Object

Handles access to a file in a repository. Hides the caching, downloading of files.

Author:
ceis

Constructor Summary
RepositoryAccess()
           
 
Method Summary
static java.lang.String calcMD5(java.io.File file)
          Calculates the digest of a local file.
 IliFiles getIliFiles(java.lang.String uri)
          Gets the list of ili-files for a given repository.
 IliSite getIliSite(java.lang.String uri)
          Gets the site metadata for a given repository.
 java.io.File getLocalFileLocation(java.lang.String uri, java.lang.String filename, long maxTTL, java.lang.String md5)
          Gets access to a file.
 void setCache(java.io.File localdir)
          Sets the local folder to be used for caching remote files.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepositoryAccess

public RepositoryAccess()
Method Detail

setCache

public void setCache(java.io.File localdir)
Sets the local folder to be used for caching remote files.


getIliFiles

public IliFiles getIliFiles(java.lang.String uri)
Gets the list of ili-files for a given repository.

Parameters:
uri - local or remote repository
Returns:
list of ili-files or null if no such repository or offline.

getIliSite

public IliSite getIliSite(java.lang.String uri)
Gets the site metadata for a given repository.

Parameters:
uri - local or remote repository
Returns:
site metadata or null if no such repository or offline.

getLocalFileLocation

public java.io.File getLocalFileLocation(java.lang.String uri,
                                         java.lang.String filename,
                                         long maxTTL,
                                         java.lang.String md5)
                                  throws RepositoryAccessException
Gets access to a file. If the file is in a remote repository, it will be downloaded to the cache and path to the version in the cache is returned. If the file is already in the cache, the repository will be checked for never version depending on age of cached file and md5 digest.

Parameters:
uri - remote or local repository
filename - file/path to download from repository. If null, uri includes the file name.
maxTTL - max age of file in cache before downloading it again.
md5 - digest of remote file or null. If cached version has a different digest, download remote file again.
Returns:
local file or null if it doesn't exist in remote repository
Throws:
RepositoryAccessException

calcMD5

public static java.lang.String calcMD5(java.io.File file)
Calculates the digest of a local file.

Parameters:
file - local file
Returns:
md5 digest of local file content.