Interface ISupportsCustomFileAttributes<F>

Type Parameters:
F - The type of the file used by the implementation. See also IBasicFileSystem.
All Known Implementing Classes:
AmazonS3FileSystem, LocalFileSystem

public interface ISupportsCustomFileAttributes<F>
An interface indicating that a filesystem supports adding custom (user-defined) file attributes. Attributes are always set as key-value pairs. The values are always strings.

A IBasicFileSystem that implements this interface should return any user-defined metadata attributes in the method IBasicFileSystem.getAdditionalFileProperties(Object).

  • Field Details

    • FILE_ATTRIBUTE_PARAM_PREFIX

      static final String FILE_ATTRIBUTE_PARAM_PREFIX
      Prefix for parameter-names, for parameters that should be set as custom metadata attributes. The prefix will not be part of the actual metadata attribute name set on the file, it is only used for filtering parameters to use for the custom metadata and stripped from the name when applying the attributes to the file.
      See Also:
  • Method Details

    • hasCustomFileAttributes

      default boolean hasCustomFileAttributes(@Nullable ParameterList pvl)
      Method to be used in configure.
      Parameters:
      pvl - the ParameterValueList, may be null.
      Returns:
      true when at least one Parameter name starts with "FileAttribute."<F>.
    • getCustomFileAttributes

      default Map<String,String> getCustomFileAttributes(@Nonnull ParameterValueList pvl)
      Gets the custom attributes from the ParameterValueList. The parameter value list is filtered on parameter names with the prefix FILE_ATTRIBUTE_PARAM_PREFIX ("FileAttribute."<F>).

      For each parameter-value, if the parameter-name starts with the prefix "FileAttribute."<F> the prefix is stripped from the name to get the attribute-name and the string-value of the parameter is used to get the attribute-value.

      This is an interface default method that most implementations should not need to override.

      Parameters:
      pvl - ParameterValueList containing inputs to apply as user-defined file metadata
      Returns:
      a Map with the custom file attributes
    • createFile

      void createFile(F file, InputStream contents, Map<String,String> customFileAttributes) throws FileSystemException, IOException
      Creates a file with the given custom file attributes.
      Parameters:
      file -
      contents -
      customFileAttributes -
      Throws:
      FileSystemException
      IOException
    • moveFile

      F moveFile(F f, String destinationFolder, boolean createFolder, Map<String,String> customFileAttributes) throws FileSystemException
      Moves the file to another folder, adding the given custom file attributes to the file in the destination folder. Does not need to check for existence of the source or non-existence of the destination. Returns the moved file, or null if no file was moved or there is no reference to the moved file.
      Throws:
      FileSystemException
    • copyFile

      F copyFile(F f, String destinationFolder, boolean createFolder, Map<String,String> customFileAttributes) throws FileSystemException
      Copies the file to another folder, adding the given custom file attributes to the file in the destination folder. Does not need to check for existence of the source or non-existence of the destination. Returns the copied file, or null if no file was copied or there is no reference to the copied file.
      Throws:
      FileSystemException
    • renameFile

      F renameFile(F source, F destination, Map<String,String> customFileAttributes) throws FileSystemException
      Renames the file to a new name, possibly in another folder. Does not need to check for the existence of the source or non-existence of the destination.
      Throws:
      FileSystemException
    • getCustomFileAttribute

      @Nullable String getCustomFileAttribute(@Nonnull F file, @Nonnull String name) throws FileSystemException
      Gets the value of the given custom file attribute on the given file. If the attribute does not exist, null is returned.
      Parameters:
      file - File object for which to get the extended attribute. Must not be null.
      name - Name of the extended attribute to get. Must not be null.
      Returns:
      Value of the extended attribute or null if the attribute does not exist.
      Throws:
      FileSystemException