Creator creator = new Creator(blm);
Collection<Organization> organizations = new ArrayList<Organization>();
Organization organization = creator.createOrganization("Red Hat/JBossESB");
organizations.add(organization);
BulkResponse br = blm.saveOrganizations(organizations);
assertEquals(BulkResponse.STATUS_SUCCESS, br.getStatus());
} catch (JAXRException je) {
je.printStackTrace();
assertTrue(false);
}
//find organization
try
{
RegistryService rs = connection.getRegistryService();
bqm = rs.getBusinessQueryManager();
Finder finder = new Finder(bqm, uddiversion);
Collection<Organization> orgs = finder.findOrganizationsByName("Red Hat/JBossESB");
Organization org = orgs.iterator().next();
assertEquals("Red Hat/JBossESB", org.getName().getValue());
} catch (JAXRException je) {
fail(je.getMessage());
}
try {
RegistryService rs = connection.getRegistryService();
bqm = rs.getBusinessQueryManager();
Finder finder = new Finder(bqm, uddiversion);
Collection<Organization> orgs = finder.findOrganizationsByName("Not Existing Org");
assertEquals(0, orgs.size());
} catch (JAXRException je) {
fail(je.getMessage());
}
//Publish a service
try {
RegistryService rs = connection.getRegistryService();
bqm = rs.getBusinessQueryManager();
Finder finder = new Finder(bqm, uddiversion);
Collection<Organization> orgs = finder.findOrganizationsByName("Red Hat/JBossESB");
Organization organization = orgs.iterator().next();
blm = rs.getBusinessLifeCycleManager();
//Adding the category as prefix for the name
Service service = blm.createService(blm.createInternationalString("Registry Test ServiceName"));
service.setDescription(blm.createInternationalString("Registry Test Service Description"));
Collection<String> findQualifiers = new ArrayList<String>();
findQualifiers.add(FindQualifier.AND_ALL_KEYS);
findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
ClassificationScheme cScheme = bqm.findClassificationSchemeByName(findQualifiers, "org.jboss.soa.esb.:testcategory");
Classification classification = blm.createClassification(cScheme, "category", "registry");
service.addClassification(classification);
organization.addService(service);
Collection<Service> services = new ArrayList<Service>();
services.add(service);
BulkResponse br = blm.saveServices(services);
assertEquals(BulkResponse.STATUS_SUCCESS, br.getStatus());
} catch (JAXRException je) {
fail(je.getMessage());
}
//find Service
try
{
RegistryService rs = connection.getRegistryService();
bqm = rs.getBusinessQueryManager();
blm = rs.getBusinessLifeCycleManager();
Finder finder = new Finder(bqm, uddiversion);
//Find the service
Service service = finder.findService("registry","Registry Test ServiceName", blm);
assertEquals("Registry Test ServiceName", service.getName().getValue());
} catch (JAXRException je) {
fail(je.getMessage());
}
//publish serviceBinding
try {
RegistryService rs = connection.getRegistryService();
bqm = rs.getBusinessQueryManager();
blm = rs.getBusinessLifeCycleManager();
Finder finder = new Finder(bqm, uddiversion);
//Find the service
Service service = finder.findService("registry","Registry Test ServiceName", blm);
ServiceBinding serviceBinding = blm.createServiceBinding();
serviceBinding.setDescription(blm.createInternationalString("eprDescription"));
String xml = "<epr>epr uri</epr>";
serviceBinding.setAccessURI(xml);
ArrayList<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
serviceBindings.add(serviceBinding);
service.addServiceBindings(serviceBindings);
Collection<String> findQualifiers = new ArrayList<String>();
findQualifiers.add(FindQualifier.AND_ALL_KEYS);
findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
ClassificationScheme cScheme = bqm.findClassificationSchemeByName(findQualifiers, "org.jboss.soa.esb.:testcategory");
Classification classification = blm.createClassification(cScheme, "category", "registry");
service.addClassification(classification);
BulkResponse br = blm.saveServiceBindings(serviceBindings);
assertEquals(BulkResponse.STATUS_SUCCESS, br.getStatus());
BulkResponse br2 = blm.saveServiceBindings(serviceBindings); //Save one more
assertEquals(BulkResponse.STATUS_SUCCESS, br2.getStatus());
//Delete one binding
Collection<ServiceBinding> serviceBindings2 = finder.findServiceBindings(service.getKey(),classification);
if ((serviceBindings2 != null) && (serviceBindings2.iterator() != null)
&& (serviceBindings2.iterator().hasNext())) {