1 package compbio.engine.archive;
3 import java.io.FileOutputStream;
4 import java.io.IOException;
5 import java.net.MalformedURLException;
7 import java.nio.channels.Channels;
8 import java.nio.channels.ReadableByteChannel;
9 import java.nio.file.Paths;
10 import java.nio.file.Files;
11 import java.util.List;
13 import compbio.engine.ProteoCachePropertyHelperManager;
14 import compbio.util.PropertyHelper;
16 public class ArchivedJob {
22 private static final PropertyHelper ph = ProteoCachePropertyHelperManager.getPropertyHelper();
24 public ArchivedJob(String id) {
26 jobfilename = id + ".tar.gz";
29 public boolean copyArchiveFromWeb(String webpath) throws IOException, MalformedURLException {
30 URL website = new URL(webpath);
31 ReadableByteChannel rbc = Channels.newChannel(website.openStream());
32 FileOutputStream fos = new FileOutputStream(path);
33 fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
38 public String prepareJobArchiveToWeb() throws IOException {
39 String resultpath = ph.getProperty("archive.web.dir");
40 String thefile = ph.getProperty("archive.path") + '/' + jobfilename;
41 String finalpath = ProteoCachePropertyHelperManager.getLocalPath() + resultpath + '/' + jobfilename;
42 if (Files.isReadable(Paths.get(thefile))) {
43 Files.copy(Paths.get(thefile), Paths.get(finalpath));
44 return resultpath + '/' + jobfilename;
49 public boolean copyArchiveLocaly(String localpath) throws IOException {
50 Files.copy(Paths.get(localpath), Paths.get(path));
54 public void setArchivePath(String path) {
58 public int getSize() {
62 public List<String> unpack() {