Class FileDAO
java.lang.Object
com.compomics.software.autoupdater.FileDAO
- Direct Known Subclasses:
GUIFileDAO,HeadlessFileDAO
FileDAO file access.
- Author:
- Davy Maddelein, Harald Barsnes
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddShortcutAtDeskTop(MavenJarFile mavenJarFile) Add desktop shortcut.booleanaddShortcutAtDeskTop(MavenJarFile mavenJarFile, String iconName) Adds a shortcut to the desktop.abstract booleancreateDesktopShortcut(MavenJarFile file, String iconName, String toolName, boolean deleteOldShortcut) Creates a new Desktop Shortcut to the Maven jar file, atm windows only.abstract FilegetLocationToDownloadOnDisk(String targetDownloadFolder) Try to find an at least somewhat sane location to download files to.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).booleanunGzipAndUntarFile(GZIPInputStream in, File fileLocationOnDiskToDownloadTo, WaitingHandler waitingHandler) Untars and ungzips a .tar.gz file.booleanUnzips a zip archive.writeStreamToDisk(InputStream in, String name, File outputLocationFolder) Writes a stream to disk.
-
Constructor Details
-
FileDAO
public FileDAO()
-
-
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 toiconName- the name of the icon file in the resources foldertoolName- the name of the tool, e.g., PeptideShakerdeleteOldShortcut- 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
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- theMavenJarFileto create the shortcut foriconName- the name of the icon in the resource folder of theMavenJarFileto link to- Returns:
- true if the shortcut was created otherwise false
- Throws:
NullPointerException- if a NullPointerException occursRuntimeException- if a RuntimeException occurs
-
getLocationToDownloadOnDisk
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
Unzips a zip archive.- Parameters:
zip- the zipfile to unzipfileLocationOnDiskToDownloadTo- 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- aGZIPInputStreamof the file that needs to be ungzipped and untarredfileLocationOnDiskToDownloadTo- the file to ungzip and untar towaitingHandler- 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 inartifactId- the artifactid in the properties of the (@code MavenJarFile) in the folder- Returns:
- the last found
MavenJarFilewith 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 diskname- the name the file that will be createdoutputLocationFolder- the location to write to- Returns:
- the written file
- Throws:
FileNotFoundException- if a FileNotFoundException occursIOException- if an IOException occurs
-