return address;
}
public static BindingTemplate getBindingTemplateFromJAXRSB(
ServiceBinding serve) throws JAXRException {
BindingTemplate bt = BindingTemplate.Factory.newInstance();
if (serve.getKey() != null && serve.getKey().getId() != null) {
bt.setBindingKey(serve.getKey().getId());
} else {
bt.setBindingKey("");
}
try {
// Set Access URI
String accessuri = serve.getAccessURI();
if (accessuri != null) {
AccessPoint ap = AccessPoint.Factory.newInstance();
ap.setURLType(getURLType(accessuri));
ap.setStringValue(accessuri);
bt.setAccessPoint(ap);
}
ServiceBinding sb = serve.getTargetBinding();
if (sb != null) {
HostingRedirector red = HostingRedirector.Factory.newInstance();
Key key = sb.getKey();
if (key != null && key.getId() != null) {
red.setBindingKey(key.getId());
} else {
red.setBindingKey("");
}
bt.setHostingRedirector(red);
} else {
if (bt.getAccessPoint() == null) {
bt.setAccessPoint(AccessPoint.Factory.newInstance());
}
}
// TODO:Need to look further at the mapping b/w BindingTemplate and
// Jaxr ServiceBinding
// Get Service information
Service svc = serve.getService();
if (svc != null && svc.getKey() != null && svc.getKey().getId() != null) {
bt.setServiceKey(svc.getKey().getId());
}
InternationalString idesc = ((RegistryObject) serve).getDescription();
if (idesc != null) {
for (LocalizedString locName : idesc.getLocalizedStrings()) {
Description desc = bt.addNewDescription();
desc.setStringValue(locName.getValue());
desc.setLang(locName.getLocale().getLanguage());
}
}
// SpecificationLink
Collection<SpecificationLink> slcol = serve.getSpecificationLinks();
TModelInstanceDetails tid = TModelInstanceDetails.Factory
.newInstance();
if (slcol != null && !slcol.isEmpty()) {
Iterator<SpecificationLink> iter = slcol.iterator();
while (iter.hasNext()) {
SpecificationLink slink = (SpecificationLink) iter.next();
TModelInstanceInfo emptyTInfo = tid
.addNewTModelInstanceInfo();
RegistryObject specificationObject = slink.getSpecificationObject();
if (specificationObject.getKey() != null && specificationObject.getKey().getId() != null) {
emptyTInfo.setTModelKey(specificationObject.getKey().getId());
if (specificationObject.getDescription()!=null) {
for (LocalizedString locDesc : specificationObject.getDescription().getLocalizedStrings()) {
Description description = emptyTInfo.addNewDescription();
description.setStringValue(locDesc.getValue());
description.setLang(locDesc.getLocale().getLanguage());
}
}
Collection<ExternalLink> externalLinks = slink.getExternalLinks();
if (externalLinks!=null && externalLinks.size()>0) {
for (ExternalLink link : externalLinks) {
InstanceDetails ids = emptyTInfo.addNewInstanceDetails();
if (link.getDescription()!=null) {
Description description = ids.addNewDescription();
description.setStringValue(link.getDescription().getValue());
}
if (link.getExternalURI()!=null) {
OverviewDoc overviewDoc = ids.addNewOverviewDoc();
overviewDoc.setOverviewURL(link.getExternalURI());
}
}
}
}
}
}
bt.setTModelInstanceDetails(tid);
log.debug("BindingTemplate=" + bt.toString());
} catch (Exception ud) {
throw new JAXRException("Apache JAXR Impl:", ud);
}
return bt;
}