com.compomics.software.autoupdater
Class FileDAO

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

public abstract class FileDAO
extends Object

FileDAO file access.

Author:
Davy Maddelein

Constructor Summary
FileDAO()
           
 
Method Summary
 boolean addShortcutAtDeskTop(MavenJarFile mavenJarFile)
          Add desktop shortcut.
 boolean addShortcutAtDeskTop(MavenJarFile mavenJarFile, String iconName)
          Adds a shortcut to the desktop.
abstract  boolean createDesktopShortcut(MavenJarFile file, String iconName, boolean deleteOldShortcut)
          Creates a new Desktop Shortcut to the maven jar file, atm windows only.
abstract  File getLocationToDownloadOnDisk(String targetDownloadFolder)
          Try to find an at least somewhat sane location to download files to.
 MavenJarFile getMavenJarFileFromFolderWithArtifactId(File folder, String artifactId)
          Fetches a maven built jar file from a folder for the given artifact id (e.g peptideshaker or ms-lims).
 boolean unGzipAndUntarFile(GZIPInputStream in, File fileLocationOnDiskToDownloadTo)
          Untars and ungzips a .tar.gz file.
 boolean unzipFile(ZipFile zip, File fileLocationOnDiskToDownloadTo)
          Unzips a zip archive.
 File writeStreamToDisk(InputStream in, String name, File outputLocationFolder)
          Writes a stream to disk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileDAO

public FileDAO()
Method Detail

createDesktopShortcut

public abstract boolean createDesktopShortcut(MavenJarFile file,
                                              String iconName,
                                              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
deleteOldShortcut - if previous shortcuts containing the maven jar file artifact id should be removed
Returns:
true id the shortcut was created (?)
Throws:
IOException

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
RuntimeException

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

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

unGzipAndUntarFile

public boolean unGzipAndUntarFile(GZIPInputStream in,
                                  File fileLocationOnDiskToDownloadTo)
                           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 folder to ungzip and untar in
Returns:
true if successful
Throws:
IOException

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

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
IOException


Copyright © 2013. All Rights Reserved.