Package net.solarnetwork.node.backup
Class ResourceBackupResource
java.lang.Object
net.solarnetwork.node.backup.ResourceBackupResource
- All Implemented Interfaces:
BackupResource
BackupResource implementation using a Spring Resource.- Version:
- 1.2
- Author:
- matt
-
Constructor Summary
ConstructorsConstructorDescriptionResourceBackupResource(org.springframework.core.io.Resource resource, String backupPath) Constructor.ResourceBackupResource(org.springframework.core.io.Resource resource, String backupPath, String providerKey) Construct with a specific provider key.ResourceBackupResource(org.springframework.core.io.Resource resource, String backupPath, String providerKey, String sha256Digest) Construct with a specific provider key. -
Method Summary
Modifier and TypeMethodDescriptionGet a relative path to save this resource to in the backup.Get anInputStreamto the resource.longGet the modification date of the resource, in milliseconds since the epoch.Get the key of theBackupResourceProviderthat provided this resource.Get the expected SHA-256 digest of the resource content.
-
Constructor Details
-
ResourceBackupResource
Constructor. TheproviderKeywill be set tonet.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
Description copied from interface:BackupResourceGet the key of theBackupResourceProviderthat provided this resource.- Specified by:
getProviderKeyin interfaceBackupResource- Returns:
- The provider key.
-
getBackupPath
Description copied from interface:BackupResourceGet 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:
getBackupPathin interfaceBackupResource- Returns:
- the relative path
-
getInputStream
Description copied from interface:BackupResourceGet anInputStreamto the resource.- Specified by:
getInputStreamin interfaceBackupResource- Returns:
- an InputStream to the data for the resource
- Throws:
IOException- if any IO error occurs
-
getModificationDate
public long getModificationDate()Description copied from interface:BackupResourceGet the modification date of the resource, in milliseconds since the epoch.- Specified by:
getModificationDatein interfaceBackupResource- Returns:
- the modification date, or -1 if not known
-
getSha256Digest
Description copied from interface:BackupResourceGet 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:
getSha256Digestin interfaceBackupResource- Returns:
- the SHA-256 digest as a hex-encoded string, or null if not known
-