/**
 * @Author Jack W Finlay - jfin404@aucklanduni.ac.nz
 */
import com.google.api.client.http.*;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.util.Key;
import scriptella.spi.*;

import java.io.IOException;

public class HTTPConnection extends AbstractConnection {
    private String HOST;
    private String BODY;
    private String TYPE;
    private int    TIME_OUT;
    private final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();

    public HTTPConnection () {} // Override default constructor

    public HTTPConnection( ConnectionParameters connectionParameters ){
        HOST = connectionParameters.getStringProperty("url");
        TYPE = connectionParameters.getStringProperty("type");
        TIME_OUT = connectionParameters.getIntegerProperty("timeout");

    }

    @Override
    public void executeScript(Resource resource, ParametersCallback parametersCallback) throws ProviderException {


    }

    @Override
    public void executeQuery(Resource resource, ParametersCallback parametersCallback, QueryCallback queryCallback) throws ProviderException {
        //return HTTP with body contents
        HttpRequestFactory requestFactory =
                HTTP_TRANSPORT.createRequestFactory(new HttpRequestInitializer() {
                    @Override
                    public void initialize(HttpRequest request) {
                        request.setConnectTimeout(TIME_OUT);
                    }
                });

        HttpRequest request;

        HTTPUrl url = new HTTPUrl(HOST);
        //url.fields =

        try {
            if (TYPE.equals("GET")) {

                request = requestFactory.buildGetRequest(url);
            } else if (TYPE.equals("POST")) {

                //request = requestFactory.buildPostRequest(HOST, new HttpCo);
            }

            //HttpResponse httpResponse = request.execute();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    @Override
    public void close(){

    }

    public static class HTTPUrl extends GenericUrl {

        public HTTPUrl(String encodedUrl) {
            super(encodedUrl);
        }

        @Key
        public String fields;
    }


}

@@ -190,16 +190,73 @@
 il.Key;%0A
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A
 import s
@@ -481,16 +481,17 @@
 e final 
+ 
 HttpTran
@@ -536,16 +536,119 @@
 sport();
+%0A    private HttpResponse httpResponse;%0A%0A    Logger logger = LoggerFactory.getLogger(%22HttpConnection%22);
 %0A%0A    pu
@@ -1031,32 +1031,37 @@
 pt(Resource 
-resource
+scriptContent
 , Parameters
@@ -1116,17 +1116,43 @@
 ption %7B%0A
-%0A
+        run(scriptContent);
 %0A    %7D%0A%0A
@@ -1207,16 +1207,20 @@
 rce 
-resource
+queryContent
 , Pa
@@ -1353,16 +1353,65 @@
 ontents%0A
+    %7D%0A%0A    private void run(Resource resource)%7B%0A%0A
         
@@ -1803,31 +1803,8 @@
 ST);
-%0A        //url.fields =
 %0A%0A  
@@ -1849,24 +1849,126 @@
 s(%22GET%22)) %7B%0A
+                url.fields = resource.toString();%0A%0A                logger.info(%22Query URL: %7B%7D%22, url );
 %0A           
@@ -2038,16 +2038,20 @@
  %7D else 
+%7B //
 if (TYPE
@@ -2090,68 +2090,206 @@
     
-//request = requestFactory.buildPostRequest(HOST, new HttpCo
+HttpContent httpContent = (HttpContent) resource;%0A%0A                request = requestFactory.buildPostRequest(url, httpContent);%0A                logger.info(%22Request response: %7B%7D%22, request.toString()
 );%0A 
@@ -2318,23 +2318,8 @@
     
-//HttpResponse 
 http
@@ -2426,24 +2426,24 @@
       %7D%0A
+%0A
     %7D%0A%0A
-%0A
     @Ove

Update HTTPConnection.java