<commit_before>package de.kisi.android.api.calls;

import org.json.JSONObject;

import android.util.Log;

import com.loopj.android.http.JsonHttpResponseHandler;

import de.kisi.android.rest.KisiRestClient;

public abstract class GenericCall {

	protected JsonHttpResponseHandler handler;
	protected String path;
	protected JSONObject json;
	protected HTTPMethod method;
	
	protected GenericCall(String path, HTTPMethod method) {
		this.path = path;
		this.method = method;
	}
	
	protected void createJson() {
		this.json = new JSONObject();
	}
	
	public void send() {
		final GenericCall call = this;
		createJson();
		JsonHttpResponseHandler realHandler = new JsonHttpResponseHandler() {
			
			@Override
			public void onSuccess(JSONObject response) {
				Log.d("GenericCall", "call success");
				if (call.handler != null) {
					call.handler.onSuccess(response);
				}
			}	
			
			public void onFailure(int statusCode, Throwable e, JSONObject response) {
				if (call.handler != null) {
					call.handler.onFailure(statusCode, e, response);
				}
			}
		};
		
		switch (this.method) {
		case GET:
			KisiRestClient.getInstance().get(path, realHandler);
			break;
		case POST:
			KisiRestClient.getInstance().post(path, json, realHandler);
			break;
		case DELETE:
			KisiRestClient.getInstance().delete(path,  realHandler);
			break;
		default:
			throw new RuntimeException("Unsupported HttpMethod");
		}
	}<commit_msg>Bugfix<commit_after>package de.kisi.android.api.calls;

import org.json.JSONArray;
import org.json.JSONObject;

import android.util.Log;

import com.loopj.android.http.JsonHttpResponseHandler;

import de.kisi.android.rest.KisiRestClient;

public abstract class GenericCall {

	protected JsonHttpResponseHandler handler;
	protected String path;
	protected JSONObject json;
	protected HTTPMethod method;
	
	protected GenericCall(String path, HTTPMethod method) {
		this.path = path;
		this.method = method;
	}
	
	protected void createJson() {
		this.json = new JSONObject();
	}
	
	public void send() {
		final GenericCall call = this;
		createJson();
		JsonHttpResponseHandler realHandler = new JsonHttpResponseHandler() {
			
			@Override
			public void onSuccess(JSONObject response) {
				Log.d("GenericCall", "call success: " + response.toString());
				if (call.handler != null) {
					call.handler.onSuccess(response);
				}
			}	
			
			public void onFailure(int statusCode, Throwable e, JSONObject response) {
				Log.d("GenericCall", "call failed: "+response.toString());
				if (call.handler != null) {
					call.handler.onFailure(statusCode, e, response);
				}
			}
			@Override
			public void onSuccess(JSONArray response) {
				Log.d("GenericCall", "call success: " + response.toString());
				if (call.handler != null) {
					call.handler.onSuccess(response);
				}
			}	
			
			public void onFailure(int statusCode, Throwable e, JSONArray response) {
				Log.d("GenericCall", "call failed: "+response.toString());
				if (call.handler != null) {
					call.handler.onFailure(statusCode, e, response);
				}
			}
		};
		
		switch (this.method) {
		case GET:
			KisiRestClient.getInstance().get(path, realHandler);
			break;
		case POST:
			KisiRestClient.getInstance().post(path, json, realHandler);
			break;
		case DELETE:
			KisiRestClient.getInstance().delete(path,  realHandler);
			break;
		default:
			throw new RuntimeException("Unsupported HttpMethod");
		}
	}
{'fraction_non_alphanumeric': 0.11479741632413389, 'fraction_numerical': 0.0, 'mean_word_length': 3.867142857142857, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1781401', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1027, 'n_words': 242}