Package org.brickred.socialauth

Examples of org.brickred.socialauth.Contact


      JSONArray responses = resp.getJSONArray("resources");
      LOG.debug("Found contacts : " + responses.length());
      for (int i = 0; i < responses.length(); i++) {
        JSONObject obj = responses.getJSONObject(i);
        JSONObject fields = obj.getJSONObject("fields");
        Contact p = new Contact();
        if (obj.has("record_type")) {
          if ("company".equals(obj.getString("record_type"))) {
            if (fields.has("company name")) {
              JSONArray arr = fields.getJSONArray("company name");
              JSONObject jobj = arr.getJSONObject(0);
              if (jobj.has("value")) {
                p.setFirstName(jobj.getString("value"));
              }
            }
            if (obj.has("avatar_url")) {
              p.setProfileImageURL(obj.getString("avatar_url"));
            }
            if (fields.has("URL")) {
              JSONArray arr = fields.getJSONArray("URL");
              JSONObject jobj = arr.getJSONObject(0);
              if (jobj.has("value")) {
                p.setProfileUrl(jobj.getString("value"));
              }
            }
            plist.add(p);
          } else if ("person".equals(obj.getString("record_type"))) {
            if (fields.has("last name")) {
              JSONArray arr = fields.getJSONArray("last name");
              JSONObject jobj = arr.getJSONObject(0);
              if (jobj.has("value")) {
                p.setLastName(jobj.getString("value"));
              }
            }
            if (fields.has("first name")) {
              JSONArray arr = fields.getJSONArray("first name");
              JSONObject jobj = arr.getJSONObject(0);
              if (jobj.has("value")) {
                p.setFirstName(jobj.getString("value"));
              }
            }
            if (obj.has("avatar_url")) {
              p.setProfileImageURL(obj.getString("avatar_url"));
            }
            if (fields.has("URL")) {
              JSONArray arr = fields.getJSONArray("URL");
              if (arr.length() == 1) {
                JSONObject jobj = arr.getJSONObject(0);
                if (jobj.has("value")) {
                  p.setProfileUrl(jobj.getString("value"));
                }
              } else {
                String url = null;
                for (int k = 0; k < arr.length(); k++) {
                  JSONObject jobj = arr.getJSONObject(k);
                  url = jobj.optString("value");
                  if ("personal".equals(jobj
                      .optString("modifier"))) {
                    break;
                  }
                }
                if (url != null) {
                  p.setProfileUrl(url);
                }
              }
            }
            plist.add(p);
          }
View Full Code Here


    try {
      LOG.debug("User Contacts list in json : " + respStr);
      JSONArray resp = new JSONArray(respStr);
      for (int i = 0; i < resp.length(); i++) {
        JSONObject obj = resp.getJSONObject(i);
        Contact p = new Contact();
        String name = obj.getString("full_name");
        p.setDisplayName(name);
        JSONObject userContactDetails = obj.getJSONObject("contact");
        JSONArray emailArr = userContactDetails
            .getJSONArray("email_addresses");
        JSONObject eobj = emailArr.getJSONObject(0);
        if (eobj.has("address")) {
          p.setEmail(eobj.getString("address"));
        }
        p.setId(obj.getString("id"));
        p.setProfileUrl(obj.getString("web_url"));
        plist.add(p);
      }
    } catch (Exception e) {
      throw new ServerDataException(
          "Failed to parse the user profile json : " + respStr, e);
View Full Code Here

    if (resp.has("data")) {
      JSONArray addArr = resp.getJSONArray("data");
      LOG.debug("Contacts Found : " + addArr.length());
      for (int i = 0; i < addArr.length(); i++) {
        JSONObject obj = addArr.getJSONObject(i);
        Contact p = new Contact();
        if (obj.has("email_hashes")) {
          JSONArray emailArr = obj.getJSONArray("email_hashes");
          if (emailArr.length() > 0) {
            p.setEmailHash(emailArr.getString(0));
          }
        }
        if (obj.has("name")) {
          p.setDisplayName(obj.getString("name"));
        }
        if (obj.has("first_name")) {
          p.setFirstName(obj.getString("first_name"));
        }
        if (obj.has("last_name")) {
          p.setLastName(obj.getString("last_name"));
        }
        if (obj.has("id")) {
          p.setId(obj.getString("id"));
        }
        plist.add(p);
      }
    }
    serviceResponse.close();
View Full Code Here

    }
    List<Contact> plist = new ArrayList<Contact>();
    for (int i = 0; i < fArr.length(); i++) {
      JSONObject fObj = fArr.getJSONObject(i);
      if (fObj.has("person")) {
        Contact contact = new Contact();
        JSONObject pObj = fObj.getJSONObject("person");
        if (pObj.has("displayName")) {
          contact.setDisplayName(pObj.getString("displayName"));
        }
        if (pObj.has("name")) {
          JSONObject nobj = pObj.getJSONObject("name");
          if (nobj.has("familyName")) {
            contact.setLastName(nobj.getString("familyName"));
          }
          if (nobj.has("givenName")) {
            contact.setFirstName(nobj.getString("givenName"));
          }
        }

        if (pObj.has("profileUrl")) {
          contact.setProfileUrl(pObj.getString("profileUrl"));
        }
        if (pObj.has("id")) {
          contact.setId(pObj.getString("id"));
        }
        plist.add(contact);
      }
    }
    return plist;
View Full Code Here

    if (resp.has("data")) {
      JSONArray addArr = resp.getJSONArray("data");
      LOG.debug("Contacts Found : " + addArr.length());
      for (int i = 0; i < addArr.length(); i++) {
        JSONObject obj = addArr.getJSONObject(i);
        Contact p = new Contact();
        if (obj.has("email_hashes")) {
          JSONArray emailArr = obj.getJSONArray("email_hashes");
          if (emailArr.length() > 0) {
            p.setEmailHash(emailArr.getString(0));
          }
        }
        if (obj.has("name")) {
          p.setDisplayName(obj.getString("name"));
        }
        if (obj.has("first_name")) {
          p.setFirstName(obj.getString("first_name"));
        }
        if (obj.has("last_name")) {
          p.setLastName(obj.getString("last_name"));
        }
        if (obj.has("id")) {
          p.setId(obj.getString("id"));
        }
        plist.add(p);
      }
    }
    serviceResponse.close();
View Full Code Here

TOP

Related Classes of org.brickred.socialauth.Contact

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.