Package org.brickred.socialauth

Examples of org.brickred.socialauth.Feed


      LOG.debug("Feed Json response :: " + respStr);
      JSONObject resp = new JSONObject(respStr);
      JSONArray data = resp.getJSONArray("data");
      LOG.debug("Feeds count : " + data.length());
      for (int i = 0; i < data.length(); i++) {
        Feed feed = new Feed();
        JSONObject obj = data.getJSONObject(i);
        if (obj.has("images")) {
          JSONObject iobj = obj.getJSONObject("images");
          if (iobj.has("low_resolution")) {
            feed.setMessage(iobj.getJSONObject("low_resolution")
                .optString("url"));
          }
        }
        if (obj.has("user")) {
          JSONObject iobj = obj.getJSONObject("user");
          if (iobj.has("full_name")) {
            feed.setFrom(iobj.getString("full_name"));
          }
          if (iobj.has("id")) {
            feed.setId(iobj.getString("id"));
          }
          if (iobj.has("username")) {
            feed.setScreenName(iobj.getString("username"));
          }
        }
        if (obj.has("created_time")) {
          feed.setCreatedAt(new Date(Integer.parseInt(obj
              .getString("created_time"))));
        }
        list.add(feed);
      }
    } catch (Exception e) {
View Full Code Here


      System.out.println(respStr);
      JSONObject resp = new JSONObject(respStr);
      JSONArray items = resp.getJSONArray("items");
      LOG.debug("Feeds count : " + items.length());
      for (int i = 0; i < items.length(); i++) {
        Feed feed = new Feed();
        JSONObject obj = items.getJSONObject(i);
        if (obj.has("title")) {
          feed.setMessage(obj.getString("title"));
        }
        if (obj.has("id")) {
          feed.setId(obj.getString("id"));
        }
        if (obj.has("actor")) {
          JSONObject actor = obj.getJSONObject("actor");
          if (actor.has("displayName")) {
            feed.setFrom(actor.getString("displayName"));
          }
        }
        if (obj.has("published")) {
          Date date = dateFormat.parse(obj.getString("published"));
          feed.setCreatedAt(date);
        }
        System.out.println(feed);
        list.add(feed);
      }
View Full Code Here

          .getResponseBodyAsString(Constants.ENCODING);
      JSONObject resp = new JSONObject(respStr);
      JSONArray data = resp.getJSONArray("data");
      LOG.debug("Feeds count : " + data.length());
      for (int i = 0; i < data.length(); i++) {
        Feed feed = new Feed();
        JSONObject obj = data.getJSONObject(i);
        if (obj.has("from")) {
          JSONObject fobj = obj.getJSONObject("from");
          if (fobj.has("name")) {
            feed.setFrom(fobj.getString("name"));
          }
          if (fobj.has("id")) {
            feed.setId(fobj.getString("id"));
          }
        }
        if (obj.has("message")) {
          feed.setMessage(obj.getString("message"));
        } else if (obj.has("story")) {
          feed.setMessage(obj.getString("story"));
        } else if (obj.has("name")) {
          feed.setMessage(obj.getString("name"));
        } else if (obj.has("caption")) {
          feed.setMessage(obj.getString("caption"));
        } else if (obj.has("description")) {
          feed.setMessage(obj.getString("description"));
        } else if (obj.has("picture")) {
          feed.setMessage(obj.getString("picture"));
        }

        if (obj.has("created_time")) {
          feed.setCreatedAt(dateFormat.parse(obj
              .getString("created_time")));
        }
        list.add(feed);
      }
    } catch (Exception e) {
View Full Code Here

        String time = xPath.evaluate(String.format(dateExpression, i),
            root);
        Date date = new Date(Long.valueOf(time));

        boolean isSet = true;
        Feed feed = new Feed();
        feed.setId(id);
        feed.setCreatedAt(date);
        feed.setFrom(name);

        if ("CONN".equals(type)) {
          String cfname = xPath.evaluate(
              String.format(cfnameExpression, i), root);
          String clname = xPath.evaluate(
              String.format(clnameExpression, i), root);
          feed.setMessage(name + UPDATE_TYPES.get("CONN") + cfname
              + " " + clname);
        } else if ("NCON".equals(type)) {
          feed.setMessage(name + UPDATE_TYPES.get("NCON"));
        } else if ("CCEM".equals(type)) {
          feed.setMessage(name + UPDATE_TYPES.get("CCEM"));
        } else if ("SHAR".equals(type)) {
          String comment = xPath.evaluate(
              String.format(shareCommentExpression, i), root);
          feed.setMessage(name + UPDATE_TYPES.get("SHAR") + comment);
        } else if ("STAT".equals(type)) {
          String status = xPath.evaluate(
              String.format(statusExpression, i), root);
          feed.setMessage(name + UPDATE_TYPES.get("STAT") + status);
        } else if ("JOBP".equals(type)) {
          String jpFname = xPath.evaluate(
              String.format(jobPosterFnameExpression, i), root);
          String jpLname = xPath.evaluate(
              String.format(jobPosterLnameExpression, i), root);
          String jpId = xPath.evaluate(
              String.format(jobPosterIdExpression, i), root);
          String position = xPath.evaluate(
              String.format(jobPositionExpression, i), root);
          String company = xPath.evaluate(
              String.format(jobCompanyExpression, i), root);
          feed.setFrom(jpFname + " " + jpLname);
          feed.setId(jpId);
          feed.setMessage(jpFname + " " + jpLname
              + UPDATE_TYPES.get("JOBP") + position + " at "
              + company);
        } else if ("JGRP".equals(type)) {
          String groupName = xPath.evaluate(
              String.format(groupNameExpression, i), root);
          feed.setMessage(name + UPDATE_TYPES.get("JGRP") + groupName);
        } else if ("PREC".equals(type)) {
          double count = (Double) xPath.evaluate(String.format(
              recommendationGivenCountExpression, i), root,
              XPathConstants.NUMBER);
          String message = "";
          if (count > 0) {
            String recommendation = xPath.evaluate(
                String.format(recommendationExpression, i),
                root);
            String recommendeeFname = xPath.evaluate(
                String.format(recommendeeFnameExpression, i),
                root);
            String recommendeeLname = xPath.evaluate(
                String.format(recommendeeLnameExpression, i),
                root);
            message = name + UPDATE_TYPES.get("PREC_GIVEN")
                + recommendeeFname + " " + recommendeeLname;
            if (recommendation != null
                && recommendation.length() > 0) {
              message += " :'" + recommendation + "'";
            }
          } else {
            String recommendeeFname = xPath.evaluate(
                String.format(recommenderFnameExpression, i),
                root);
            String recommendeeLname = xPath.evaluate(
                String.format(recommenderLnameExpression, i),
                root);
            message = name + UPDATE_TYPES.get("PREC_RECEIVED")
                + recommendeeFname + " " + recommendeeLname;
          }
          feed.setMessage(message);
        } else if ("PROF".equals(type)) {
          feed.setMessage(name + UPDATE_TYPES.get("PROF"));
        } else if ("APPM".equals(type)) {
          String update = xPath.evaluate(
              String.format(appUpdateExpression, i), root);
          feed.setMessage(name + UPDATE_TYPES.get("APPM") + update);
        } else if ("MSFC".equals(type)) {
          String company = xPath.evaluate(
              String.format(companyExpression, i), root);
          String pfname = xPath.evaluate(
              String.format(companyPersonFnameExpression, i),
              root);
          String plname = xPath.evaluate(
              String.format(companyPersonLnameExpression, i),
              root);
          String pid = xPath.evaluate(
              String.format(companyPersonIdExpression, i), root);
          feed.setMessage(pfname + " " + plname
              + UPDATE_TYPES.get("MSFC") + company);
          feed.setFrom(pfname + " " + pfname);
          feed.setId(pid);
          list.add(feed);
        } else if ("PICU".equals(type)) {
          feed.setMessage(name + UPDATE_TYPES.get("PICU"));
        } else {
          isSet = false;
        }

        if (isSet) {
View Full Code Here

      LOG.debug("Feeds json string :: " + respStr);
      JSONArray jarr = new JSONArray(respStr);
      LOG.debug("Feeds count :: " + jarr.length());
      for (int i = 0; i < jarr.length(); i++) {
        JSONObject jobj = jarr.getJSONObject(i);
        Feed feed = new Feed();
        if (jobj.has("created_at")) {
          String dateStr = jobj.getString("created_at");
          feed.setCreatedAt(dateFormat.parse(dateStr));
        }
        if (jobj.has("text")) {
          feed.setMessage(jobj.getString("text"));
        }
        if (jobj.has("user")) {
          JSONObject userObj = jobj.getJSONObject("user");
          if (userObj.has("id_str")) {
            feed.setId(userObj.getString("id_str"));
          }
          if (userObj.has("name")) {
            feed.setFrom(userObj.getString("name"));
          }
          if (userObj.has("screen_name")) {
            feed.setScreenName(userObj.getString("screen_name"));
          }
        }
        list.add(feed);
      }
    } catch (Exception e) {
View Full Code Here

        String time = xPath.evaluate(String.format(dateExpression, i),
            root);
        Date date = new Date(Long.valueOf(time));

        boolean isSet = true;
        Feed feed = new Feed();
        feed.setId(id);
        feed.setCreatedAt(date);
        feed.setFrom(name);

        if ("CONN".equals(type)) {
          String cfname = xPath.evaluate(
              String.format(cfnameExpression, i), root);
          String clname = xPath.evaluate(
              String.format(clnameExpression, i), root);
          feed.setMessage(name + UPDATE_TYPES.get("CONN") + cfname
              + " " + clname);
        } else if ("NCON".equals(type)) {
          feed.setMessage(name + UPDATE_TYPES.get("NCON"));
        } else if ("CCEM".equals(type)) {
          feed.setMessage(name + UPDATE_TYPES.get("CCEM"));
        } else if ("SHAR".equals(type)) {
          String comment = xPath.evaluate(
              String.format(shareCommentExpression, i), root);
          feed.setMessage(name + UPDATE_TYPES.get("SHAR") + comment);
        } else if ("STAT".equals(type)) {
          String status = xPath.evaluate(
              String.format(statusExpression, i), root);
          feed.setMessage(name + UPDATE_TYPES.get("STAT") + status);
        } else if ("JOBP".equals(type)) {
          String jpFname = xPath.evaluate(
              String.format(jobPosterFnameExpression, i), root);
          String jpLname = xPath.evaluate(
              String.format(jobPosterLnameExpression, i), root);
          String jpId = xPath.evaluate(
              String.format(jobPosterIdExpression, i), root);
          String position = xPath.evaluate(
              String.format(jobPositionExpression, i), root);
          String company = xPath.evaluate(
              String.format(jobCompanyExpression, i), root);
          feed.setFrom(jpFname + " " + jpLname);
          feed.setId(jpId);
          feed.setMessage(jpFname + " " + jpLname
              + UPDATE_TYPES.get("JOBP") + position + " at "
              + company);
        } else if ("JGRP".equals(type)) {
          String groupName = xPath.evaluate(
              String.format(groupNameExpression, i), root);
          feed.setMessage(name + UPDATE_TYPES.get("JGRP") + groupName);
        } else if ("PREC".equals(type)) {
          double count = (Double) xPath.evaluate(String.format(
              recommendationGivenCountExpression, i), root,
              XPathConstants.NUMBER);
          String message = "";
          if (count > 0) {
            String recommendation = xPath.evaluate(
                String.format(recommendationExpression, i),
                root);
            String recommendeeFname = xPath.evaluate(
                String.format(recommendeeFnameExpression, i),
                root);
            String recommendeeLname = xPath.evaluate(
                String.format(recommendeeLnameExpression, i),
                root);
            message = name + UPDATE_TYPES.get("PREC_GIVEN")
                + recommendeeFname + " " + recommendeeLname;
            if (recommendation != null
                && recommendation.length() > 0) {
              message += " :'" + recommendation + "'";
            }
          } else {
            String recommendeeFname = xPath.evaluate(
                String.format(recommenderFnameExpression, i),
                root);
            String recommendeeLname = xPath.evaluate(
                String.format(recommenderLnameExpression, i),
                root);
            message = name + UPDATE_TYPES.get("PREC_RECEIVED")
                + recommendeeFname + " " + recommendeeLname;
          }
          feed.setMessage(message);
        } else if ("PROF".equals(type)) {
          feed.setMessage(name + UPDATE_TYPES.get("PROF"));
        } else if ("APPM".equals(type)) {
          String update = xPath.evaluate(
              String.format(appUpdateExpression, i), root);
          feed.setMessage(name + UPDATE_TYPES.get("APPM") + update);
        } else if ("MSFC".equals(type)) {
          String company = xPath.evaluate(
              String.format(companyExpression, i), root);
          String pfname = xPath.evaluate(
              String.format(companyPersonFnameExpression, i),
              root);
          String plname = xPath.evaluate(
              String.format(companyPersonLnameExpression, i),
              root);
          String pid = xPath.evaluate(
              String.format(companyPersonIdExpression, i), root);
          feed.setMessage(pfname + " " + plname
              + UPDATE_TYPES.get("MSFC") + company);
          feed.setFrom(pfname + " " + pfname);
          feed.setId(pid);
          list.add(feed);
        } else if ("PICU".equals(type)) {
          feed.setMessage(name + UPDATE_TYPES.get("PICU"));
        } else {
          isSet = false;
        }

        if (isSet) {
View Full Code Here

TOP

Related Classes of org.brickred.socialauth.Feed

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.