a5d3ddd5b437987e8813ed068bc7c453eddc1ef8
[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.cassandra.CassandraNativeConnector;
9 import compbio.engine.ProteoCachePropertyHelperManager;
10 import compbio.util.PropertyHelper;
11
12 public class Archive {
13         private static final PropertyHelper ph = ProteoCachePropertyHelperManager.getPropertyHelper();
14         private static Logger log = Logger.getLogger(CassandraNativeConnector.class);
15
16         private String archivepath;
17         private File archive;
18         private boolean archiveexist;
19
20         /*
21          * connect to the cluster and look whether all tables exist
22          */
23         public Archive() throws IOException {
24                 String path = ph.getProperty("archive.path");
25                 assert (null != path);
26
27                 if (isAbsolutePath (path)) {
28                         archivepath = path;
29                 } else {
30                         String abspath = ProteoCachePropertyHelperManager.getLocalPath();
31                         archivepath = abspath + "/" + path;
32                 }
33                 if (!isDirExists(archivepath)) {
34                         archiveexist = (new File(archivepath).mkdirs());
35                 }
36         }
37
38         private boolean isAbsolutePath (String path) {
39                  return (new File(path).isAbsolute());
40         }
41         
42         private boolean isDirExists (String path) throws IOException {
43                 archive = new File(path);
44                 return archive.getCanonicalFile().isDirectory();
45         }
46         
47
48         public boolean addArchivedJob (ArchivedJob job) {
49                 return true;
50         }
51         
52         public String createJob(String jobid) {
53                 return archivepath + "/" + jobid + ".tar.gz";
54         }
55
56 }