Overview | Package | Class | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## es.upm.gib.aewrapper.cache
Class CacheManager

    java.lang.Object
      es.upm.gib.aewrapper.cache.CacheManager

    public class CacheManager

extends java.lang.Object

Class that allows managing the cache of arrayexpress experiments in disk

The cache of experiments in disk is organized as follows: There is one base dir for the cache. That dir is read at the start of execution, and never changes. From it, a dir for each experiment is placed. The name of that dir is always the accession number of the experiment (e.g: C:\AECACHE\E-MEXP_221). In these dirs, three files should be located: one xml file containing the experiment itself as downloaded from the ae database (in mage format), an owl file containing the owl version of the experiment. The names of these files are, respectively, exp.xml and exp.owl. The third file contains the size, in bytes, of the downloaded file (this allows to quickly check if an experiment is up to date). This file simply contains one text line with a long value (the byte length).

There does not exist any master file describing which experiments are stored. To check if an experiment is cached, we simply look at its directory and the two files. If any of these elements are missing, it means that the experiment is not cached.

This manager gives facilities for accessing cached experiments, caching new experiments or even deleting cached experiments. Manual deletion of experiments should be avoided if the server is running, as it could cause a conflict in case a request arrives at the same time.

Constructor Summary
`CacheManager()`

Method Summary
`static void` | `addExperiment(java.lang.String expID, java.lang.String originalFilePath, long length)` Adds an experiment to the cache
`static void` | `deleteExperiment(java.lang.String expID)` Deletes an experiment from the cache
`static java.lang.String` | `getExperimentOriginalFile(java.lang.String expID)` Retrieves the original mage-ml file of an experiment
`static java.lang.String` | `getExperimentOwlFile(java.lang.String expID)` Retrieves the owl file of an experiment
`static java.lang.Long` | `getExperimentSize(java.lang.String expID)` Returns the size of an experiment
`static boolean` | `isCached(java.lang.String expID)` Says whether a specific experiment is cached
`static void` | `updateExperimentOWLFile(java.lang.String expID)` Updates only the owl file of a cached experiment

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### CacheManager

    public CacheManager()

Method Detail

### isCached

    public static boolean isCached(java.lang.String expID)
                            throws org.jdom.JDOMException,
                                   LocalConfigException

  Says whether a specific experiment is cached

  Parameters:
    `expID` - the identifier of the experiment
  Returns:
    true if the given experiment is cached, false otherwise
  Throws:
    `org.jdom.JDOMException` - errors in the XML syntax of the configuration file
    `LocalConfigException` - errors in the configuration file

### updateExperimentOWLFile

    public static void updateExperimentOWLFile(java.lang.String expID)
                                        throws MageParsingException,
                                               org.jdom.JDOMException,
                                               LocalConfigException

  Updates only the owl file of a cached experiment

  Parameters:
    `expID` - identifier of the experiment
  Throws:
    `MageParsingException` - problems generating the obm file from the mage document
    `org.jdom.JDOMException` - errors in the XML syntax of the configuration file
    `LocalConfigException` - errors in the configuration file

### getExperimentOriginalFile

    public static java.lang.String getExperimentOriginalFile(java.lang.String expID)
                                                      throws org.jdom.JDOMException,
                                                             LocalConfigException

  Retrieves the original mage-ml file of an experiment

  Parameters:
    `expID` - the identifier of the experiment
  Returns:
    the path to the mage-ml file of the requested experiment, or null if the experiment is not cached
  Throws:
    `org.jdom.JDOMException` - errors in the XML syntax of the configuration file
    `LocalConfigException` - errors in the configuration file

### getExperimentOwlFile

    public static java.lang.String getExperimentOwlFile(java.lang.String expID)
                                                 throws org.jdom.JDOMException,
                                                        LocalConfigException

  Retrieves the owl file of an experiment

  Parameters:
    `expID` - the identifier of the experiment
  Returns:
    the path to the owl file of the requested experiment, or null if the experiment is not cached
  Throws:
    `org.jdom.JDOMException` - errors in the XML syntax of the configuration file
    `LocalConfigException` - errors in the configuration file

### getExperimentSize

    public static java.lang.Long getExperimentSize(java.lang.String expID)
                                            throws java.io.IOException,
                                                   org.jdom.JDOMException,
                                                   LocalConfigException

  Returns the size of an experiment

  Parameters:
    `expID` - the identifier of the requested experiment
  Returns:
    the current size in bytes of the given experiment
  Throws:
    `java.io.IOException` - problems connecting to the ArrayExpress server
    `org.jdom.JDOMException` - errors in the XML syntax of the configuration file
    `LocalConfigException` - errors in the configuration file

### addExperiment

    public static void addExperiment(java.lang.String expID,
                                     java.lang.String originalFilePath,
                                     long length)
                              throws java.io.IOException,
                                     MageParsingException,
                                     org.jdom.JDOMException,
                                     LocalConfigException

  Adds an experiment to the cache

  Parameters:
    `expID` - the identifier of the experiment
    `originalFilePath` - path to the mage-ml file of the experiment
    `length` - size in bytes of the experiment
  Throws:
    `java.io.IOException` - problems copying files into the cache
    `MageParsingException` - problems reading the mage-ml file
    `org.jdom.JDOMException` - errors in the XML syntax of the configuration file
    `LocalConfigException` - errors in the configuration file

### deleteExperiment

    public static void deleteExperiment(java.lang.String expID)
                                 throws org.jdom.JDOMException,
                                        LocalConfigException

  Deletes an experiment from the cache

  Parameters:
    `expID` - the identifier of the experiment
  Throws:
    `org.jdom.JDOMException` - errors in the XML syntax of the configuration file
    `LocalConfigException` - errors in the configuration file

Overview | Package | Class | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD