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<String> 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 {
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;