Class ResultsPruner


  • public final class ResultsPruner
    extends Object
    Manages the deletion of results from the checksum history. It uses the dspace.cfg file as the default configuration file for the deletion settings and can use a different configuration file if it is passed in.
    Author:
    Jim Downing, Grace Carpenter, Nathan Sarr
    • Constructor Detail

      • ResultsPruner

        public ResultsPruner​(Context context)
        Default Constructor
        Parameters:
        context - Context
    • Method Detail

      • getDefaultPruner

        public static ResultsPruner getDefaultPruner​(Context context)
        Factory method for the default results pruner configuration using dspace.cfg
        Parameters:
        context - Context
        Returns:
        a ResultsPruner that represent the default retention policy
      • getPruner

        public static ResultsPruner getPruner​(Context context,
                                              String propsFile)
                                       throws FileNotFoundException
        Factory method for ResultsPruners
        Parameters:
        context - Context
        propsFile - to configure the results pruner.
        Returns:
        the configured results pruner.
        Throws:
        FileNotFoundException - if file doesn't exist it the configuration file cannot be found.
      • addInterested

        public void addInterested​(ChecksumResultCode result,
                                  long duration)
        Add a result and the length of time before the history with this type of result is removed from the database.
        Parameters:
        result - code in the database.
        duration - before bitstreams with the specified result type in the checksum history is removed.
      • addInterested

        public void addInterested​(ChecksumResultCode result,
                                  String duration)
                           throws ParseException
        Add a result and the length of time before it is removed from the checksum history table.
        Parameters:
        result - code in the database.
        duration - before bitstreams with the specified result type in the checksum history is removed.
        Throws:
        ParseException - if the duration cannot be parsed into a long value.
      • getDefaultDuration

        public long getDefaultDuration()
        The default amount of time before a result is removed.
        Returns:
        the default duration.
      • prune

        public int prune()
                  throws SQLException
        Prunes the results retaining results as configured by the interests registered with this object.
        Returns:
        number of results removed.
        Throws:
        SQLException - if database error
      • setDefaultDuration

        public void setDefaultDuration​(long defaultDuration)
        The default duration before records are removed from the checksum history table.
        Parameters:
        defaultDuration - used before records are removed from the checksum history.