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.GetServiceDetail; 26 import org.apache.juddi.datatype.response.ServiceDetail; 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 33 36 public class GetServiceDetailFunction extends AbstractFunction 37 { 38 private static Log log = LogFactory.getLog(GetServiceDetailFunction.class); 40 41 44 public GetServiceDetailFunction(RegistryEngine registry) 45 { 46 super(registry); 47 } 48 49 52 public RegistryObject execute(RegistryObject regObject) 53 throws RegistryException 54 { 55 GetServiceDetail request = (GetServiceDetail)regObject; 56 String generic = request.getGeneric(); 57 Vector keyVector = request.getServiceKeyVector(); 58 59 DataStore dataStore = DataStoreFactory.getDataStore(); 61 62 try 63 { 64 dataStore.beginTrans(); 65 66 for (int i=0; i<keyVector.size(); i++) 67 { 68 String serviceKey = (String )keyVector.elementAt(i); 69 70 if ((serviceKey == null) || (serviceKey.length() == 0) || 72 (!dataStore.isValidServiceKey(serviceKey))) 73 throw new InvalidKeyPassedException("get_serviceDetail: "+ 74 "serviceKey="+serviceKey); 75 } 76 77 Vector serviceVector = new Vector (); 78 79 for (int i=0; i<keyVector.size(); i++) 80 { 81 String serviceKey = (String )keyVector.elementAt(i); 82 serviceVector.add(dataStore.fetchService(serviceKey)); 83 } 84 85 dataStore.commit(); 86 87 ServiceDetail detail = new ServiceDetail(); 89 detail.setGeneric(generic); 90 detail.setOperator(Config.getOperator()); 91 detail.setBusinessServiceVector(serviceVector); 92 return detail; 93 } 94 catch(InvalidKeyPassedException keyex) 95 { 96 try { dataStore.rollback(); } catch(Exception e) { } 97 log.info(keyex.getMessage()); 98 throw (RegistryException)keyex; 99 } 100 catch(RegistryException regex) 101 { 102 try { dataStore.rollback(); } catch(Exception e) { } 103 log.error(regex); 104 throw (RegistryException)regex; 105 } 106 catch(Exception ex) 107 { 108 try { dataStore.rollback(); } catch(Exception e) { } 109 log.error(ex); 110 throw new RegistryException(ex); 111 } 112 finally 113 { 114 if (dataStore != null) 115 dataStore.release(); 116 } 117 } 118 119 120 121 122 123 124 125 public static void main(String [] args) 126 { 127 RegistryEngine reg = new RegistryEngine(); 129 reg.init(); 130 131 try 132 { 133 } 134 catch (Exception ex) 135 { 136 ex.printStackTrace(); 138 } 139 finally 140 { 141 reg.dispose(); 143 } 144 } 145 } 146 147 | Popular Tags |