Source:
private void saveEndpointTemplate(OMElement templateElement) throws AxisFault { final Lock lock = getLock(); try { lock.lock(); if (templateElement != null && templateElement.getLocalName().equals( XMLConfigConstants.TEMPLATE_ELT.getLocalPart())) { String templateName = templateElement.getAttributeValue(new QName("name")); SynapseConfiguration config = getSynapseConfiguration(); log.debug("Saving template : " + templateName); Template preSeq = config.getEndpointTemplates().get(templateName); if (preSeq == null) { handleException("Unable to save template " + templateName + ". Does not exist"); } else { Template endpointTemplate = new TemplateFactory().createEndpointTemplate( templateElement, getSynapseConfiguration().getProperties()); config.removeEndpointTemplate(templateName); if (endpointTemplate instanceof Template) { ((Template) endpointTemplate).setFileName(preSeq.getFileName()); config.addEndpointTemplate(templateName, endpointTemplate); } log.debug("Saved template : " + templateName + " to the configuration"); Template templ = config.getEndpointTemplates().get(templateName); if (templ != null) { CAppArtifactDataService cAppArtifactDataService = ConfigHolder.getInstance(). getcAppArtifactDataService(); if (cAppArtifactDataService.isArtifactDeployedFromCApp(getTenantId(), ServiceBusConstants.TEMPLATE_TYPE + File.separator + templateName)) { cAppArtifactDataService.setEdited(getTenantId(), ServiceBusConstants.TEMPLATE_TYPE + File.separator + templateName); } else { persistTemplate(templ); } } } } else { handleException("Unable to save template. Invalid definition"); } } catch (Exception fault) { handleException("Unable to save the Template : " + fault.getMessage(), fault); } finally { lock.unlock(); } }

Target:
private void saveEndpointTemplate(OMElement templateElement) throws AxisFault { final Lock lock = getLock(); try { lock.lock(); if (templateElement != null && templateElement.getLocalName().equals( XMLConfigConstants.TEMPLATE_ELT.getLocalPart())) { String templateName = templateElement.getAttributeValue(new QName("name")); SynapseConfiguration config = getSynapseConfiguration(); log.debug("Saving template : " + templateName); Template preSeq = config.getEndpointTemplates().get(templateName); if (preSeq == null) { handleException("Unable to save template " + templateName + ". Does not exist"); } else { Template endpointTemplate = new TemplateFactory().createEndpointTemplate( templateElement, getSynapseConfiguration().getProperties()); config.removeEndpointTemplate(templateName); if (endpointTemplate instanceof Template) { ((Template) endpointTemplate).setFileName(preSeq.getFileName()); config.addEndpointTemplate(templateName, endpointTemplate); } log.debug("Saved template : " + templateName + " to the configuration"); Template templ = config.getEndpointTemplates().get(templateName); if (templ != null) { String artifactName = getArtifactName(artifactType, templateName); CAppArtifactDataService cAppArtifactDataService = ConfigHolder.getInstance().getcAppArtifactDataService(); if (cAppArtifactDataService.isArtifactDeployedFromCApp(getTenantId(), artifactName)) { cAppArtifactDataService.setEdited(getTenantId(), artifactName); } else { persistTemplate(templ); } } } } else { handleException("Unable to save template. Invalid definition"); } } catch (Exception fault) { handleException("Unable to save the Template : " + fault.getMessage(), fault); } finally { lock.unlock(); } }