Sweeper
Date: 2017-06-10

org.gcube.informationsystem.collector.impl.xmlstorage.exist.sweep

## Class Sweeper

- java.lang.Object
- - org.gcube.informationsystem.collector.impl.xmlstorage.exist.sweep.Sweeper

- All Implemented Interfaces:
    java.lang.Runnable

      public class Sweeper
      extends java.lang.Object
      implements java.lang.Runnable

  This class provides some cleanup procedures to use to maintain a consistent content in the XML storage. One of them is a thread, activated at RI startup time, that periodically drops the out to date resources from the storage
  Author:
    Manuele Simi (ISTI-CNR)

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Sweeper(long delay, long resourceExpirationTime)` Initializes a new Sweeper

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cleanDeletedResourcesList()` Deletes the expired resources from the list of deleted resources as notified by the AF
    `void` | `cleanExpiredResources()` Deletes from the backend storage the expired resources
    `static void` | `cleanResourceForRI(java.lang.String id)` Removes all the properties documents related to the given Running Instance ID
    `static void` | `cleanRPs()` Deletes the Properties collection from the storage
    `void` | `run()`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Sweeper

          public Sweeper(long delay,
                 long resourceExpirationTime)
                  throws java.lang.Exception

      Initializes a new Sweeper
      Parameters:
        `delay` - the sweeper delay
        `resourceExpirationTime` - the time after that a resource is classified as exipired
      Throws:
        `java.lang.Exception` - if the eXist connection fails

  - ### Method Detail

    - #### run

          public void run()

      Specified by:
        `run` in interface `java.lang.Runnable`

    - #### cleanExpiredResources

          public void cleanExpiredResources()

      Deletes from the backend storage the expired resources

    - #### cleanResourceForRI

          public static void cleanResourceForRI(java.lang.String id)

      Removes all the properties documents related to the given Running Instance ID
      Parameters:
        `id` - the ID of the Running Instance whose properties documents have to be removed

    - #### cleanRPs

          public static void cleanRPs()
                               throws XMLStorage.XMLStorageNotAvailableException

      Deletes the Properties collection from the storage
      Throws:
        `XMLStorage.XMLStorageNotAvailableException`

    - #### cleanDeletedResourcesList

          public void cleanDeletedResourcesList()

      Deletes the expired resources from the list of deleted resources as notified by the AF