1 16 package org.apache.juddi.function; 17 18 import java.util.Vector ; 19 20 import org.apache.commons.logging.Log; 21 import org.apache.commons.logging.LogFactory; 22 import org.apache.juddi.datastore.DataStore; 23 import org.apache.juddi.datastore.DataStoreFactory; 24 import org.apache.juddi.datatype.RegistryObject; 25 import org.apache.juddi.datatype.request.GetBindingDetail; 26 import org.apache.juddi.datatype.response.BindingDetail; 27 import org.apache.juddi.error.InvalidKeyPassedException; 28 import org.apache.juddi.error.RegistryException; 29 import org.apache.juddi.registry.RegistryEngine; 30 import org.apache.juddi.util.Config; 31 32 35 public class GetBindingDetailFunction extends AbstractFunction 36 { 37 private static Log log = LogFactory.getLog(GetBindingDetailFunction.class); 39 40 43 public GetBindingDetailFunction(RegistryEngine registry) 44 { 45 super(registry); 46 } 47 48 51 public RegistryObject execute(RegistryObject regObject) 52 throws RegistryException 53 { 54 GetBindingDetail request = (GetBindingDetail)regObject; 55 String generic = request.getGeneric(); 56 Vector keyVector = request.getBindingKeyVector(); 57 58 DataStore dataStore = DataStoreFactory.getDataStore(); 60 61 try 62 { 63 dataStore.beginTrans(); 64 65 for (int i=0; i<keyVector.size(); i++) 66 { 67 String bindingKey = (String )keyVector.elementAt(i); 69 70 if ((bindingKey == null) || (bindingKey.length() == 0) || 73 (!dataStore.isValidBindingKey(bindingKey))) 74 throw new InvalidKeyPassedException("get_bindingDetail: "+ 75 "bindingKey="+bindingKey); 76 } 77 78 Vector bindingVector = new Vector (); 79 80 for (int i=0; i<keyVector.size(); i++) 81 { 82 String key = (String )keyVector.elementAt(i); 83 bindingVector.add(dataStore.fetchBinding(key)); 84 } 85 86 dataStore.commit(); 87 88 BindingDetail detail = new BindingDetail(); 90 detail.setGeneric(generic); 91 detail.setBindingTemplateVector(bindingVector); 92 detail.setOperator(Config.getOperator()); 93 return detail; 94 } 95 catch(InvalidKeyPassedException keyex) 96 { 97 try { dataStore.rollback(); } catch(Exception e) { } 98 log.info(keyex.getMessage()); 99 throw (RegistryException)keyex; 100 } 101 catch(RegistryException regex) 102 { 103 try { dataStore.rollback(); } catch(Exception e) { } 104 log.error(regex); 105 throw (RegistryException)regex; 106 } 107 catch(Exception ex) 108 { 109 try { dataStore.rollback(); } catch(Exception e) { } 110 log.error(ex); 111 throw new RegistryException(ex); 112 } 113 finally 114 { 115 if (dataStore != null) 116 dataStore.release(); 117 } 118 } 119 120 121 122 123 124 125 126 public static void main(String [] args) 127 { 128 RegistryEngine reg = new RegistryEngine(); 130 reg.init(); 131 132 try 133 { 134 } 135 catch (Exception ex) 136 { 137 ex.printStackTrace(); 139 } 140 finally 141 { 142 reg.dispose(); 144 } 145 } 146 } | Popular Tags |