Package org.brickred.socialauth

Examples of org.brickred.socialauth.Album


    if (root != null) {
      NodeList albumList = root.getElementsByTagName("entry");
      if (albumList != null && albumList.getLength() > 0) {
        LOG.info("Found albums : " + albumList.getLength());
        for (int i = 0; i < albumList.getLength(); i++) {
          Album album = new Album();
          Element p = (Element) albumList.item(i);

          NodeList id = p.getElementsByTagNameNS(ALBUM_NAMESPACE,
              "id");
          String albumId = XMLParseUtil.getElementData(id.item(0));
          album.setId(albumId);

          album.setName(XMLParseUtil.getElementData(p, "title"));

          NodeList count = p.getElementsByTagNameNS(ALBUM_NAMESPACE,
              "numphotos");
          album.setPhotosCount(Integer.parseInt(XMLParseUtil
              .getElementData(count.item(0))));

          NodeList mediaGroup = p.getElementsByTagNameNS(
              MEDIA_NAMESPACE, "group");
          String url = null;
          if (mediaGroup != null && mediaGroup.getLength() > 0) {
            Element el = (Element) mediaGroup.item(0);
            if (el != null) {
              NodeList thumbnail = el.getElementsByTagNameNS(
                  MEDIA_NAMESPACE, "thumbnail");
              if (thumbnail != null) {
                Element tl = (Element) thumbnail.item(0);
                if (tl != null) {
                  url = tl.getAttribute("url");
                }
              }
            }
          }
          album.setCoverPhoto(url);

          String rel = null;
          String href = null;

          NodeList link = p.getElementsByTagName("link");
          if (link != null && link.getLength() > 0) {
            for (int j = 0; j < link.getLength(); j++) {
              Element l = (Element) link.item(j);
              if (l != null) {
                rel = l.getAttribute("rel");
                if (rel != null
                    && rel.equalsIgnoreCase("alternate")) {
                  href = l.getAttribute("href");
                }
              }
            }
          }

          album.setLink(href);
          List<Photo> photos = getAlbumPhotos(albumId);
          album.setPhotos(photos);

          albums.add(album);
          System.out.println(album);
        }
      } else {
View Full Code Here


    List<Album> albums = new ArrayList<Album>();
    JSONObject resp = new JSONObject(respStr);
    JSONArray data = resp.getJSONArray("data");
    LOG.debug("Albums count : " + data.length());
    for (int i = 0; i < data.length(); i++) {
      Album album = new Album();
      JSONObject obj = data.getJSONObject(i);
      String albumId = obj.getString("id");
      album.setId(albumId);
      if (obj.has("name")) {
        album.setName(obj.getString("name"));
      }

      if (obj.has("link")) {
        album.setLink(obj.getString("link"));
      }
      if (obj.has("cover_photo")) {
        album.setCoverPhoto(obj.getString("cover_photo"));
      }
      if (obj.has("count")) {
        album.setPhotosCount(obj.getInt("count"));
      }
      album.setCoverPhoto(String.format(ALBUM_COVER_URL, albumId,
          providerSupport.getAccessGrant().getKey()));
      List<Photo> photos = getAlbumPhotos(albumId);
      album.setPhotos(photos);
      albums.add(album);
    }
    return albums;
  }
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++) {
      Album album = new Album();
      JSONObject jobj = jarr.getJSONObject(i);

      if (jobj.has("user")) {
        JSONObject userObj = jobj.getJSONObject("user");

        if (jobj.has("entities")) {
          JSONObject entitiesObj = jobj.getJSONObject("entities");
          if (entitiesObj.has("media")) {
            JSONObject mediaObj = entitiesObj.getJSONArray("media")
                .getJSONObject(0);
            if (mediaObj.has("type")
                && mediaObj.getString("type").equalsIgnoreCase(
                    "photo")) {
              if (userObj.has("name")
                  && mediaObj.has("media_url")) {
                List<Photo> photos = photo_data.get(userObj
                    .getString("name"));
                if (photos == null) {
                  photos = new ArrayList<Photo>();
                  photo_data.put(userObj.getString("name"),
                      photos);

                  album.setName(userObj.getString("name"));
                  album.setCoverPhoto(userObj.getString(
                      "profile_image_url").replaceAll(
                      "_normal", "_reasonably_small"));
                  albums.add(album);
                }
                Photo photo = new Photo();
                String photoURL = mediaObj
                    .getString("media_url");
                photo.setThumbImage(photoURL + ":thumb");
                photo.setSmallImage(photoURL + ":small");
                photo.setMediumImage(photoURL);
                photo.setLargeImage(photoURL + ":large");
                if (jobj.has("text")) {
                  photo.setTitle(jobj.getString("text"));
                }
                if (mediaObj.has("id_str")) {
                  photo.setId(mediaObj.getString("id_str"));
                }
                if (mediaObj.has("expanded_url")) {
                  photo.setLink(mediaObj
                      .getString("expanded_url"));
                }
                if (jobj.has("retweet_count")) {
                  Map<String, String> map = new HashMap<String, String>();
                  map.put("retweet_count", String
                      .valueOf(jobj
                          .getInt("retweet_count")));
                  photo.setMetaData(map);
                }
                photos.add(photo);
              }
            }
          }
        }
      }
    }

    for (Album album : albums) {
      List<Photo> photos = photo_data.get(album.getName());
      album.setPhotos(photos);
      album.setPhotosCount(photos.size());
    }
    return albums;
  }
View Full Code Here

TOP

Related Classes of org.brickred.socialauth.Album

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.