1 package org.openbravo.erpCommon.utility; 2 3 import org.openbravo.utils.FileUtility; 4 import org.openbravo.utils.DirFilter; 5 import org.openbravo.erpCommon.ad_combos.LanguageComboData; 6 import org.openbravo.database.CPStandAlone; 7 8 import java.io.*; 9 import org.apache.log4j.Logger; 10 import org.apache.log4j.PropertyConfigurator; 11 12 class CommandLine_CopyFiles { 13 static Logger log4j = Logger.getLogger(CommandLine_CopyFiles.class); 14 15 public static void main(String argv[]) throws Exception { 16 PropertyConfigurator.configure("log4j.lcf"); 17 String connectionFile; 18 String source; 19 String destiny; 20 DirFilter filter = null; 21 boolean overwrite = false; 22 boolean discardHidden = false; 23 String language = ""; 24 25 if (argv.length < 6) { 26 log4j.error("Usage: java org.openbravo.erpCommon.utility.CommandLine_CopyFiles XmlPool.xml source destiny filter discard_hidden overwrite [language]"); 27 return; 28 } 29 30 connectionFile = argv[0]; 31 source = argv[1]; 32 destiny = argv[2]; 33 filter = new DirFilter(argv[3]); 34 if (argv[4].equals("true")) discardHidden = true; 35 if (argv[5].equals("true")) overwrite = true; 36 if (argv.length > 6) language = argv[6]; 37 38 File fileSource = new File(source); 39 if (!fileSource.exists()) throw new Exception ("Source directory doesn't exists: " + source); 40 41 CPStandAlone conn = null; 42 try { 43 conn = new CPStandAlone(connectionFile); 44 FileUtility fUtility = new FileUtility(); 45 LanguageComboData[] data = LanguageComboData.selectOthers(conn, language); 46 if (data!=null && data.length>0) { 47 for (int i=0;i<data.length;i++) { 48 File fileLang = new File(destiny, data[i].adLanguage); 49 fileLang.mkdir(); 50 log4j.info("files copied to " + data[i].adLanguage + ": " + fUtility.copy(fileSource, fileLang, filter, discardHidden, overwrite)); 51 } 52 } 53 54 conn.destroy(); 55 } catch (Exception ex) { 56 conn.destroy(); 57 throw ex; 58 } 59 } 60 } 61 | Popular Tags |