public void registerEPR(String category, String serviceName, String serviceDescription, EPR epr, String eprDescription)
throws RegistryException
{
if (category == null)
{
throw new RegistryException("Null Category argument specified") ;
}
if (serviceName == null)
{
throw new RegistryException("Null Service Name argument specified") ;
}
if (epr == null)
{
throw new RegistryException("Null EPR argument specified") ;
}
Connection connection = JAXRConnectionSingleton.getConnection(jaxrConnectionFactory);
try {
final Concept jbossTModel = getJBossESBTModel(connection);
//Find the service
Service service = findService(category,serviceName);
if (service==null) {
logger.log(Level.DEBUG, "Service " + serviceName + " does not yet exist, creating now..");
service = registerService(category, serviceName, serviceDescription);
}
RegistryService rs = connection.getRegistryService();
BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
BusinessQueryManager bqm = rs.getBusinessQueryManager();
ServiceBinding serviceBinding = blm.createServiceBinding();
String xml = EPRHelper.toXMLString(epr);
serviceBinding.setAccessURI(xml);
ArrayList<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
SpecificationLink sl = new SpecificationLinkImpl(blm);
sl.setSpecificationObject(jbossTModel);
serviceBinding.getSpecificationLinks().add(sl);
if (isV3 && ((eprDescription == null) || ("".equals(eprDescription)))) {
serviceBinding.setDescription(blm.createInternationalString(REGISTERED_BY_JBOSSESB));
} else {
serviceBinding.setDescription(blm.createInternationalString(eprDescription));
}
serviceBindings.add(serviceBinding);
service.addServiceBindings(serviceBindings);
ClassificationScheme cScheme = getClassificationScheme(bqm, blm);
Classification classification = blm.createClassification(cScheme, "category", category);
service.addClassification(classification);
saveRegistryObject(serviceBinding, jaxrConnectionFactory);
} catch (JAXRException je) {
throw new RegistryException(je.getLocalizedMessage(), je);
} catch (MarshalException me) {
throw new RegistryException(me.getLocalizedMessage(), me);
} finally {
JAXRConnectionSingleton.recycleConnection(jaxrConnectionFactory, connection);
}
}