Example usage for org.json JSONException printStackTrace

List of usage examples for org.json JSONException printStackTrace

Introduction

In this page you can find the example usage for org.json JSONException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:com.eventattend.portal.bl.FaceBookBL.java

private List personFBFriendsProfile(FacebookJsonRestClient userClient, long userId) {
    JSONArray jsonArray = null;//w  w w . jav a 2 s.  c o  m
    List friendsList = null;
    List friendsIds = null;
    friendsIds = new ArrayList();
    JSONObject jsonObject = null;

    try {

        jsonArray = userClient.friends_get();

        for (int i = 0; i < jsonArray.length(); i++) {

            try {

                Object uId = (Object) jsonArray.get(i);

                userId = Long.parseLong(uId.toString());

                friendsIds.add(userId);

            } catch (JSONException e) {

                e.printStackTrace();
            }

        }

        jsonArray = userClient.users_getInfo(friendsIds, fields);

        friendsList = personFBFriendsList(jsonArray);

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

    return friendsList;
}

From source file:com.eventattend.portal.bl.FaceBookBL.java

public List personFBFriendsList(JSONArray jsonArray) {

    List friendsList = null;/*from w w  w.j  ava 2  s  .  c  o m*/
    JSONObject jsonObject = null;
    friendsList = new ArrayList();

    for (int i = 0; i < jsonArray.length(); i++) {

        try {
            jsonObject = jsonArray.getJSONObject(i);
            //    getUserDetails(jsonObject);

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

    }
    return friendsList;

}

From source file:com.eventattend.portal.bl.FaceBookBL.java

private FaceBookDTO getUserDetails(JSONObject jsonObject, FaceBookDTO faceBookDTO) {
    JSONArray jsonArray = null;// w  w  w .  j av  a2 s  .  co  m
    JSONObject jsonObjectLocation = null;
    System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
    try {

        if (jsonObject != null) {
            System.out.println("UId=> " + jsonObject.getString("uid"));
            if (jsonObject.getString("profile_url") != null) {
                faceBookDTO.setProfileUrl(jsonObject.getString("profile_url"));
                System.out.println("PROFILE_URL=> " + jsonObject.getString("profile_url"));
            }
            if (jsonObject.getString("name") != null) {
                System.out.println("Name=> " + jsonObject.getString("name"));
                faceBookDTO.setName(jsonObject.getString("name"));
            }
            if (jsonObject.getString("first_name") != null) {
                System.out.println("First Name=> " + jsonObject.getString("first_name"));
            }
            if (jsonObject.getString("last_name") != null) {
                System.out.println("Last Name=> " + jsonObject.getString("last_name"));
            }
            if (jsonObject.getString("birthday") != null
                    && (!jsonObject.getString("birthday").equals("null"))) {
                System.out.println("BIRTHDAY=> " + jsonObject.getString("birthday"));
            }

            if (jsonObject.getString("about_me") != null
                    && (!jsonObject.getString("about_me").equals("null"))) {
                System.out.println("About Me=> " + jsonObject.getString("about_me"));
            }

            if (jsonObject.getString("movies") != null && (!jsonObject.getString("movies").equals("null"))) {
                System.out.println("MOVIES=> " + jsonObject.getString("movies"));
            }
            if (jsonObject.getString("status") != null && (!jsonObject.getString("status").equals("null"))) {
                System.out.println("Status=> " + jsonObject.getString("status"));
            }
            if (jsonObject.getString("relationship_status") != null) {
                System.out.println("RELATIONSHIP_STATUS=> " + jsonObject.getString("relationship_status"));
            }
            if (jsonObject.getString("locale") != null) {
                System.out.println("LOCALE=> " + jsonObject.getString("locale"));
            }
            if (jsonObject.getString("wall_count") != null) {
                System.out.println("WALL_COUNT=> " + jsonObject.getString("wall_count"));
            }
            if (jsonObject.getString("quotes") != null) {
                System.out.println("QUOTES=> " + jsonObject.getString("quotes"));
            }
            if (jsonObject.getString("pic") != null) {
                System.out.println("PIC=> " + jsonObject.getString("pic"));
                faceBookDTO.setProfileImg(jsonObject.getString("pic"));
            }
            if (jsonObject.getString("pic_big") != null) {
                System.out.println("PIC_BIG=> " + jsonObject.getString("pic_big"));
                faceBookDTO.setProfileBigImg(jsonObject.getString("pic_big"));
            }
            if (jsonObject.getString("activities") != null) {
                System.out.println("ACTIVITIES=> " + jsonObject.getString("activities"));
            }
            if (jsonObject.getString("hometown_location") != null) {
                System.out.println("HOMETOWN_LOCATION=> " + jsonObject.getString("hometown_location"));
            }

            if (jsonObject.getString("hs_info") != null) {
                System.out.println("hs_info=> " + jsonObject.getString("hs_info"));
            }
            if (jsonObject.getString("education_history") != null) {
                String edu = jsonObject.getString("education_history");
                Collection coll = new ArrayList();
                JSONObject myString = new JSONObject().put(edu, coll);

                System.out.println("EDUCATION_HISTORY=> " + jsonObject.getString("education_history"));

            }
            if (jsonObject.getString("work_history") != null) {
                System.out.println("WORK_HISTORY=> " + jsonObject.getString("work_history"));
            }
            if (jsonObject.getString("affiliations") != null) {
                System.out.println("WORK_HISTORY=> " + jsonObject.getString("affiliations"));
            }
            if (jsonObject.getString("email_hashes") != null) {
                System.out.println("EMAIL_HASHES=> " + jsonObject.getString("email_hashes"));
            }
            if (jsonObject.getString("interests") != null) {
                System.out.println("INTERESTS=> " + jsonObject.getString("interests"));
            }

            if (jsonObject.getString("current_location") != null) {
                if (!jsonObject.getString("current_location").equals("null")) {
                    jsonObjectLocation = jsonObject.getJSONObject("current_location");
                    //         System.out.println("ObjectLocation=> "+jsonObjectLocation);

                } else {

                }
            } else {

            }

        }

    } catch (JSONException e) {
        e.printStackTrace();
    }
    return faceBookDTO;
}

From source file:com.eventattend.portal.bl.FaceBookBL.java

/**
 * @param userClient/*from w ww. j a  v  a2  s . com*/
 * @return
 * @throws EventPortalException 
 */
private ProfileDTO getUserProfile(FacebookJsonRestClient userClient) throws EventPortalException {
    JSONArray jsonArray = null;
    ProfileDTO profileDTO = null;
    List currentUser = new ArrayList();
    EnumSet<ProfileField> fields1 = EnumSet.of(com.google.code.facebookapi.ProfileField.UID,
            com.google.code.facebookapi.ProfileField.NAME, com.google.code.facebookapi.ProfileField.PIC,
            com.google.code.facebookapi.ProfileField.CURRENT_LOCATION,
            com.google.code.facebookapi.ProfileField.FIRST_NAME,
            com.google.code.facebookapi.ProfileField.LAST_NAME,
            com.google.code.facebookapi.ProfileField.HOMETOWN_LOCATION,
            com.google.code.facebookapi.ProfileField.PROFILE_URL);
    try {

        Long facebookUserID = userClient.users_getLoggedInUser();
        currentUser.add(facebookUserID);

        jsonArray = userClient.users_getInfo(currentUser, fields1);

        try {

            JSONObject obj = jsonArray.getJSONObject(0);
            profileDTO = getUserData(obj);

        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    } catch (FacebookException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
        throw new EventPortalException("Facebook Session Invalid");

    }

    return profileDTO;
}

From source file:com.eventattend.portal.bl.FaceBookBL.java

private ProfileDTO getUserData(JSONObject jsonObject) {
    JSONArray jsonArray = null;/*from w  w  w  .  j a va  2s. c om*/
    JSONObject jsonObjectLocation = null;
    ProfileDTO profileDTO = null;

    try {
        if (jsonObject != null) {

            profileDTO = new ProfileDTO();

            profileDTO.setProfileId(jsonObject.getString("uid"));
            profileDTO.setFirstName(jsonObject.getString("first_name"));
            profileDTO.setLastName(jsonObject.getString("last_name"));
            profileDTO.setFaceBookImgUrl(jsonObject.getString("pic"));
            if (jsonObject.getString("current_location") != null) {
                if (!jsonObject.getString("current_location").equals("null")) {
                    jsonObjectLocation = jsonObject.getJSONObject("current_location");
                    //profileDTO.setLocation(getLocation(jsonObjectLocation));
                } else {
                    //profileDTO.setLocation("");
                }
            } else {
                //profileDTO.setLocation("");
            }
            //profileDTO.setFaceBookId(jsonObject.getString("profile_url"));
        }

    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return profileDTO;
}

From source file:com.eventattend.portal.bl.FaceBookBL.java

public String getLocation(JSONObject jsonObject) {

    String location = "";
    String city = "";
    String state = "";
    String country = "";

    try {/*from  w  w  w.  j ava  2 s  . c o  m*/

        //JSONObject obj = jsonObject.getJSONObject(0);

        city = jsonObject.getString("city");
        state = jsonObject.getString("state");
        country = jsonObject.getString("country");

        location = city + ", " + state + ", " + country;

    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return location;
}

From source file:com.eventattend.portal.bl.FaceBookBL.java

/**
 * @param userClient//from  w  w w. ja  va  2s.  c  o  m
 * @return
 */
private List getFriendsProfile(FacebookJsonRestClient userClient) {
    JSONArray jsonArray = null;
    List friendsList = null;
    List friendsIds = null;

    FaceBookDTO faceBookDTO = null;
    friendsIds = new ArrayList();
    JSONObject jsonObject = null;
    long userId = 0;

    try {
        userId = userClient.users_getLoggedInUser();

        jsonArray = userClient.friends_get(userId);

        for (int i = 0; i < jsonArray.length(); i++) {

            try {

                Object uId = (Object) jsonArray.get(i);

                userId = Long.parseLong(uId.toString());

                friendsIds.add(userId);

            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }

        jsonArray = userClient.users_getInfo(friendsIds, fields);

        friendsList = getFriendsList(jsonArray);

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

    return friendsList;
}

From source file:com.eventattend.portal.bl.FaceBookBL.java

public List getFriendsList(JSONArray jsonArray) {

    List friendsList = null;/*from ww w  . j  av a 2s .  c om*/
    JSONObject jsonObject = null;
    ProfileDTO profileDTO = null;

    friendsList = new ArrayList();

    for (int i = 0; i < jsonArray.length(); i++) {

        try {
            jsonObject = jsonArray.getJSONObject(i);
            profileDTO = getUserData(jsonObject);
            friendsList.add(profileDTO);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    return friendsList;

}

From source file:com.unlockdisk.android.opengl.MainGLActivity.java

private void initializeCrittercism() {
    ///////////////
    // instantiate metadata json object
    JSONObject metadata = new JSONObject();
    // add arbitrary metadata
    try {//ww  w  .  j  a  va 2  s .  c o m
        metadata.put("user_id", 123);
    } catch (JSONException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    try {
        metadata.put("name", "John Doe");
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    // send metadata to crittercism (asynchronously)
    Crittercism.setMetadata(metadata);
    //   String crittercismKey = buildHelper.getEnvProperty(Config.CRITTERCISM_KEY);
    Crittercism.init(getApplicationContext(), Config.CRITTERCISM_KEY, metadata);
}

From source file:org.apache.cordova.unittests.NativeToJsMessageQueueTest.java

@Test
public void testJsonPopAndEncodeAsJs() {
    NativeToJsMessageQueue.BridgeMode bridge;
    bridge = new NativeToJsMessageQueue.NoOpBridgeMode();
    queue.addBridgeMode(bridge);//  w ww. jav  a  2  s  .c  om
    queue.setBridgeMode(0);

    JSONObject object = new JSONObject();
    try {
        object.put("test", "value");
    } catch (JSONException e) {
        e.printStackTrace();
    }
    PluginResult result = new PluginResult(PluginResult.Status.OK, object);
    queue.addPluginResult(result, TEST_CALLBACK_ID);
    assertFalse(queue.isEmpty());
    String resultString = queue.popAndEncodeAsJs();
    assertTrue(resultString.startsWith("cordova.callbackFromNative"));
}