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.publisher.Publisher; 26 import org.apache.juddi.datatype.request.AuthInfo; 27 import org.apache.juddi.datatype.request.GetRegisteredInfo; 28 import org.apache.juddi.datatype.response.BusinessInfos; 29 import org.apache.juddi.datatype.response.RegisteredInfo; 30 import org.apache.juddi.datatype.response.TModelInfos; 31 import org.apache.juddi.error.RegistryException; 32 import org.apache.juddi.registry.RegistryEngine; 33 import org.apache.juddi.util.Config; 34 35 38 public class GetRegisteredInfoFunction extends AbstractFunction 39 { 40 private static Log log = LogFactory.getLog(GetRegisteredInfoFunction.class); 42 43 46 public GetRegisteredInfoFunction(RegistryEngine registry) 47 { 48 super(registry); 49 } 50 51 54 public RegistryObject execute(RegistryObject regObject) 55 throws RegistryException 56 { 57 GetRegisteredInfo request = (GetRegisteredInfo)regObject; 58 String generic = request.getGeneric(); 59 AuthInfo authInfo = request.getAuthInfo(); 60 61 DataStore dataStore = DataStoreFactory.getDataStore(); 63 64 try 65 { 66 dataStore.beginTrans(); 67 68 Publisher publisher = getPublisher(authInfo,dataStore); 70 String publisherID = publisher.getPublisherID(); 71 72 75 BusinessInfos businessInfos = new BusinessInfos(); 77 TModelInfos tModelInfos = new TModelInfos(); 78 Vector keyVector = null; 79 Vector infoVector = null; 80 81 keyVector = dataStore.findRegisteredBusinesses(publisherID); 83 if ((keyVector != null) && (keyVector.size() > 0)) 84 { 85 int rowCount = keyVector.size(); 86 87 infoVector = new Vector (rowCount); 89 for (int i=0; i<rowCount; i++) 90 infoVector.addElement(dataStore.fetchBusinessInfo((String )keyVector.elementAt(i))); 91 92 businessInfos.setBusinessInfoVector(infoVector); 93 } 94 95 keyVector = dataStore.findRegisteredTModels(publisherID); 97 if ((keyVector != null) && (keyVector.size() > 0)) 98 { 99 int rowCount = keyVector.size(); 100 101 infoVector = new Vector (rowCount); 103 for (int i=0; i<rowCount; i++) 104 infoVector.addElement(dataStore.fetchTModelInfo((String )keyVector.elementAt(i))); 105 106 tModelInfos.setTModelInfoVector(infoVector); 107 } 108 109 dataStore.commit(); 110 111 RegisteredInfo info = new RegisteredInfo(); 114 info.setGeneric(generic); 115 info.setOperator(Config.getOperator()); 116 info.setBusinessInfos(businessInfos); 117 info.setTModelInfos(tModelInfos); 118 return info; 119 } 120 catch(RegistryException regex) 121 { 122 try { dataStore.rollback(); } catch(Exception e) { } 123 log.error(regex); 124 throw (RegistryException)regex; 125 } 126 catch(Exception ex) 127 { 128 try { dataStore.rollback(); } catch(Exception e) { } 129 log.error(ex); 130 throw new RegistryException(ex); 131 } 132 finally 133 { 134 if (dataStore != null) 135 dataStore.release(); 136 } 137 } 138 139 140 141 142 143 144 145 public static void main(String [] args) 146 { 147 RegistryEngine reg = new RegistryEngine(); 149 reg.init(); 150 151 try 152 { 153 } 154 catch (Exception ex) 155 { 156 ex.printStackTrace(); 158 } 159 finally 160 { 161 reg.dispose(); 163 } 164 } 165 } | Popular Tags |