Interface DataStore

    • Method Detail

      • getRecordIfStored

        DataRecord getRecordIfStored​(DataIdentifier identifier)
                              throws DataStoreException
        Check if a record for the given identifier exists, and return it if yes. If no record exists, this method returns null.
        Parameters:
        identifier - data identifier
        Returns:
        the record if found, and null if not
        Throws:
        DataStoreException - if the data store could not be accessed
      • getRecord

        DataRecord getRecord​(DataIdentifier identifier)
                      throws DataStoreException
        Returns the identified data record. The given identifier should be the identifier of a previously saved data record. Since records are never removed, there should never be cases where the identified record is not found. Abnormal cases like that are treated as errors and handled by throwing an exception.
        Parameters:
        identifier - data identifier
        Returns:
        identified data record
        Throws:
        DataStoreException - if the data store could not be accessed, or if the given identifier is invalid
      • getRecordFromReference

        DataRecord getRecordFromReference​(java.lang.String reference)
                                   throws DataStoreException
        Returns the record that matches the given binary reference. Returns null if the reference is invalid, for example if it points to a record that does not exist.
        Parameters:
        reference - binary reference
        Returns:
        matching record, or null
        Throws:
        DataStoreException - if the data store could not be accessed
      • addRecord

        DataRecord addRecord​(java.io.InputStream stream)
                      throws DataStoreException
        Creates a new data record. The given binary stream is consumed and a binary record containing the consumed stream is created and returned. If the same stream already exists in another record, then that record is returned instead of creating a new one.

        The given stream is consumed and not closed by this method. It is the responsibility of the caller to close the stream. A typical call pattern would be:

             InputStream stream = ...;
             try {
                 record = store.addRecord(stream);
             } finally {
                 stream.close();
             }
         
        Parameters:
        stream - binary stream
        Returns:
        data record that contains the given stream
        Throws:
        DataStoreException - if the data store could not be accessed
      • updateModifiedDateOnAccess

        void updateModifiedDateOnAccess​(long before)
        From now on, update the modified date of an object even when accessing it. Usually, the modified date is only updated when creating a new object, or when a new link is added to an existing object. When this setting is enabled, even getLength() will update the modified date.
        Parameters:
        before - - update the modified date to the current time if it is older than this value
      • deleteAllOlderThan

        int deleteAllOlderThan​(long min)
                        throws DataStoreException
        Delete objects that have a modified date older than the specified date.
        Parameters:
        min - the minimum time
        Returns:
        the number of data records deleted
        Throws:
        DataStoreException
      • getMinRecordLength

        int getMinRecordLength()
        Get the minimum size of an object that should be stored in this data store. Depending on the overhead and configuration, each store may return a different value.
        Returns:
        the minimum size in bytes
      • clearInUse

        void clearInUse()
        Clear the in-use list. This is only used for testing to make the the garbage collection think that objects are no longer in use.