org.broadleafcommerce.common.file.service
Interface BroadleafFileService

All Known Implementing Classes:
BroadleafFileServiceImpl

public interface BroadleafFileService

Many components in the Broadleaf Framework can benefit from creating and manipulating temporary files as well as storing and accessing files in a remote repository (such as AmazonS3). This service provides a pluggable way to provide those services.

Author:
bpolster

Method Summary
 void addOrUpdateResource(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)
          Takes in a temporary work area and copies all of the files to the configured FileProvider's permanent storage.
 void addOrUpdateResources(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 checkForResourceOnClassPath(String name)
          Returns true if the resource is available on the classpath.
 void closeWorkArea(FileWorkArea workArea)
          Closes the passed in work area.
 InputStream getClasspathResource(String name)
          Allows assets to be included in the Java classpath.
 File getLocalResource(String fullUrl)
          Checks for a resource in the temporary directory of the file-system.
 File getResource(String name)
          Returns a File representing the passed in name.
 File getResource(String name, FileApplicationType applicationType)
          Returns a File representing the passed in name and application type.
 File getSharedLocalResource(String fullUrl)
          Checks for a resource in the temporary directory of the file-system.
 FileWorkArea initializeWorkArea()
          Create a file work area that can be used for further operations.
 boolean removeResource(String name)
          Removes the resource from the configured FileProvider
 

Method Detail

initializeWorkArea

FileWorkArea initializeWorkArea()
Create a file work area that can be used for further operations.

Returns:

closeWorkArea

void closeWorkArea(FileWorkArea workArea)
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:
Work - Area

getResource

File getResource(String name)
Returns a File representing the passed in name. This method will always access the file via the FileProvider which might be a remote operation as opposed to the getResource(String, FileApplicationType) method which may access a copy of the file that is stored locally.

Parameters:
name - - fully qualified path to the resource
applicationType - - The type of file being accessed
Returns:

getLocalResource

File getLocalResource(String fullUrl)
Checks for a resource in the temporary directory of the file-system. Will check for a site-specific file.

Parameters:
fullUrl -
Returns:

getSharedLocalResource

File getSharedLocalResource(String fullUrl)
Checks for a resource in the temporary directory of the file-system. Will check for a global (e.g. not site specific file).

Parameters:
fullUrl -
Returns:

getResource

File getResource(String name,
                 FileApplicationType applicationType)
Returns a File representing the passed in name and application type. The application type provides an opportunity for the provider to cache the file locally for infrequently change files.

Parameters:
name - - fully qualified path to the resource
applicationType - - The type of file being accessed
Returns:

checkForResourceOnClassPath

boolean checkForResourceOnClassPath(String name)
Returns true if the resource is available on the classpath.

Parameters:
name -
Returns:

getClasspathResource

InputStream getClasspathResource(String name)
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

boolean removeResource(String name)
Removes the resource from the configured FileProvider

Parameters:
name - - fully qualified path to the resource
applicationType - - The type of file being accessed

addOrUpdateResource

void addOrUpdateResource(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 -
fileName -
removeFilesFromWorkArea -

addOrUpdateResources

void addOrUpdateResources(FileWorkArea workArea,
                          boolean removeFilesFromWorkArea)
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

void addOrUpdateResources(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 -
fileNames -
removeFilesFromWorkArea -


Copyright © 2013. All Rights Reserved.