Example usage for android.net ParseException printStackTrace

List of usage examples for android.net ParseException printStackTrace

Introduction

In this page you can find the example usage for android.net ParseException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.letsgood.synergykitsdkandroid.builders.ResultObjectBuilder.java

public static SynergykitObject buildObject(int statusCode, BufferedReader data, Type type) {

    // Param check
    if (data == null || statusCode != HttpStatus.SC_OK)
        return null;

    // Build object
    try {/*from w w  w .  jav  a2 s  .c  o  m*/
        return (SynergykitObject) GsonWrapper.getGson().fromJson(data, type);
    } catch (ParseException e) {
        e.printStackTrace();
    }

    return null;
}

From source file:com.letsgood.synergykitsdkandroid.builders.ResultObjectBuilder.java

public static SynergykitObject[] buildObjects(int statusCode, BufferedReader data, Type type) {
    SynergykitObject[] baseObjects;//from   w  w w . jav  a2 s  .c  om

    // Param check
    if (data == null || statusCode != HttpStatus.SC_OK)
        return null;

    // Build objects
    try {
        baseObjects = (SynergykitObject[]) GsonWrapper.getGson().fromJson(data, type);

        return baseObjects;

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

    return null;
}

From source file:com.letsgood.synergykitsdkandroid.builders.ResultObjectBuilder.java

public static SynergykitError buildError(int statusCode, BufferedReader data) {
    SynergykitError errorObject;//w w  w  .  j a  v a 2s  .com

    // Param check
    if (data == null)
        return null;

    // Build error
    try {
        errorObject = (SynergykitError) GsonWrapper.getGson().fromJson(data, SynergykitError.class);
        errorObject.setStatusCode(statusCode);
        return errorObject;

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

    return null;
}

From source file:org.wso2.cdm.agent.utils.HTTPConnectorUtils.java

public static String getResponseBody(HttpResponse response) {

    String response_text = null;//ww w . j ava 2  s. c  om
    HttpEntity entity = null;
    try {
        entity = response.getEntity();
        response_text = readResponseBody(entity);
    } catch (ParseException e) {
        e.printStackTrace();
    } catch (IOException e) {
        if (entity != null) {
            try {
                entity.consumeContent();
            } catch (IOException e1) {
            }
        }
    }
    return response_text;
}

From source file:com.mhise.util.MHISEUtil.java

public static String getResponseBody(HttpResponse response) {

    String response_text = null;/* w w  w .j  a  va2  s .  c o  m*/

    HttpEntity entity = null;

    try {

        entity = response.getEntity();

        response_text = _getResponseBody(entity);

    } catch (ParseException e) {

        e.printStackTrace();

    } catch (IOException e) {

        if (entity != null) {

            try {

                entity.consumeContent();

            } catch (IOException e1) {

            }

        }

    }

    return response_text;

}

From source file:android.net.http.RequestHandle.java

/**
 * Create and queue a redirect request./*  ww w. j a v  a2  s. co  m*/
 *
 * @param redirectTo URL to redirect to
 * @param statusCode HTTP status code returned from original request
 * @param cacheHeaders Cache header for redirect URL
 * @return true if setup succeeds, false otherwise (redirect loop
 * count exceeded, body provider unable to rewind on 307 redirect)
 */
public boolean setupRedirect(String redirectTo, int statusCode, Map<String, String> cacheHeaders) {
    if (HttpLog.LOGV) {
        HttpLog.v("RequestHandle.setupRedirect(): redirectCount " + mRedirectCount);
    }

    // be careful and remove authentication headers, if any
    mHeaders.remove(AUTHORIZATION_HEADER);
    mHeaders.remove(PROXY_AUTHORIZATION_HEADER);

    if (++mRedirectCount == MAX_REDIRECT_COUNT) {
        // Way too many redirects -- fail out
        if (HttpLog.LOGV)
            HttpLog.v("RequestHandle.setupRedirect(): too many redirects " + mRequest);
        mRequest.error(EventHandler.ERROR_REDIRECT_LOOP, com.android.internal.R.string.httpErrorRedirectLoop);
        return false;
    }

    if (mUrl.startsWith("https:") && redirectTo.startsWith("http:")) {
        // implement http://www.w3.org/Protocols/rfc2616/rfc2616-sec15.html#sec15.1.3
        if (HttpLog.LOGV) {
            HttpLog.v("blowing away the referer on an https -> http redirect");
        }
        mHeaders.remove("Referer");
    }

    mUrl = redirectTo;
    try {
        mUri = new WebAddress(mUrl);
    } catch (ParseException e) {
        e.printStackTrace();
    }

    // update the "Cookie" header based on the redirected url
    mHeaders.remove("Cookie");
    String cookie = CookieManager.getInstance().getCookie(mUri);
    if (cookie != null && cookie.length() > 0) {
        mHeaders.put("Cookie", cookie);
    }

    if ((statusCode == 302 || statusCode == 303) && mMethod.equals("POST")) {
        if (HttpLog.LOGV) {
            HttpLog.v("replacing POST with GET on redirect to " + redirectTo);
        }
        mMethod = "GET";
    }
    /* Only repost content on a 307.  If 307, reset the body
       provider so we can replay the body */
    if (statusCode == 307) {
        try {
            if (mBodyProvider != null)
                mBodyProvider.reset();
        } catch (java.io.IOException ex) {
            if (HttpLog.LOGV) {
                HttpLog.v("setupRedirect() failed to reset body provider");
            }
            return false;
        }

    } else {
        mHeaders.remove("Content-Type");
        mBodyProvider = null;
    }

    // Update the cache headers for this URL
    mHeaders.putAll(cacheHeaders);

    createAndQueueNewRequest();
    return true;
}

From source file:org.mycard.net.network.LoadListener.java

/**
 * Sets the current URL associated with this load.
 *///from   ww w  . j a v  a2  s . c o m
void setUrl(String url) {
    if (url != null) {
        mUri = null;
        if (URLUtil.isNetworkUrl(url)) {
            mUrl = URLUtil.stripAnchor(url);
            try {
                mUri = new WebAddress(mUrl);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        } else {
            mUrl = url;
        }
    }
}

From source file:android.webkit.LoadListener.java

/**
 * Sets the current URL associated with this load.
 *//*w w w .j a  v a  2s . c om*/
void setUrl(String url) {
    if (url != null) {
        if (URLUtil.isDataUrl(url)) {
            // Don't strip anchor as that is a valid part of the URL
            mUrl = url;
        } else {
            mUrl = URLUtil.stripAnchor(url);
        }
        mUri = null;
        if (URLUtil.isNetworkUrl(mUrl)) {
            try {
                mUri = new WebAddress(mUrl);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:watch.oms.omswatch.actioncenter.helpers.WatchPostAsyncTaskHelper.java

/**
 * @param clientTableName//  ww w  .  j ava 2 s. co  m
 * @param postResponse
 * @return
 */
private String processHttpURLConnectionPostResponse(String clientTableName, String postResponse) {
    String response = null;
    String jsonString = null;
    JSONObject responseJSONObject = null;

    try {
        //jsonString = EntityUtils.toString(httpEntity);

        JSONObject responseWebServiceJSON = new JSONObject(postResponse);

        responseJSONObject = responseWebServiceJSON.getJSONObject(OMSMessages.RESPONSE_STRING.getValue());
        String dbProcessDuration = responseWebServiceJSON.getString("dbprocessduration");
        String serverProcessDuration = responseWebServiceJSON.getString("serverprocessduration");

        if (!TextUtils.isEmpty(dbProcessDuration)) {
            OMSApplication.getInstance().setDatabaseProcessDuration(dbProcessDuration);
        }
        if (!TextUtils.isEmpty(serverProcessDuration)) {
            OMSApplication.getInstance().setServerProcessDuration(serverProcessDuration);
        }

        /*  "dbprocessduration": 297,
          "serverprocessduration": 297
                  
          String d*/
    } catch (JSONException jex) {
        if (jex != null
                && jex.getMessage().contains("No value for " + (OMSMessages.RESPONSE_STRING.getValue()))) {
            Log.d(TAG, "response key is not present. Assuming json response contains data set");
            // This changes are for Oasis Project. # Start
            DataParser dataParser = new DataParser(context);
            // This changes are for Oasis Project. # End
            dataParser.parseAndUpdate(jsonString);
            response = "BLPostSuccess";
        } else {
            Log.e(TAG, "Exception occurred while reading the json response. Error is:" + jex.getMessage());
        }
        return response = OMSMessages.ACTION_CENTER_FAILURE.getValue();
    } catch (ParseException e) {
        Log.e(TAG, "Exception occurred while parsing the json response. Error is:" + e.getMessage());
    }

    try {
        String code = responseJSONObject.getString(OMSMessages.CODE.getValue());
        if (code.equals(OMSMessages.DEFAULT_JSON_CODE.getValue())) {
            Log.i(TAG, "Response Message :" + responseJSONObject.getString(OMSMessages.MESSAGE.getValue()));
            double processedModifiedDate = responseJSONObject.getDouble(OMSMessages.PROCESSED_DATE.getValue());

            parseJSONObject(jsonPayLoad.toString(), OMSDatabaseConstants.STATUS_TYPE_FINISHED,
                    processedModifiedDate);
            progressString = context.getResources().getString(R.string.post_success);
            response = "BLPostSuccess";

        } else {
            Log.e(TAG, "Response Message :" + responseJSONObject.getString(OMSMessages.MESSAGE.getValue()));
            try {
                Log.e(TAG, "Response Message Additional:"
                        + responseJSONObject.getString(OMSMessages.ERROR_ADDITIONAL_MESSAGE.getValue()));
            } catch (JSONException je) {
                // ignore if field is not available
            }
            response = OMSMessages.ACTION_CENTER_FAILURE.getValue();

            ContentValues contentValues = new ContentValues();
            contentValues.put(OMSDatabaseConstants.TRANSACTION_QUEUE_STATUS,
                    OMSDatabaseConstants.ACTION_STATUS_TRIED);
            contentValues.put(OMSDatabaseConstants.TRANSACTION_QUEUE_SERVER_URL, serviceUrl);
            contentValues.put(OMSDatabaseConstants.TRANSACTION_QUEUE_DATA_TABLE_NAME, tableName);
            contentValues.put(OMSDatabaseConstants.TRANSACTION_QUEUE_TYPE,
                    OMSDatabaseConstants.POST_TYPE_REQUEST);
            contentValues.put(OMSDatabaseConstants.BL_SCHEMA_NAME, schemaName);
            actionCenterHelper.insertOrUpdateTransactionFailQueue(contentValues, uniqueRowId, configAppId);
        }
    } catch (JSONException e) {
        Log.e(TAG, "Exception occurred while updating the Action Queue status." + e.getMessage());
        e.printStackTrace();
    } catch (IllegalFormatConversionException e) {
        Log.e(TAG, "Exception occurred while updating the Action Queue status." + e.getMessage());
        e.printStackTrace();
    }
    return response;
}