[jbpm-commits] JBoss JBPM SVN: r5639 - projects/zync/src.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Sep 14 16:26:30 EDT 2009


Author: tom.baeyens at jboss.com
Date: 2009-09-14 16:26:29 -0400 (Mon, 14 Sep 2009)
New Revision: 5639

Modified:
   projects/zync/src/Zync.java
Log:
updates :-)

Modified: projects/zync/src/Zync.java
===================================================================
--- projects/zync/src/Zync.java	2009-09-14 19:44:39 UTC (rev 5638)
+++ projects/zync/src/Zync.java	2009-09-14 20:26:29 UTC (rev 5639)
@@ -90,100 +90,6 @@
     log("done.");
   }
 
-  static void saveLocalFileNames() {
-    String zyncPreviousFileNamesPath = System.getProperty("user.home")+"/.zync/previous.filenames.txt";
-    try {
-      FileOutputStream outputStream = new FileOutputStream(zyncPreviousFileNamesPath, false);
-      OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream);
-      PrintWriter writer = new PrintWriter(outputStreamWriter);
-      try {
-        for (String localFileName: localFileNames) {
-          writer.println(localFileName);
-        }
-      } finally {
-        writer.close();
-        outputStreamWriter.close();
-        outputStream.close();
-      }
-    } catch (Exception e) {
-      throw new RuntimeException("problem writing "+zyncPreviousFileNamesPath+": "+e.getMessage());
-    }
-  }
-
-  static void loadPreviousLocalFileNames() {
-    String zyncPreviousFileNamesPath = System.getProperty("user.home")+"/.zync/previous.filenames.txt";
-    File file = new File(zyncPreviousFileNamesPath);
-    if (file.exists()) {
-      try {
-        InputStream inputStream = new FileInputStream(file);
-        InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
-        BufferedReader reader = new BufferedReader(inputStreamReader);
-        try {
-          String line;
-          while ((line=reader.readLine())!=null) {
-            previousLocalFileNames.add(line);
-          }
-        } finally {
-          inputStream.close();
-        }
-      } catch (Exception e) {
-        throw new RuntimeException("problem reading "+zyncPreviousFileNamesPath+": "+e.getMessage());
-      }
-    }
-  }
-
-  private static void loadConfiguration() {
-    String zyncCfgPath = System.getProperty("user.home")+"/.zync/zync.properties";
-    File file = new File(zyncCfgPath);
-    if (!file.exists()) {
-      throw new RuntimeException("zync config file "+zyncCfgPath+" does not exist");
-    }
-
-    Properties properties = new Properties();
-    try {
-      FileInputStream inputStream = new FileInputStream(file);
-      properties.load(inputStream);
-    } catch (Exception e) {
-      throw new RuntimeException("couldn't load zync config file "+zyncCfgPath+": "+e.getMessage(), e);
-    }
-
-    ftpServer = properties.getProperty("ftp.server");
-    ftpUsername = properties.getProperty("ftp.username");
-    ftpPassword = properties.getProperty("ftp.password");
-    ftpDirectory = properties.getProperty("ftp.directory");
-    localDirectory = properties.getProperty("local.directory");
-  }
-
-  static void connect() throws Exception {
-    int reply;
-    log("Connecting to " + ftpServer + "...");
-    ftpClient.connect(ftpServer);
-    ftpClient.login(ftpUsername, ftpPassword);
-    ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
-    log("Connected to " + ftpServer + ".");
-    log(ftpClient.getReplyString());
-
-    // After connection attempt, you should check the reply code to verify
-    // success.
-    reply = ftpClient.getReplyCode();
-
-    if(!FTPReply.isPositiveCompletion(reply)) {
-      ftpClient.disconnect();
-      System.err.println("FTP server refused connection.");
-      return;
-    }
-  }
-
-  static void disconnect() {
-    if(ftpClient.isConnected()) {
-      try {
-        ftpClient.disconnect();
-      } catch(IOException ioe) {
-        // do nothing
-      }
-    }
-  }
-
   static void syncDirectory(String directory) {
     try {
       log("syncing directory "+directory);
@@ -213,9 +119,9 @@
       
 
       String remoteDir = ftpDirectory+"/"+directory;
-      //ftpClient.mkd(remoteDir);
+      ftpClient.makeDirectory(remoteDir);
       FTPFile[] ftpFilesArray = ftpClient.listFiles(remoteDir);
-      log("scanning remote directory " + directory);
+      log("scanning remote directory " + remoteDir);
       Map<String, FTPFile> ftpFiles = new HashMap<String, FTPFile>();
       if (ftpFilesArray!=null) {
         for (FTPFile ftpFile: ftpFilesArray) {
@@ -241,7 +147,6 @@
         localTimestamp.set(Calendar.MILLISECOND, 0);
         
         if (ftpFile==null) {
-          log("remote file "+localFileName+" does not exist.");
           uploadFile(localFile, directory);
         } else if (isBefore(localTimestamp, ftpFile.getTimestamp())) {
           log("local file "+localFileName+" is newest");
@@ -268,7 +173,7 @@
       }
       
       for (String subDirectory: subDirectories) {
-        syncDirectory( getRemoteFileName(directory, subDirectory) );
+        syncDirectory( "".equals(directory) ? subDirectory : directory+"/"+subDirectory );
       }
 
     } catch (Exception e) {
@@ -326,6 +231,100 @@
     return first.getTimeInMillis()<second.getTimeInMillis();
   }
 
+  static void saveLocalFileNames() {
+    String zyncPreviousFileNamesPath = System.getProperty("user.home")+"/.zync/previous.filenames.txt";
+    try {
+      FileOutputStream outputStream = new FileOutputStream(zyncPreviousFileNamesPath, false);
+      OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream);
+      PrintWriter writer = new PrintWriter(outputStreamWriter);
+      try {
+        for (String localFileName: localFileNames) {
+          writer.println(localFileName);
+        }
+      } finally {
+        writer.close();
+        outputStreamWriter.close();
+        outputStream.close();
+      }
+    } catch (Exception e) {
+      throw new RuntimeException("problem writing "+zyncPreviousFileNamesPath+": "+e.getMessage());
+    }
+  }
+
+  static void loadPreviousLocalFileNames() {
+    String zyncPreviousFileNamesPath = System.getProperty("user.home")+"/.zync/previous.filenames.txt";
+    File file = new File(zyncPreviousFileNamesPath);
+    if (file.exists()) {
+      try {
+        InputStream inputStream = new FileInputStream(file);
+        InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
+        BufferedReader reader = new BufferedReader(inputStreamReader);
+        try {
+          String line;
+          while ((line=reader.readLine())!=null) {
+            previousLocalFileNames.add(line);
+          }
+        } finally {
+          inputStream.close();
+        }
+      } catch (Exception e) {
+        throw new RuntimeException("problem reading "+zyncPreviousFileNamesPath+": "+e.getMessage());
+      }
+    }
+  }
+
+  private static void loadConfiguration() {
+    String zyncCfgPath = System.getProperty("user.home")+"/.zync/zync.properties";
+    File file = new File(zyncCfgPath);
+    if (!file.exists()) {
+      throw new RuntimeException("zync config file "+zyncCfgPath+" does not exist");
+    }
+
+    Properties properties = new Properties();
+    try {
+      FileInputStream inputStream = new FileInputStream(file);
+      properties.load(inputStream);
+    } catch (Exception e) {
+      throw new RuntimeException("couldn't load zync config file "+zyncCfgPath+": "+e.getMessage(), e);
+    }
+
+    ftpServer = properties.getProperty("ftp.server");
+    ftpUsername = properties.getProperty("ftp.username");
+    ftpPassword = properties.getProperty("ftp.password");
+    ftpDirectory = properties.getProperty("ftp.directory");
+    localDirectory = properties.getProperty("local.directory");
+  }
+
+  static void connect() throws Exception {
+    int reply;
+    log("Connecting to " + ftpServer + "...");
+    ftpClient.connect(ftpServer);
+    ftpClient.login(ftpUsername, ftpPassword);
+    ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
+    log("Connected to " + ftpServer + ".");
+    log(ftpClient.getReplyString());
+
+    // After connection attempt, you should check the reply code to verify
+    // success.
+    reply = ftpClient.getReplyCode();
+
+    if(!FTPReply.isPositiveCompletion(reply)) {
+      ftpClient.disconnect();
+      System.err.println("FTP server refused connection.");
+      return;
+    }
+  }
+
+  static void disconnect() {
+    if(ftpClient.isConnected()) {
+      try {
+        ftpClient.disconnect();
+      } catch(IOException ioe) {
+        // do nothing
+      }
+    }
+  }
+
   static void log(String msg) {
     System.out.println(msg);
   }



More information about the jbpm-commits mailing list