X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=engine%2Fcompbio%2Fengine%2Farchive%2FArchivedJob.java;fp=engine%2Fcompbio%2Fengine%2Farchive%2FArchivedJob.java;h=a07d77dc6b7ca6e7b83185289bbc3ae984edd0ba;hb=9bb6ee99ca7f738fac1087190b5481b8fe6e8d9f;hp=94433de910817f70a7e10d6dc1cd00ed3a7e819d;hpb=2e3f6b76be585306f1003d849831840c0adb3360;p=proteocache.git diff --git a/engine/compbio/engine/archive/ArchivedJob.java b/engine/compbio/engine/archive/ArchivedJob.java index 94433de..a07d77d 100644 --- a/engine/compbio/engine/archive/ArchivedJob.java +++ b/engine/compbio/engine/archive/ArchivedJob.java @@ -10,14 +10,20 @@ 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(); public ArchivedJob(String id) { this.id = id; + jobfilename = id + ".tar.gz"; } public boolean copyArchiveFromWeb(String webpath) throws IOException, MalformedURLException { @@ -25,9 +31,24 @@ public class ArchivedJob { 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(finalpath))) { + Files.delete(Paths.get(finalpath)); + } + 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;