use of org.eclipse.winery.model.tosca.TTopologyTemplate in project winery by eclipse.
the class WineryRepositoryClient method getTopologyTemplate.
@Override
public TTopologyTemplate getTopologyTemplate(QName serviceTemplate, String parentPath, String elementPath) {
// we try all repositories until the first hit
for (WebResource wr : this.repositoryResources) {
WebResource r = WineryRepositoryClient.getTopologyTemplateWebResource(wr, serviceTemplate, parentPath, elementPath);
ClientResponse response = r.accept(MediaType.TEXT_XML).get(ClientResponse.class);
if (response.getClientResponseStatus() == ClientResponse.Status.OK) {
TTopologyTemplate topologyTemplate;
Document doc = this.parseAndValidateTOSCAXML(response.getEntityInputStream());
if (doc == null) {
// no valid document
return null;
}
try {
topologyTemplate = WineryRepositoryClient.createUnmarshaller().unmarshal(doc.getDocumentElement(), TTopologyTemplate.class).getValue();
} catch (JAXBException e) {
LOGGER.debug("Could not parse topology, returning null", e);
return null;
}
// first hit: immediately stop and return result
return topologyTemplate;
}
}
// nothing found
return null;
}
Aggregations