Class DnDRepository

java.lang.Object
com.levigo.jadice.web.demo.common.server.dnd.DnDRepository

public class DnDRepository extends Object
A implementation to store drag an drop request data in temporary files. The files default directory is $user.home/.jwt-dnd/. By default after two hours of not accessing a file it will be deleted. The create files got the name '$uuid.dat'.
  • Method Details

    • getInstance

      public static DnDRepository getInstance()
    • getFile

      public InputStream getFile(String uuid) throws FileNotFoundException
      Searches for the file within the defaultDirectory and if found return an InputStream of the file.
      Parameters:
      uuid - The uuid of the file
      Returns:
      An InputStream of the file or null if no file was found.
      Throws:
      FileNotFoundException - Should not happen except permissions are missing
    • saveFile

      public void saveFile(String resource, String uuid) throws IOException
      Save the given resource in the defaultDirectory dictionary with a filename matching the uuid.
      Parameters:
      resource - The resource to be saved
      uuid - The uuid which represents the filename
      Throws:
      IOException - If the file couldn't be created
    • saveFile

      public void saveFile(InputStream inputStream, String uuid) throws IOException
      Save the given resource in the defaultDirectory dictionary with a filename matching the uuid.
      Parameters:
      inputStream - The inputStream to be saved
      uuid - The uuid which represents the filename
      Throws:
      IOException - If the file couldn't be created
    • getDefaultDirectory

      public String getDefaultDirectory()
    • setDefaultDirectory

      public void setDefaultDirectory(String defaultDirectory)
    • getLifeTime

      public Duration getLifeTime()
    • setLifeTime

      public void setLifeTime(Duration lifeTime)
    • getInitialLifeTime

      public Duration getInitialLifeTime()
    • setInitialLifeTime

      public void setInitialLifeTime(Duration initialLifeTime)