Android Open Source - Icinga-Mobile Icinga Executor

From Project

Back to project page Icinga-Mobile.


The source code is released under:

GNU General Public License

If you think the Android project Icinga-Mobile listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package mhst.dreamteam.IcingaClient.Icinga;
//w  w w . ja v a2s .  c  o m
import android.os.AsyncTask;
import android.util.Log;

import org.apache.http.HttpStatus;

import java.util.HashMap;
import java.util.Map;

import mhst.dreamteam.IcingaClient.Controller.NetController;
import mhst.dreamteam.IcingaClient.Interface.OnCompleteListener;
import mhst.dreamteam.IcingaClient.SessionMng.Session;

 * Execute Icinga Api request. This class uses to send request to server and get raw response String.
 * Uses IcingaApi to parse the response data.
 * @author MinhNN
 * @see mhst.dreamteam.IcingaClient.Icinga.IcingaApi
public class IcingaExecutor extends AsyncTask<String, Void, String> {
    private OnCompleteListener mListener;

    public IcingaExecutor(OnCompleteListener listener) {
        mListener = listener;

    protected String doInBackground(String... params) {
        // Get current application session
        Session AppSession = Session.getInstance();

        // Check if user is logged in or if session has cookie
        if (!AppSession.isLogin()) return null;
        if (AppSession.getCookie() == null) return null;

        // Properties for request
        Map<String, String> prop = new HashMap<String, String>();
        if (AppSession.getCookie() != null) {
            prop.put("Cookie", AppSession.getCookie());

        // Parse api uri (for further use)
        String Uri = AppSession.getWorkingServer() + params[0];

        // Send request and get response
        String result;
        Log.i("Icinga Executor", Uri);
        Map<String, Object> response = NetController.sendRequest("GET", Uri, null, prop);
        if (response.containsKey("Code")) {
            if (((Integer) response.get("Code")) == HttpStatus.SC_OK) {
                if (response.containsKey("Data")) {
                    result = (String) response.get("Data");
                    if (result != null) return result;
        return null;

    protected void onPostExecute(String result) {
        if (mListener != null) {
            mListener.onComplete(result, "IcingaExecutor");

Java Source Code List