X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=engine%2Fcompbio%2Fengine%2Farchive%2FArchivedJob.java;h=2c2c2ab89616bbb3afc5b6436e354cd1699fce3f;hb=daa7e16fa1815c285bf465b69c8aa1a4ae36c0b9;hp=3f0f7d5f0f5a0a1e799b3db13bf7c2be23433645;hpb=6245c3f3f005e06873f7a6307c76bf518f1422a4;p=proteocache.git diff --git a/engine/compbio/engine/archive/ArchivedJob.java b/engine/compbio/engine/archive/ArchivedJob.java index 3f0f7d5..2c2c2ab 100644 --- a/engine/compbio/engine/archive/ArchivedJob.java +++ b/engine/compbio/engine/archive/ArchivedJob.java @@ -6,38 +6,62 @@ import java.net.MalformedURLException; import java.net.URL; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; +import java.nio.file.Paths; +import java.nio.file.Files; import java.util.List; +import compbio.engine.ProteoCachePropertyHelperManager; +import compbio.util.PropertyHelper; + public class ArchivedJob { String path; + String id; + String jobfilename; int filesize; List files; + private static final PropertyHelper ph = ProteoCachePropertyHelperManager.getPropertyHelper(); - ArchivedJob (String path) { - this.path = path; + public ArchivedJob(String id) { + this.id = id; + jobfilename = id + ".tar.gz"; } - - public boolean getArchiveFromWS() { - return false; - } - - - public boolean getArchiveFromWeb (String webpath) throws IOException, MalformedURLException { + + public boolean copyArchiveFromWeb(String webpath) throws IOException, MalformedURLException { URL website = new URL(webpath); ReadableByteChannel rbc = Channels.newChannel(website.openStream()); FileOutputStream fos = new FileOutputStream(path); fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + return true; + } + + public String prepareJobArchiveToWeb() throws IOException { + String resultpath = ph.getProperty("archive.web.dir"); + String thefile = ph.getProperty("archive.path") + '/' + jobfilename; + String finalpath = ProteoCachePropertyHelperManager.getLocalPath() + resultpath + '/' + jobfilename; + if (Files.isReadable(Paths.get(thefile))) { + Files.copy(Paths.get(thefile), Paths.get(finalpath)); + return resultpath + '/' + jobfilename; + } + return null; + } + + public boolean copyArchiveLocaly(String localpath) throws IOException { + Files.copy(Paths.get(localpath), Paths.get(path)); return true; } - - + + public void setArchivePath(String path) { + this.path = path; + } + public int getSize() { return filesize; } - + public List unpack() { if (null != files) { - + } return files; }