1 package org.enhydra.dods.generator; 2 3 import java.io.File ; 4 import java.io.FileInputStream ; 5 import java.io.FileOutputStream ; 6 import java.util.Properties ; 7 import org.enhydra.dods.Common; 8 import org.enhydra.dods.xml.XmlUtil; 9 import org.enhydra.dods.xml.XmlUtilException; 10 11 17 public class DODSEjenProperties { 18 public static void main(String [] args) { 19 20 String customTemplateDirStr = null; 21 22 try { 23 Properties dodswizard = new Properties (); 24 25 dodswizard.setProperty("project.root", args[1]); 26 dodswizard.setProperty("doml.file", args[0]); 27 dodswizard.setProperty("doml.template", args[2]); 28 dodswizard.setProperty("database.vendor", args[3]); 29 dodswizard.setProperty("generate.force", args[4]); 30 dodswizard.setProperty("dods.config", Common.getConfigDir()); 31 customTemplateDirStr = Common.getCustomTemplateDir(); 32 int l = 0; 33 int k = 0; 34 int last = 0; 35 36 if (System.getProperty("os.name").toLowerCase().startsWith("win")) { 37 l = args[0].lastIndexOf("/"); 38 k = args[0].lastIndexOf("\\"); 39 if (l >= k) { 40 last = l; 41 } else { 42 last = k; 43 } 44 } else { 45 last = args[0].lastIndexOf("/"); 46 } 47 dodswizard.setProperty("doml.filename", args[0].substring(last + 1)); 48 49 File dodsEjenProperty = new File (Common.getDodsEjenPropertyFilename()); 50 51 dodsEjenProperty.getParentFile().mkdirs(); 52 dodswizard.store(new FileOutputStream (Common.getDodsEjenPropertyFilename()), 53 "DODS Generator Wizard"); 54 Properties dodsProperties = new Properties (); 55 FileInputStream fisInstall = new FileInputStream (Common.getInstallProperties()); 56 57 dodsProperties.load(fisInstall); 58 fisInstall.close(); 59 dodsProperties.setProperty("current.user.dir", 60 System.getProperties().getProperty("user.home")); 61 62 String templateDir = null; 63 64 if (customTemplateDirStr != null) { 65 templateDir = customTemplateDirStr; 66 } else { 67 try { 68 templateDir = XmlUtil.getSingleTextNode(Common.getConfigDir() 69 + File.separator + "dodsConf.xml", 70 "/dodsConf/TemplateDir", null); 71 } catch (XmlUtilException ex) {} 72 73 if (templateDir == null) { 74 templateDir = Common.getDODSRoot() + File.separator 75 + "template"; 76 } 77 78 } 79 dodsProperties.setProperty("template.dir", templateDir); 80 dodsProperties.store(new FileOutputStream (Common.getInstallProperties()), 81 "DODS-EJEN INSTALL PROPERTIES"); 82 } catch (Exception e) { 83 e.printStackTrace(); 84 } 85 } 86 } 87 | Popular Tags |