Search in sources :

Example 36 with ConfigContext

use of org.wso2.carbon.apimgt.impl.template.ConfigContext in project carbon-apimgt by wso2.

the class SequenceUtils method getSequenceTemplateConfigContext.

/**
 * Gets the velocity template config context with sequence data populated
 *
 * @param soapToRestMediationDtoList registry resource path
 * @param seqType                    sequence type whether in or out sequence
 * @param configContext              velocity template config context
 * @return {@link ConfigContext} sequences populated velocity template config context
 */
public static ConfigContext getSequenceTemplateConfigContext(List<SoapToRestMediationDto> soapToRestMediationDtoList, String seqType, ConfigContext configContext) {
    if (soapToRestMediationDtoList.size() > 0) {
        JSONObject pathObj = new JSONObject();
        for (SoapToRestMediationDto soapToRestMediationDto : soapToRestMediationDtoList) {
            String method = soapToRestMediationDto.getMethod();
            String resourceName = soapToRestMediationDto.getResource();
            JSONObject contentObj = new JSONObject();
            contentObj.put(method, soapToRestMediationDto.getContent());
            pathObj.put(SOAPToRESTConstants.SequenceGen.PATH_SEPARATOR.concat(resourceName), contentObj);
        }
        configContext = new SOAPToRESTAPIConfigContext(configContext, pathObj, seqType);
    }
    return configContext;
}
Also used : SOAPToRESTAPIConfigContext(org.wso2.carbon.apimgt.rest.api.publisher.v1.common.template.SOAPToRESTAPIConfigContext) JSONObject(org.json.simple.JSONObject) SoapToRestMediationDto(org.wso2.carbon.apimgt.impl.dto.SoapToRestMediationDto)

Aggregations

VelocityContext (org.apache.velocity.VelocityContext)18 Test (org.junit.Test)17 APIConfigContext (org.wso2.carbon.apimgt.rest.api.publisher.v1.common.template.APIConfigContext)17 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)16 ConfigContext (org.wso2.carbon.apimgt.rest.api.publisher.v1.common.template.ConfigContext)16 API (org.wso2.carbon.apimgt.api.model.API)14 StringWriter (java.io.StringWriter)11 VelocityEngine (org.apache.velocity.app.VelocityEngine)11 Template (org.apache.velocity.Template)9 HashMap (java.util.HashMap)8 Map (java.util.Map)6 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)6 EndpointSecurityModel (org.wso2.carbon.apimgt.rest.api.publisher.v1.common.template.EndpointSecurityModel)6 SecurityConfigContext (org.wso2.carbon.apimgt.rest.api.publisher.v1.common.template.SecurityConfigContext)6 APITemplateException (org.wso2.carbon.apimgt.impl.template.APITemplateException)4 ConfigContext (org.wso2.carbon.apimgt.impl.template.ConfigContext)4 ArrayList (java.util.ArrayList)3 ParseErrorException (org.apache.velocity.exception.ParseErrorException)3 ResourceNotFoundException (org.apache.velocity.exception.ResourceNotFoundException)3 ClasspathResourceLoader (org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader)3