Class ResourceBackupResource

java.lang.Object
net.solarnetwork.node.backup.ResourceBackupResource
All Implemented Interfaces:
BackupResource

public class ResourceBackupResource extends Object implements BackupResource
BackupResource implementation using a Spring Resource.
Version:
1.2
Author:
matt
  • Constructor Details

    • ResourceBackupResource

      public ResourceBackupResource(org.springframework.core.io.Resource resource, String backupPath)
      Constructor. The providerKey will be set to net.solarnetwork.node.backup.FileBackupResourceProvider.
      Parameters:
      resource - The resource.
      backupPath - The backup path.
    • ResourceBackupResource

      public ResourceBackupResource(org.springframework.core.io.Resource resource, String backupPath, String providerKey)
      Construct with a specific provider key.
      Parameters:
      resource - The resource.
      backupPath - The backup path.
      providerKey - The provider key.
      Since:
      1.1
    • ResourceBackupResource

      public ResourceBackupResource(org.springframework.core.io.Resource resource, String backupPath, String providerKey, String sha256Digest)
      Construct with a specific provider key.
      Parameters:
      resource - The resource.
      backupPath - The backup path.
      providerKey - The provider key.
      sha256Digest - The SHA-256 digest, hex encoded
      Since:
      1.2
  • Method Details

    • getProviderKey

      public String getProviderKey()
      Description copied from interface: BackupResource
      Get the key of the BackupResourceProvider that provided this resource.
      Specified by:
      getProviderKey in interface BackupResource
      Returns:
      The provider key.
    • getBackupPath

      public String getBackupPath()
      Description copied from interface: BackupResource
      Get a relative path to save this resource to in the backup.

      This must be a URL-like path, using a forward slash to represent directories. For example, the a path could be some/path/here.txt.

      Specified by:
      getBackupPath in interface BackupResource
      Returns:
      the relative path
    • getInputStream

      public InputStream getInputStream() throws IOException
      Description copied from interface: BackupResource
      Get an InputStream to the resource.
      Specified by:
      getInputStream in interface BackupResource
      Returns:
      an InputStream to the data for the resource
      Throws:
      IOException - if any IO error occurs
    • getModificationDate

      public long getModificationDate()
      Description copied from interface: BackupResource
      Get the modification date of the resource, in milliseconds since the epoch.
      Specified by:
      getModificationDate in interface BackupResource
      Returns:
      the modification date, or -1 if not known
    • getSha256Digest

      public String getSha256Digest()
      Description copied from interface: BackupResource
      Get the expected SHA-256 digest of the resource content.

      This value is meant to be used to verify the integrity of the content of the resource when read from BackupResource.getInputStream().

      Specified by:
      getSha256Digest in interface BackupResource
      Returns:
      the SHA-256 digest as a hex-encoded string, or null if not known