94433de910817f70a7e10d6dc1cd00ed3a7e819d
[proteocache.git] / engine / compbio / engine / archive / ArchivedJob.java
1 package compbio.engine.archive;
2
3 import java.io.FileOutputStream;
4 import java.io.IOException;
5 import java.net.MalformedURLException;
6 import java.net.URL;
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;
12
13 public class ArchivedJob {
14         String path;
15         String id;
16         int filesize;
17         List<String> files;
18
19         public ArchivedJob(String id) {
20                 this.id = id;
21         }
22
23         public boolean copyArchiveFromWeb(String webpath) throws IOException, MalformedURLException {
24                 URL website = new URL(webpath);
25                 ReadableByteChannel rbc = Channels.newChannel(website.openStream());
26                 FileOutputStream fos = new FileOutputStream(path);
27                 fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
28                 return true;
29         }
30
31         public boolean copyArchiveLocaly(String localpath) throws IOException {
32                 Files.copy(Paths.get(localpath), Paths.get(path));
33                 return true;
34         }
35
36         public void setArchivePath(String path) {
37                 this.path = path;
38         }
39
40         public int getSize() {
41                 return filesize;
42         }
43
44         public List<String> unpack() {
45                 if (null != files) {
46
47                 }
48                 return files;
49         }
50 }