use of org.apache.synapse.config.xml.TemplateMediatorSerializer in project wso2-synapse by wso2.
the class TemplateDeployer method restoreSynapseArtifact.
@Override
public void restoreSynapseArtifact(String artifactName) {
if (log.isDebugEnabled()) {
log.debug("Restoring the Template with name : " + artifactName + " : Started");
}
try {
Template st = getSynapseConfiguration().getEndpointTemplate(artifactName);
if (st != null) {
TemplateSerializer ts = new TemplateSerializer();
OMElement stElem = ts.serializeEndpointTemplate(st, null);
if (st.getFileName() != null) {
String fileName = getServerConfigurationInformation().getSynapseXMLLocation() + File.separator + MultiXMLConfigurationBuilder.TEMPLATES_DIR + File.separator + st.getFileName();
writeToFile(stElem, fileName);
if (log.isDebugEnabled()) {
log.debug("Restoring the Endpoint Template with name : " + artifactName + " : Completed");
}
log.info("Template named '" + artifactName + "' has been restored");
}
} else {
TemplateMediator mt = getSynapseConfiguration().getSequenceTemplate(artifactName);
if (mt != null) {
TemplateMediatorSerializer ts = new TemplateMediatorSerializer();
OMElement stElem = ts.serializeMediator(null, mt);
if (mt.getFileName() != null) {
String fileName = getServerConfigurationInformation().getSynapseXMLLocation() + File.separator + MultiXMLConfigurationBuilder.TEMPLATES_DIR + File.separator + st.getFileName();
writeToFile(stElem, fileName);
if (log.isDebugEnabled()) {
log.debug("Restoring the Sequence Template with name : " + artifactName + " : Completed");
}
log.info("Template named '" + artifactName + "' has been restored");
}
} else {
handleSynapseArtifactDeploymentError("Couldn't restore the Template named '" + artifactName + "', filename cannot be found");
}
}
} catch (Exception e) {
handleSynapseArtifactDeploymentError("Restoring of the Template named '" + artifactName + "' has failed", e);
}
}
Aggregations