Java Code Examples for org.wso2.carbon.apimgt.api.model.API#getContext()

The following examples show how to use org.wso2.carbon.apimgt.api.model.API#getContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: APIGatewayManager.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
/**
 * create body of sequence
 *
 * @param api
 * @param url
 * @return
 */
public String createSeqString(API api, String url, String urltype) throws JSONException  {

    String context = api.getContext();
    context = urltype + context;
    String[] endpointConfig = websocketEndpointConfig(api, urltype);
    String timeout = endpointConfig[0];
    String suspendOnFailure = endpointConfig[1];
    String markForSuspension = endpointConfig[2];
    String endpointConf = "<default>\n" +
            "\t<timeout>\n" +
            timeout +
            "\t</timeout>\n" +
            "\t<suspendOnFailure>\n" +
            suspendOnFailure + "\n" +
            "\t</suspendOnFailure>\n" +
            "\t<markForSuspension>\n" +
            markForSuspension +
            "\t</markForSuspension>\n" +
            "</default>";
    String seq = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
            "<sequence xmlns=\"http://ws.apache.org/ns/synapse\" name=\"" +
            context.replace('/', '-') + "\">\n" +
            "   <property name=\"OUT_ONLY\" value=\"true\"/>\n" +
            "   <script language=\"js\">var sub_path = mc.getProperty(\"websocket.subscriber.path\");\t    \n" +
            "        \tvar queryParamString = sub_path.split(\"\\\\?\")[1];\n" +
            "                if(queryParamString != undefined) {\t    \n" +
            "\t\tmc.setProperty('queryparams', \"?\" + queryParamString);\n" +
            "\t\t}\t\t\n" +
            "   </script>\n" +
            "   <property xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\"\n" +
            "             xmlns:ns=\"http://org.apache.synapse/xsd\"\n" +
            "             xmlns:ns3=\"http://org.apache.synapse/xsd\"\n" +
            "             name=\"queryparams\"\n" +
            "             expression=\"$ctx:queryparams\"/>\n" +
            "   <property name=\"urlVal\" value=\""+ url + "\"/>\n" +
            "   <property xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\"\n" +
            "             xmlns:ns3=\"http://org.apache.synapse/xsd\"\n" +
            "             name=\"fullUrl\"\n" +
            "             expression=\"fn:concat(get-property('urlVal'), get-property('queryparams'))\"\n" +
            "             type=\"STRING\"/>\n" +
            "   <header xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\"\n" +
            "           xmlns:ns3=\"http://org.apache.synapse/xsd\"\n" +
            "           name=\"To\"\n" +
            "           expression=\"$ctx:fullUrl\"/>\n" +
            "   <send>\n" +
            "      <endpoint>\n" +
            endpointConf + "\n" +
            "      </endpoint>\n" +
            "   </send>\n" +
            "</sequence>";
    return seq;
}
 
Example 2
Source File: OAS3Parser.java    From carbon-apimgt with Apache License 2.0 3 votes vote down vote up
/**
 * Update OAS definition with GW endpoints
 *
 * @param api               API
 * @param hostsWithSchemes  GW hosts with protocol mapping
 * @param openAPI           OpenAPI
 */
private void updateEndpoints(API api, Map<String, String> hostsWithSchemes, OpenAPI openAPI) {

    String basePath = api.getContext();
    String transports = api.getTransports();
    updateEndpoints(openAPI, basePath, transports, hostsWithSchemes);
}
 
Example 3
Source File: OAS2Parser.java    From carbon-apimgt with Apache License 2.0 2 votes vote down vote up
/**
 * Update OAS definition with GW endpoints
 *
 * @param api            API
 * @param hostsWithSchemes  GW hosts with protocol mapping
 * @param swagger        Swagger
 */
private void updateEndpoints(API api, Map<String,String> hostsWithSchemes, Swagger swagger) {
    String basePath = api.getContext();
    String transports = api.getTransports();
    updateEndpoints(swagger, basePath, transports, hostsWithSchemes);
}