First working code for archinving Jpred jobs
[proteocache.git] / engine / compbio / engine / archive / Archive.java
index 2a1f410..a5d3ddd 100644 (file)
@@ -1,5 +1,56 @@
 package compbio.engine.archive;
 
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.log4j.Logger;
+
+import compbio.cassandra.CassandraNativeConnector;
+import compbio.engine.ProteoCachePropertyHelperManager;
+import compbio.util.PropertyHelper;
+
 public class Archive {
+       private static final PropertyHelper ph = ProteoCachePropertyHelperManager.getPropertyHelper();
+       private static Logger log = Logger.getLogger(CassandraNativeConnector.class);
+
+       private String archivepath;
+       private File archive;
+       private boolean archiveexist;
+
+       /*
+        * connect to the cluster and look whether all tables exist
+        */
+       public Archive() throws IOException {
+               String path = ph.getProperty("archive.path");
+               assert (null != path);
+
+               if (isAbsolutePath (path)) {
+                       archivepath = path;
+               } else {
+                       String abspath = ProteoCachePropertyHelperManager.getLocalPath();
+                       archivepath = abspath + "/" + path;
+               }
+               if (!isDirExists(archivepath)) {
+                       archiveexist = (new File(archivepath).mkdirs());
+               }
+       }
+
+       private boolean isAbsolutePath (String path) {
+                return (new File(path).isAbsolute());
+       }
+       
+       private boolean isDirExists (String path) throws IOException {
+               archive = new File(path);
+               return archive.getCanonicalFile().isDirectory();
+       }
+       
+
+       public boolean addArchivedJob (ArchivedJob job) {
+               return true;
+       }
+       
+       public String createJob(String jobid) {
+               return archivepath + "/" + jobid + ".tar.gz";
+       }
 
 }