Class FilesystemSupplementedRepositoryImpl.RelativePathTranslatorListener

  • Enclosing class:
    FilesystemSupplementedRepositoryImpl<Type extends VersionedFileFields<java.lang.Long> & IridaThing>

    public static class FilesystemSupplementedRepositoryImpl.RelativePathTranslatorListener
    extends java.lang.Object
    A JPA event listener to translate the relative paths stored in the database to absolute paths so that everyone after the repository knows where the file is actually stored.
    • Constructor Detail

      • RelativePathTranslatorListener

        public RelativePathTranslatorListener()
    • Method Detail

      • addBaseDirectory

        public static void addBaseDirectory​(java.lang.Class<?> c,
                                            java.nio.file.Path p)
        Add a base directory to safe files to
        Parameters:
        c - The class for the base directory to save files
        p - the path to save files to
      • absolutePath

        public void absolutePath​(VersionedFileFields<java.lang.Long> fileSystemEntity)
        Whenever a VersionedFileFields is loaded from the database, we need to translate it's path from a relative path to an absolute path based on the storage directory for the type.
        Parameters:
        fileSystemEntity - the object to make absolute paths for
      • relativePath

        public void relativePath​(VersionedFileFields<java.lang.Long> fileSystemEntity)
        Before persisting a VersionedFileFields to the database, we need to translate it to a relative path by stripping the storage directory for the type.
        Parameters:
        fileSystemEntity - the object to make relative paths for.