Add still-not-working code for archiving jobs
[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.util.List;
10
11 public class ArchivedJob {
12         String path;
13         int filesize;
14         List<String> files;
15
16         ArchivedJob (String path) {
17                 this.path = path;
18         }
19         
20         public boolean getArchiveFromWS() {
21                 return false;
22         }
23         
24         
25         public boolean getArchiveFromWeb (String webpath) throws IOException, MalformedURLException {
26                 URL website = new URL(webpath);
27                 ReadableByteChannel rbc = Channels.newChannel(website.openStream());
28                 FileOutputStream fos = new FileOutputStream(path);
29                 fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
30                 return true;
31         }
32         
33         
34         public int getSize() {
35                 return filesize;
36         }
37         
38         public List<String> unpack() {
39                 if (null != files) {
40                         
41                 }
42                 return files;
43         }
44 }