use of org.eclipse.winery.model.tosca.TEntityTemplate.Properties in project winery by eclipse.
the class GenericArtifactsResource method storeProperties.
private void storeProperties(ArtifactTemplateId artifactTemplateId, DefinitionsChildId typeId, String name) {
// We generate the properties by hand instead of using JAX-B as using JAX-B causes issues at org.eclipse.winery.common.ModelUtilities.getPropertiesKV(TEntityTemplate):
// getAny() does not always return "w3c.dom.element" anymore
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
try {
builder = dbf.newDocumentBuilder();
} catch (ParserConfigurationException e) {
GenericArtifactsResource.LOGGER.error(e.getMessage(), e);
return;
}
Document doc = builder.newDocument();
String namespace = QNames.QNAME_ARTIFACT_TYPE_WAR.getNamespaceURI();
Element root = doc.createElementNS(namespace, "WSProperties");
doc.appendChild(root);
Element element = doc.createElementNS(namespace, "ServiceEndpoint");
Text text = doc.createTextNode("/services/" + name + "Port");
element.appendChild(text);
root.appendChild(element);
element = doc.createElementNS(namespace, "PortType");
text = doc.createTextNode("{" + typeId.getNamespace().getDecoded() + "}" + name);
element.appendChild(text);
root.appendChild(element);
element = doc.createElementNS(namespace, "InvocationType");
text = doc.createTextNode("SOAP/HTTP");
element.appendChild(text);
root.appendChild(element);
Properties properties = new Properties();
properties.setAny(root);
final IRepository repository = RepositoryFactory.getRepository();
final TArtifactTemplate artifactTemplate = repository.getElement(artifactTemplateId);
artifactTemplate.setProperties(properties);
try {
repository.setElement(artifactTemplateId, artifactTemplate);
} catch (IOException e) {
throw new WebApplicationException(e);
}
}
Aggregations