1 package sdk; 2 3 import dinamica.*; 4 import java.io.*; 5 6 16 public class ActionDocGen 17 { 18 19 String rootPath = null; 20 Recordset action = new Recordset(); 21 22 public ActionDocGen(String path) throws Throwable 23 { 24 rootPath = path; 25 action.append("path", java.sql.Types.VARCHAR); 26 action.append("dataclass", java.sql.Types.VARCHAR); 27 action.append("outputclass", java.sql.Types.VARCHAR); 28 action.append("log", java.sql.Types.VARCHAR); 29 action.append("jdbclog", java.sql.Types.VARCHAR); 30 action.append("tx-enabled", java.sql.Types.VARCHAR); 31 action.append("summary", java.sql.Types.VARCHAR); 32 33 File f = new File(rootPath); 34 if (!f.exists()) 35 throw new Throwable ("Path not found - Invalid Action path: " + rootPath); 36 getData(f); 37 38 } 39 40 void getData(File f) throws Throwable 41 { 42 String items[] = f.list(); 43 44 46 for (int i=0;i<items.length;i++) 47 { 48 49 String fname = f.getPath() + File.separator + items[i]; 50 51 File item = new File(fname); 52 if (item.isDirectory()) 53 { 54 getData(item); 55 } 56 else 57 { 58 if (item.getName().equals("config.xml")) 59 { 60 Config c = new Config(getFile(item), item.getParent()); 61 String path = c.path.substring(c.path.lastIndexOf("WEB-INF") + "WEB-INF".length()); 62 path = StringUtil.replace(path, "\\", "/"); 63 action.addNew(); 64 action.setValue("path", path); 65 action.setValue("summary", c.summary); 66 action.setValue("tx-enabled", c.transTransactions); 67 action.setValue("dataclass", c.transClassName); 68 action.setValue("outputclass", c.outClassName); 69 action.setValue("log", c.mvcLog); 70 action.setValue("jdbclog", c.jdbcLog); 71 } 72 } 73 74 } 75 76 } 77 78 String getFile(File f) throws Throwable 79 { 80 byte buffer[] = new byte[(int)f.length()]; 81 FileInputStream fis = null; 82 try 83 { 84 fis = new FileInputStream(f); 85 fis.read(buffer); 86 String data = new String (buffer); 87 return data; 88 } 89 catch (FileNotFoundException e) 90 { 91 throw e; 92 } 93 catch (IOException e) 94 { 95 throw e; 96 } 97 finally 98 { 99 if (fis!=null) 100 fis.close(); 101 } 102 } 103 104 120 public Recordset getActions() 121 { 122 return action; 123 } 124 125 } 126 | Popular Tags |