1 16 package org.apache.juddi.datastore.jdbc; 17 18 import java.sql.Connection ; 19 import java.util.Vector ; 20 21 import org.apache.juddi.datatype.Description; 22 import org.apache.juddi.datatype.OverviewDoc; 23 import org.apache.juddi.datatype.binding.AccessPoint; 24 import org.apache.juddi.datatype.binding.BindingTemplate; 25 import org.apache.juddi.datatype.binding.TModelInstanceInfo; 26 import org.apache.juddi.datatype.business.BusinessEntity; 27 import org.apache.juddi.datatype.service.BusinessService; 28 import org.apache.juddi.util.Config; 29 import org.apache.juddi.util.jdbc.Transaction; 30 import org.apache.juddi.uuidgen.UUIDGen; 31 import org.apache.juddi.uuidgen.UUIDGenFactory; 32 33 36 class TestInstanceDetailsDocDescTable 37 { 38 public static void main(String [] args) 39 throws Exception 40 { 41 Config.setStringProperty("juddi.useConnectionPool","true"); 44 45 Connection conn = null; 46 try { 47 conn = Database.aquireConnection(); 48 test(conn); 49 } 50 finally { 51 if (conn != null) 52 conn.close(); 53 } 54 } 55 56 public static void test(Connection connection) throws Exception 57 { 58 Transaction txn = new Transaction(); 59 UUIDGen uuidgen = UUIDGenFactory.getUUIDGen(); 60 61 if (connection != null) 62 { 63 try 64 { 65 String businessKey = uuidgen.uuidgen(); 66 BusinessEntity business = new BusinessEntity(); 67 business.setBusinessKey(businessKey); 68 business.setAuthorizedName("sviens"); 69 business.setOperator("WebServiceRegistry.com"); 70 71 String serviceKey = uuidgen.uuidgen(); 72 BusinessService service = new BusinessService(); 73 service.setBusinessKey(businessKey); 74 service.setServiceKey(serviceKey); 75 76 String bindingKey = uuidgen.uuidgen(); 77 BindingTemplate binding = new BindingTemplate(); 78 binding.setServiceKey(serviceKey); 79 binding.setBindingKey(bindingKey); 80 binding.setAccessPoint( 81 new AccessPoint("http://www.juddi.org/bindingtemplate.html", "http")); 82 83 Vector infoList = new Vector (); 84 infoList.add(new TModelInstanceInfo(uuidgen.uuidgen())); 85 int infoID = 0; 86 87 OverviewDoc overviewDoc = new OverviewDoc(); 88 overviewDoc.setOverviewURL("http://www.juddi.org/overviewdoc.html"); 89 90 Vector descList = new Vector (); 91 descList.add(new Description("blah, blah, blah", "en")); 92 descList.add(new Description("Yadda, Yadda, Yadda", "it")); 93 descList.add(new Description("WhoobWhoobWhoobWhoob", "cy")); 94 descList.add(new Description("Haachachachacha", "km")); 95 96 String authorizedUserID = "sviens"; 97 98 txn.begin(connection); 100 101 BusinessEntityTable.insert(business, authorizedUserID, connection); 103 104 BusinessServiceTable.insert(service, connection); 106 107 BindingTemplateTable.insert(binding, connection); 109 110 TModelInstanceInfoTable.insert(bindingKey, infoList, connection); 112 113 InstanceDetailsDocDescTable.insert( 115 bindingKey, 116 infoID, 117 descList, 118 connection); 119 120 descList = 122 InstanceDetailsDocDescTable.select(bindingKey, infoID, connection); 123 124 InstanceDetailsDocDescTable.delete(bindingKey, connection); 126 127 descList = 129 InstanceDetailsDocDescTable.select(bindingKey, infoID, connection); 130 131 txn.commit(); 133 } 134 catch (Exception ex) 135 { 136 try 137 { 138 txn.rollback(); 139 } 140 catch (java.sql.SQLException sqlex) 141 { 142 sqlex.printStackTrace(); 143 } 144 throw ex; 145 } 146 } 147 } 148 } 149 | Popular Tags |