392a7376d856b10ec7882702d64687bc3a16571f
[proteocache.git] / engine / compbio / engine / archive / Archive.java
1 package compbio.engine.archive;
2
3 import java.io.File;
4 import java.io.IOException;
5
6 import org.apache.log4j.Logger;
7
8 import compbio.engine.ProteoCachePropertyHelperManager;
9 import compbio.util.PropertyHelper;
10
11 public class Archive {
12         private static final PropertyHelper ph = ProteoCachePropertyHelperManager.getPropertyHelper();
13         private static Logger log = Logger.getLogger(Archive.class);
14
15         private String archivepath;
16         private File archive;
17         private boolean archiveexist;
18
19         public Archive() throws IOException {
20                 String path = ph.getProperty("archive.path");
21                 assert (null != path);
22
23                 if (isAbsolutePath (path)) {
24                         archivepath = path;
25                 } else {
26                         String abspath = ProteoCachePropertyHelperManager.getLocalPath();
27                         archivepath = abspath + "/" + path;
28                 }
29                 if (!isDirExists(archivepath)) {
30                         archiveexist = (new File(archivepath).mkdirs());
31                 }
32         }
33
34         private boolean isAbsolutePath (String path) {
35                  return (new File(path).isAbsolute());
36         }
37         
38         private boolean isDirExists (String path) throws IOException {
39                 archive = new File(path);
40                 return archive.getCanonicalFile().isDirectory();
41         }
42         
43
44         public boolean addArchivedJob (ArchivedJob job) {
45                 return true;
46         }
47         
48         public String createJob(String jobid) {
49                 return archivepath + "/" + jobid + ".tar.gz";
50         }
51
52 }