Search in sources :

Example 1 with TemplateMediatorSerializer

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);
    }
}
Also used : TemplateMediator(org.apache.synapse.mediators.template.TemplateMediator) TemplateMediatorSerializer(org.apache.synapse.config.xml.TemplateMediatorSerializer) TemplateSerializer(org.apache.synapse.config.xml.endpoints.TemplateSerializer) OMElement(org.apache.axiom.om.OMElement) SynapseException(org.apache.synapse.SynapseException) DeploymentException(org.apache.axis2.deployment.DeploymentException) Template(org.apache.synapse.endpoints.Template)

Aggregations

OMElement (org.apache.axiom.om.OMElement)1 DeploymentException (org.apache.axis2.deployment.DeploymentException)1 SynapseException (org.apache.synapse.SynapseException)1 TemplateMediatorSerializer (org.apache.synapse.config.xml.TemplateMediatorSerializer)1 TemplateSerializer (org.apache.synapse.config.xml.endpoints.TemplateSerializer)1 Template (org.apache.synapse.endpoints.Template)1 TemplateMediator (org.apache.synapse.mediators.template.TemplateMediator)1