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 Summary
Constructors Constructor Description FileDAO()
-
Method Summary
Modifier and Type Method Description 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, String toolName, 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, WaitingHandler waitingHandler)
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.
-
Constructor Details
-
FileDAO
public FileDAO()
-
-
Method Details
-
createDesktopShortcut
public abstract boolean createDesktopShortcut(MavenJarFile file, String iconName, String toolName, boolean deleteOldShortcut) throws IOExceptionCreates 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, RuntimeExceptionAdds a shortcut to the desktop. At the moment for Windows only.- Parameters:
mavenJarFile
- theMavenJarFile
to create the shortcut foriconName
- the name of the icon in the resource folder of theMavenJarFile
to 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 IOExceptionUntars and ungzips a .tar.gz file.- Parameters:
in
- aGZIPInputStream
of 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 IOExceptionFetches 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
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, IOExceptionWrites 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
-