Fix session constructor/initialisation if the session directory already exists
authorpmarguerite <pmarguerite@issues.jalview.org>
Thu, 14 Dec 2006 19:21:21 +0000 (19:21 +0000)
committerpmarguerite <pmarguerite@issues.jalview.org>
Thu, 14 Dec 2006 19:21:21 +0000 (19:21 +0000)
git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@301 be28352e-c001-0410-b1a7-c7978e42abec

src/uk/ac/vamsas/client/simpleclient/VamsasSession.java

index a70fe54..34b69d7 100644 (file)
@@ -117,7 +117,20 @@ public class VamsasSession {
   private void initLog() throws IOException {
     // LATER: make dedicated appender format for session log.
     Appender app = slog.getAppender("SESSION_LOG");
-    slog.addAppender(new FileAppender(app.getLayout(), new File(sessionDir, SESSION_LOG).getAbsolutePath()));
+   // slog.addAppender(new FileAppender(app.getLayout(), new File(sessionDir, SESSION_LOG).getAbsolutePath()));
+    
+    //Appender app = slog.getAppender("SESSION_LOG");
+    if (app == null) log.info("No appender for SESSION_LOG");
+  
+    if (slog!= null && app != null)
+      {
+        if (app instanceof FileAppender)
+          {
+            File sessionLogFile =  new File(this.sessionDir, ((FileAppender)app).getFile());
+            slog.addAppender(new FileAppender(app.getLayout(), sessionLogFile.getAbsolutePath()));
+          }
+        // slog.removeAppender("SESSION_LOG");
+      }
   }
   
   /**
@@ -146,12 +159,14 @@ public class VamsasSession {
       if (!sessionDir.isDirectory() || !sessionDir.canWrite() || !sessionDir.canRead())
         throw new IOException("Cannot access '"+sessionDir+"' as a read/writable Directory.");
       if (checkSessionFiles(sessionDir)) {
+        createSessionFiles();
+      }
         // session files exist in the directory
         this.sessionDir = sessionDir;
         initSessionObjects();
         slog.debug("Initialising additional VamsasSession instance");
         log.debug("Attached to VamsasSession in "+sessionDir);
-      } 
+      //} 
     } else {
       // start from scratch
       if (!sessionDir.mkdir())