AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot);
System.out.println("root AUTHTOKEN = " + "don't log auth tokens!");
token = rootAuthToken.getAuthInfo();
}
LoremIpsum textgen = new LoremIpsum();
DatatypeFactory df = DatatypeFactory.newInstance();
GregorianCalendar gcal = new GregorianCalendar();
gcal.setTimeInMillis(System.currentTimeMillis());
XMLGregorianCalendar xcal = df.newXMLGregorianCalendar(gcal);
for (int i = 0; i < businesses; i++) {
// Creating the parent business entity that will contain our service.
BusinessEntity myBusEntity = new BusinessEntity();
Name myBusName = new Name();
myBusName.setLang("en");
myBusName.setValue("My Business " + i + " " + xcal.toString() + " " + textgen.getWords(5, 2) );
myBusEntity.getDescription().add(new Description( textgen.getWords(10, 2), null));
myBusEntity.getName().add(myBusName);
// Adding the business entity to the "save" structure, using our publisher's authentication info and saving away.
SaveBusiness sb = new SaveBusiness();
sb.getBusinessEntity().add(myBusEntity);
sb.setAuthInfo(token);
BusinessDetail bd = publish.saveBusiness(sb);
String myBusKey = bd.getBusinessEntity().get(0).getBusinessKey();
System.out.println("saved: Business key: " + myBusKey);
for (int k = 0; k < servicesPerBusiness; k++) {
// Creating a service to save. Only adding the minimum data: the parent business key retrieved from saving the business
// above and a single name.
BusinessService myService = new BusinessService();
myService.setBusinessKey(myBusKey);
Name myServName = new Name();
myServName.setLang("en");
myServName.setValue("My Service " + i + " " + k + " " + xcal.toString()+ " " + textgen.getWords(5, 2) );
myService.getName().add(myServName);
myService.getDescription().add(new Description( textgen.getWords(10, 2), null));
// Add binding templates, etc...
BindingTemplate myBindingTemplate = new BindingTemplate();
myBindingTemplate.setCategoryBag(new CategoryBag());
KeyedReference kr = new KeyedReference();
kr.setTModelKey(UDDIConstants.TRANSPORT_HTTP);
kr.setKeyName("keyname1");
kr.setKeyValue("myvalue1");
myBindingTemplate.getCategoryBag().getKeyedReference().add(kr);
KeyedReferenceGroup krg = new KeyedReferenceGroup();
krg.setTModelKey(UDDIConstants.TRANSPORT_HTTP);
kr = new KeyedReference();
kr.setTModelKey(UDDIConstants.PROTOCOL_SSLv3);
kr.setKeyName("keyname1grp");
kr.setKeyValue("myvalue1grp");
krg.getKeyedReference().add(kr);
myBindingTemplate.getCategoryBag().getKeyedReferenceGroup().add(krg);
myService.setCategoryBag(new CategoryBag());
kr = new KeyedReference();
kr.setTModelKey(UDDIConstants.TRANSPORT_HTTP);
kr.setKeyName("Servicekeyname2grp");
kr.setKeyValue("Servicemyvalue2grp");
myService.getCategoryBag().getKeyedReference().add(kr);
krg = new KeyedReferenceGroup();
krg.setTModelKey(UDDIConstants.TRANSPORT_HTTP);
kr = new KeyedReference();
kr.setTModelKey(UDDIConstants.TRANSPORT_HTTP);
kr.setKeyName("keyname1grp");
kr.setKeyValue("myvalue1grp");
krg.getKeyedReference().add(kr);
myService.getCategoryBag().getKeyedReferenceGroup().add(krg);
AccessPoint accessPoint = new AccessPoint();
accessPoint.setUseType(AccessPointType.WSDL_DEPLOYMENT.toString());
accessPoint.setValue("http://example.org/services/myservice" + i + k + "?wsdl");
myBindingTemplate.setAccessPoint(accessPoint);
myBindingTemplate.setTModelInstanceDetails(new TModelInstanceDetails());
TModelInstanceInfo tii = new TModelInstanceInfo();
Description d = new Description();
d.setValue("Tmodel instance description");
tii.getDescription().add(d);
tii.setTModelKey(UDDIConstants.TRANSPORT_HTTP);
tii.setInstanceDetails(new InstanceDetails());
tii.getInstanceDetails().setInstanceParms("heres some useful stuff describing this endpoint, up to 4KB of data"+ " " + textgen.getWords(20, 2) );
tii.getInstanceDetails().getDescription().add(d);
OverviewDoc od = new OverviewDoc();
d = new Description();
d.setValue("ovweview doc description"+ " " + textgen.getWords(5, 2) );
od.getDescription().add(d);
od.setOverviewURL(new OverviewURL());
od.getOverviewURL().setUseType("www");
od.getOverviewURL().setValue("www.apache.org");
tii.getInstanceDetails().getOverviewDoc().add(od);