Class FileDAO

java.lang.Object
com.compomics.software.autoupdater.FileDAO
Direct Known Subclasses:
GUIFileDAO, HeadlessFileDAO

public abstract class FileDAO
extends Object
FileDAO file access.
Author:
Davy Maddelein, Harald Barsnes
  • Constructor Details

  • Method Details

    • createDesktopShortcut

      public abstract boolean createDesktopShortcut​(MavenJarFile file, String iconName, String toolName, boolean deleteOldShortcut) throws IOException
      Creates a new Desktop Shortcut to the Maven jar file, atm windows only.
      Parameters:
      file - the Maven jarfile to make a shortcut to
      iconName - the name of the icon file in the resources folder
      toolName - the name of the tool, e.g., PeptideShaker
      deleteOldShortcut - if previous shortcuts containing the Maven jar file artifact id should be removed
      Returns:
      true id the shortcut was created (?)
      Throws:
      IOException - if an IOException occurs
    • addShortcutAtDeskTop

      public boolean addShortcutAtDeskTop​(MavenJarFile mavenJarFile)
      Add desktop shortcut.
      Parameters:
      mavenJarFile - the Maven jar file
      Returns:
      true id the shortcut was created (?)
    • addShortcutAtDeskTop

      public boolean addShortcutAtDeskTop​(MavenJarFile mavenJarFile, String iconName) throws NullPointerException, RuntimeException
      Adds a shortcut to the desktop. At the moment for Windows only.
      Parameters:
      mavenJarFile - the MavenJarFile to create the shortcut for
      iconName - the name of the icon in the resource folder of the MavenJarFile to link to
      Returns:
      true if the shortcut was created otherwise false
      Throws:
      NullPointerException - if a NullPointerException occurs
      RuntimeException - if a RuntimeException occurs
    • getLocationToDownloadOnDisk

      public abstract File getLocationToDownloadOnDisk​(String targetDownloadFolder) throws IOException
      Try to find an at least somewhat sane location to download files to.
      Parameters:
      targetDownloadFolder - first place to check if it is a possible download location
      Returns:
      the folder to download in (in best case scenario this is the passed parameter targetDownloadFolder)
      Throws:
      IOException - if an IOException occurs
    • unzipFile

      public boolean unzipFile​(ZipFile zip, File fileLocationOnDiskToDownloadTo) throws IOException
      Unzips a zip archive.
      Parameters:
      zip - the zipfile to unzip
      fileLocationOnDiskToDownloadTo - the folder to unzip in
      Returns:
      true if successful
      Throws:
      IOException - if an IOException occurs
    • unGzipAndUntarFile

      public boolean unGzipAndUntarFile​(GZIPInputStream in, File fileLocationOnDiskToDownloadTo, WaitingHandler waitingHandler) throws IOException
      Untars and ungzips a .tar.gz file.
      Parameters:
      in - a GZIPInputStream of the file that needs to be ungzipped and untarred
      fileLocationOnDiskToDownloadTo - the file to ungzip and untar to
      waitingHandler - the waiting handler
      Returns:
      true if successful
      Throws:
      IOException - if an IOException occurs
    • getMavenJarFileFromFolderWithArtifactId

      public MavenJarFile getMavenJarFileFromFolderWithArtifactId​(File folder, String artifactId) throws IOException
      Fetches a Maven built jar file from a folder for the given artifact id (e.g peptideshaker or ms-lims).
      Parameters:
      folder - the folder to look in
      artifactId - the artifactid in the properties of the (@code MavenJarFile) in the folder
      Returns:
      the last found MavenJarFile with the given artifactid, can be null
      Throws:
      IOException - if an IOException occurs
    • writeStreamToDisk

      public File writeStreamToDisk​(InputStream in, String name, File outputLocationFolder) throws FileNotFoundException, IOException
      Writes a stream to disk.
      Parameters:
      in - the stream to write to disk
      name - the name the file that will be created
      outputLocationFolder - the location to write to
      Returns:
      the written file
      Throws:
      FileNotFoundException - if a FileNotFoundException occurs
      IOException - if an IOException occurs