}
}
TModel keygen = UDDIClerk.createKeyGenator("uddi:" + domain + ":keygenerator", domain, "en");
//save the keygen
SaveTModel stm = new SaveTModel();
stm.setAuthInfo(token);
stm.getTModel().add(keygen);
System.out.println("Saving key gen " + keygen.getTModelKey());
publish.saveTModel(stm);
System.out.println("Saved!");
//step three, we have two options
//1) import the wsdl's services into a brand new business
//2) import the wsdl's services into an existing business
//in either case, we're going to have to parse the WSDL
ReadWSDL rw = new ReadWSDL();
Definition wsdlDefinition = null;
if (pathOrURL.startsWith("http")) {
wsdlDefinition = rw.readWSDL(new URL(pathOrURL));
} else {
wsdlDefinition = rw.readWSDL(pathOrURL);
}
if (wsdlDefinition == null) {
System.out.println("There was an error parsing the WSDL!");
return;
}
properties.put("keyDomain", domain);
properties.put("businessName", domain);
properties.put("serverName", domain);
properties.put("serverPort", port);
wsdlURL = wsdlDefinition.getDocumentBaseURI();
WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizerDefaultImpl(), properties);
BusinessServices businessServices = wsdl2UDDI.createBusinessServices(wsdlDefinition);
@SuppressWarnings("unchecked")
Map<QName, PortType> portTypes = (Map<QName, PortType>) wsdlDefinition.getAllPortTypes();
Set<TModel> portTypeTModels = wsdl2UDDI.createWSDLPortTypeTModels(wsdlURL, portTypes);
Map allBindings = wsdlDefinition.getAllBindings();
Set<TModel> createWSDLBindingTModels = wsdl2UDDI.createWSDLBindingTModels(wsdlURL, allBindings);
//When parsing a WSDL, there's really two things going on
//1) convert a bunch of stuff (the portTypes) to tModels
//2) convert the service definition to a BusinessService
//Since the service depends on the tModel, we have to save the tModels first
stm = new SaveTModel();
stm.setAuthInfo(token);
TModel[] tmodels = portTypeTModels.toArray(new TModel[0]);
for (int i = 0; i < tmodels.length; i++) {
stm.getTModel().add(tmodels[i]);
}
tmodels = createWSDLBindingTModels.toArray(new TModel[0]);
for (int i = 0; i < tmodels.length; i++) {
stm.getTModel().add(tmodels[i]);
}
//important, you'll need to save your new tModels first, or else saving the business/service may fail
System.out.println(new PrintUDDI<SaveTModel>().print(stm));
System.out.println("Saving " + stm.getTModel().size() + " tModels");
publish.saveTModel(stm);
System.out.println("Saved!");
if (businessKey == null || businessKey.length() == 0) {
SaveBusiness sb = new SaveBusiness();