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 Details

    • 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:
      workArea - 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.
      Parameters:
      name - - fully qualified path to the resource
      Returns:
    • getResource

      File getResource(String name, Long timeout)
      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 to getResource(String).

      If the timeout parameter is null then if the resource exists locally, it will be returned.

      Parameters:
      name - - fully qualified path to the resource
      timeout - - timeframe that the temporary file is considered valid
      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:
    • 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
    • addOrUpdateResource

      @Deprecated 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 -
      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 file
      file - the file to upload
      removeFilesFromWorkArea - whether or not the given file should be removed from workArea when it has been copied
    • addOrUpdateResources

      @Deprecated 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 -
    • addOrUpdateResourcesForPaths

      List<String> addOrUpdateResourcesForPaths(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

      @Deprecated 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 -
      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 files
      files - the files to copy to the provider's permanent storage
      removeFilesFromWorkArea - whether or not the given files hsould be removed from the given workArea after they are uploaded