log.debug("Template update from file : " + fileName + " has started");
}
try {
OMElement element = artifactConfig.getFirstChildWithName(
new QName(SynapseConstants.SYNAPSE_NAMESPACE, "endpoint"));
if (element != null) {
org.apache.synapse.config.xml.endpoints.TemplateFactory templateFactory =
new org.apache.synapse.config.xml.endpoints.TemplateFactory();
Template tm = templateFactory.createEndpointTemplate(artifactConfig, properties);
tm.setFileName(new File(fileName).getName());
if (log.isDebugEnabled()) {
log.debug("Endpoint Template named '" + tm.getName()
+ "' has been built from the file " + fileName);
}
Template existingSt = getSynapseConfiguration().
getEndpointTemplate(existingArtifactName);
if (existingArtifactName.equals(tm.getName())) {
getSynapseConfiguration().updateEndpointTemplate(tm.getName(), existingSt);
} else {
getSynapseConfiguration().addEndpointTemplate(tm.getName(), tm);
getSynapseConfiguration().removeEndpointTemplate(existingSt.getName());
log.info("Template: " + existingArtifactName + " has been undeployed");
}
log.info("Template: " + tm.getName() + " has been updated from the file: " + fileName);
return tm.getName();
} else {
element = artifactConfig.getFirstChildWithName(
new QName(SynapseConstants.SYNAPSE_NAMESPACE, "sequence"));
if (element != null) {
Mediator mediator = MediatorFactoryFinder.getInstance().
getMediator(artifactConfig, properties);
if (mediator instanceof TemplateMediator) {
TemplateMediator tm = (TemplateMediator) mediator;