Package net.solarnetwork.service
Interface ResourceStorageService
- All Superinterfaces:
Identifiable
Service API for a repository of resources, much like a very simple virtual
file system.
- Since:
- 1.54
- Version:
- 1.0
- Author:
- matt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringAn event topic for when a resource has been saved successfully by aResourceStorageService.static final StringAn event topic for when a set of resources have been deleted successfully by aResourceStorageService.static final StringProperty name for anIterableof string path values.static final StringProperty name for a string URL value.Fields inherited from interface net.solarnetwork.service.Identifiable
GROUP_UID_PROPERTY, UID_PROPERTY -
Method Summary
Modifier and TypeMethodDescriptiondeleteResources(Iterable<String> paths) Asynchronously delete a set of resources.booleanTest if the service is configured and ready for use.CompletableFuture<Iterable<org.springframework.core.io.Resource>>listResources(String pathPrefix) Asynchronously get a set of resources.resourceStorageUrl(String path) Resolve a path as a URL to a resource in the storage service.saveResource(String path, org.springframework.core.io.Resource resource, boolean replace, ProgressListener<org.springframework.core.io.Resource> progressListener) Asynchronously save a resource.Methods inherited from interface net.solarnetwork.service.Identifiable
getDisplayName, getGroupUid, getUid
-
Field Details
-
EVENT_TOPIC_RESOURCE_SAVED
An event topic for when a resource has been saved successfully by aResourceStorageService.The standard properties of the event shall be:
Identifiable.UID_PROPERTY- The UID of the
ResourceStorageServicethat saved the resource, if available. Identifiable.GROUP_UID_PROPERTY- The group UID of the
ResourceStorageServicethat saved the resource, if available. RESOURCE_URL_PROPERTY- The URL of the resource that was saved.
RESOURCE_PATHS_PROPERTY- The path of the resource that was saved (as a singleton collection).
- See Also:
-
EVENT_TOPIC_RESOURCES_DELETED
An event topic for when a set of resources have been deleted successfully by aResourceStorageService.The standard properties of the event shall be:
Identifiable.UID_PROPERTY- The UID of the
ResourceStorageServicethat deleted the resource, if available. Identifiable.GROUP_UID_PROPERTY- The group UID of the
ResourceStorageServicethat deleted the resource, if available. RESOURCE_PATHS_PROPERTY- The paths of the resources that were deleted.
- See Also:
-
RESOURCE_URL_PROPERTY
Property name for a string URL value.- See Also:
-
RESOURCE_PATHS_PROPERTY
Property name for anIterableof string path values.- See Also:
-
-
Method Details
-
isConfigured
boolean isConfigured()Test if the service is configured and ready for use.A service might not be available for use even if registered at runtime. For example a remote storage service might require credentials to be configured before it can be used.
- Returns:
- true if the service is configured and ready for use
-
listResources
Asynchronously get a set of resources.- Parameters:
pathPrefix- an optional prefix to limit the listed resources to, or null for all available resources- Returns:
- a future that returns the list of matching resources
-
resourceStorageUrl
Resolve a path as a URL to a resource in the storage service.- Parameters:
path- the path- Returns:
- the resource storage URL, or null if a URL cannot be determined or is not supported
-
saveResource
CompletableFuture<Boolean> saveResource(String path, org.springframework.core.io.Resource resource, boolean replace, ProgressListener<org.springframework.core.io.Resource> progressListener) Asynchronously save a resource.- Parameters:
path- the unique path to save the resource toresource- the resource to savereplace- true to replace, false to skip if resource already exists atpathprogressListener- an optional progress listener- Returns:
- a future that returns true if the resource was saved,
or false if
replacewas false and a resource already existed atpath
-
deleteResources
Asynchronously delete a set of resources.- Parameters:
paths- the unique paths of the resources to delete- Returns:
- a future that returns the set of
pathvalues that were not deleted, or an empty set if resources for allpathswere deleted
-