| 1 package dinamica.security; 2 3 import dinamica.*; 4 import javax.sql.DataSource ; 5 import java.sql.*; 6 7 18 public class GetMenu extends GenericTransaction 19 { 20 21 24 public int service(Recordset inputParams) throws Throwable  25 { 26 int rc = 0; 27 28 super.service(inputParams); 30 31 String jndiName = (String )getContext().getAttribute("dinamica.security.datasource"); 33 if (jndiName==null) 34 throw new Throwable ("Context attribute [dinamica.security.datasource] is null, check your security filter configuration."); 35 36 DataSource ds = Jndi.getDataSource(jndiName); 38 Connection conn = ds.getConnection(); 39 this.setConnection(conn); 40 41 try 42 { 43 44 Db db = getDb(); 46 47 String sql = getSQL(getResource("query-master.sql"), inputParams); 49 50 Recordset menu = db.get(sql); 52 53 publish("menu", menu); 54 55 } 56 catch (Throwable e) 57 { 58 throw e; 59 } 60 finally 61 { 62 if (conn!=null) 63 conn.close(); 64 } 65 66 return rc; 67 68 } 69 70 public Recordset getMenuItems(Recordset menu) throws Throwable  71 { 72 String jndiName = (String )getContext().getAttribute("dinamica.security.datasource"); 74 if (jndiName==null) 75 throw new Throwable ("Context attribute [dinamica.security.datasource] is null, check your security filter configuration."); 76 77 DataSource ds = Jndi.getDataSource(jndiName); 79 Connection conn = ds.getConnection(); 80 this.setConnection(conn); 81 82 try 83 { 84 85 Db db = getDb(); 87 88 String sql = getSQL(getResource("query-detail.sql"), menu); 90 91 Recordset items = db.get(sql); 93 94 return items; 95 96 } 97 catch (Throwable e) 98 { 99 throw e; 100 } 101 finally 102 { 103 if (conn!=null) 104 conn.close(); 105 } 106 107 } 108 109 } 110 | Popular Tags |