Interface BroadleafFileService
- All Known Implementing Classes:
BroadleafFileServiceImpl
This service provides a pluggable way to provide those services.
- Author:
- bpolster
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addOrUpdateResource
(FileWorkArea workArea, File file, boolean removeFilesFromWorkArea) Deprecated.addOrUpdateResourceForPath
(FileWorkArea workArea, File file, boolean removeFilesFromWorkArea) Takes in a temporary work area and a single File and copies that files to the configured FileProvider's permanent storage.void
addOrUpdateResources
(FileWorkArea workArea, boolean removeFilesFromWorkArea) Deprecated.void
addOrUpdateResources
(FileWorkArea workArea, List<File> files, boolean removeFilesFromWorkArea) Deprecated.addOrUpdateResourcesForPaths
(FileWorkArea workArea, boolean removeFilesFromWorkArea) Takes in a temporary work area and copies all of the files to the configured FileProvider's permanent storage.addOrUpdateResourcesForPaths
(FileWorkArea workArea, List<File> files, boolean removeFilesFromWorkArea) Takes in a temporary work area and a list of Files and copies them to the configured FileProvider's permanent storage.boolean
Returns true if the resource is available on the classpath.void
closeWorkArea
(FileWorkArea workArea) Closes the passed in work area.getClasspathResource
(String name) Allows assets to be included in the Java classpath.getLocalResource
(String fullUrl) Checks for a resource in the temporary directory of the file-system.getResource
(String name) Returns a File representing the passed in name.getResource
(String name, Long timeout) Returns a File representing the resource.getSharedLocalResource
(String fullUrl) Checks for a resource in the temporary directory of the file-system.Create a file work area that can be used for further operations.boolean
removeResource
(String name) Removes the resource from the configured FileProvider
-
Method Details
-
initializeWorkArea
FileWorkArea initializeWorkArea()Create a file work area that can be used for further operations.- Returns:
-
closeWorkArea
Closes the passed in work area. This method will delete all items contained in the work area. Future calls using this WorkArea will cause a RuntimeError- Parameters:
workArea
- Area
-
getResource
Returns a File representing the passed in name. This method will always access the file via the FileProvider which might be a remote operation.- Parameters:
name
- - fully qualified path to the resource- Returns:
-
getResource
Returns a File representing the resource. This method first checks the local temporary directory for the file. If it exists and has been modified within the timeout parameter, it will be returned. Otherwise, this method will make a call togetResource(String)
.If the timeout parameter is null then if the resource exists locally, it will be returned.
- Parameters:
name
- - fully qualified path to the resourcetimeout
- - timeframe that the temporary file is considered valid- Returns:
-
getLocalResource
Checks for a resource in the temporary directory of the file-system. Will check for a site-specific file.- Parameters:
fullUrl
-- Returns:
-
checkForResourceOnClassPath
Returns true if the resource is available on the classpath.- Parameters:
name
-- Returns:
-
getClasspathResource
Allows assets to be included in the Java classpath.This method was designed to support an internal Broadleaf use case and may not have general applicability beyond that. For Broadleaf demo sites, many of the product images are shared across the demo sites.
Rather than copy those images, they are stored in a Jar file and shared by all of the sites.
- Parameters:
name
- - fully qualified path to the resource- Returns:
-
removeResource
Removes the resource from the configured FileProvider- Parameters:
name
- - fully qualified path to the resource
-
addOrUpdateResource
@Deprecated void addOrUpdateResource(FileWorkArea workArea, File file, boolean removeFilesFromWorkArea) Deprecated.Takes in a temporary work area and a single File and copies that files to the configured FileProvider's permanent storage.
Passing in removeFilesFromWorkArea to true allows for more efficient file processing when using a local file system as it performs a move operation instead of a copy.
- Parameters:
workArea
-file
-removeFilesFromWorkArea
-
-
addOrUpdateResourceForPath
String addOrUpdateResourceForPath(FileWorkArea workArea, File file, boolean removeFilesFromWorkArea) Takes in a temporary work area and a single File and copies that files to the configured FileProvider's permanent storage.
Passing in removeFilesFromWorkArea to true allows for more efficient file processing when using a local file system as it performs a move operation instead of a copy.
- Parameters:
workArea
- the work area from the given filefile
- the file to uploadremoveFilesFromWorkArea
- whether or not the given file should be removed from workArea when it has been copied
-
addOrUpdateResources
Deprecated.Takes in a temporary work area and copies all of the files to the configured FileProvider's permanent storage.
Passing in removeFilesFromWorkArea to true allows for more efficient file processing when using a local file system as it performs a move operation instead of a copy.
- Parameters:
workArea
-removeFilesFromWorkArea
-
-
addOrUpdateResourcesForPaths
Takes in a temporary work area and copies all of the files to the configured FileProvider's permanent storage.
Passing in removeFilesFromWorkArea to true allows for more efficient file processing when using a local file system as it performs a move operation instead of a copy.
- Parameters:
workArea
-removeFilesFromWorkArea
-
-
addOrUpdateResources
@Deprecated void addOrUpdateResources(FileWorkArea workArea, List<File> files, boolean removeFilesFromWorkArea) Deprecated.Takes in a temporary work area and a list of Files and copies them to the configured FileProvider's permanent storage.
Passing in removeFilesFromWorkArea to true allows for more efficient file processing when using a local file system as it performs a move operation instead of a copy.
- Parameters:
workArea
-files
-removeFilesFromWorkArea
-
-
addOrUpdateResourcesForPaths
List<String> addOrUpdateResourcesForPaths(FileWorkArea workArea, List<File> files, boolean removeFilesFromWorkArea) Takes in a temporary work area and a list of Files and copies them to the configured FileProvider's permanent storage.
Passing in removeFilesFromWorkArea to true allows for more efficient file processing when using a local file system as it performs a move operation instead of a copy.
- Parameters:
workArea
- the work area for the given filesfiles
- the files to copy to the provider's permanent storageremoveFilesFromWorkArea
- whether or not the given files hsould be removed from the given workArea after they are uploaded
-
addOrUpdateResourceForPath(FileWorkArea, File, boolean)