Package org.encuestame.utils.social

Examples of org.encuestame.utils.social.TubmlrUserProfile


    */
   private TubmlrUserProfile getUserProfile() {
       Map<?, ?> response = getRestTemplate().getForObject(GET_CURRENT_USER_INFO, Map.class);      
       Map<?, ?> response2 = (Map<?, ?>) response.get("response");
       Map<?, ?> user = (Map<?, ?>) response2.get("user");
       final TubmlrUserProfile profile = new TubmlrUserProfile();
       profile.setName(user.get("name").toString());
       profile.setFollowing(Integer.valueOf(user.get("following").toString()));
       profile.setLikes(Integer.valueOf(user.get("likes").toString()));
       profile.setDefaultPostFormat(user.get("default_post_format").toString());
       try {
         List<LinkedHashMap<String, Object>> t =   (List<LinkedHashMap<String, Object>>) user.get("blogs");
         for (LinkedHashMap<String, Object> linkedHashMap : t) {
           final TumblrBlog blog = new TumblrBlog();
           blog.setAsk(Boolean.valueOf(linkedHashMap.get("ask").toString()));
           blog.setDescription(linkedHashMap.get("description").toString());
           blog.setFollowers(Integer.valueOf(linkedHashMap.get("followers").toString()));
           blog.setUrl(linkedHashMap.get("url").toString());
           blog.setName(linkedHashMap.get("name").toString());
           blog.setPrimary(Boolean.valueOf(linkedHashMap.get("primary").toString()));
           //blog.setLastUpdated(new Date(linkedHashMap.get("updated").toString()));
           blog.setLastUpdated(Calendar.getInstance().getTime());
           profile.getListBlogs().add(blog);
         }
       }catch(Exception ex){
         ex.printStackTrace();
         log.error(ex);     
       }
View Full Code Here


    */
  @Override
  public SocialUserProfile getProfile() throws Exception {
    //TODO: finish properties mapping
    final SocialUserProfile socialUserProfile = new SocialUserProfile();
    final TubmlrUserProfile profile = this.getUserProfile();
    socialUserProfile.setFollowersCount(0);
    socialUserProfile.setUsername(profile.getName());
    socialUserProfile.setId(profile.getName());
    //get the primary blog
    socialUserProfile.setEmail(null);
    socialUserProfile.setCreatedAt(Calendar.getInstance().getTime());
    socialUserProfile.setName(profile.getName());
    socialUserProfile.setUrl(profile.getListBlogs().get(0).getUrl());
    socialUserProfile.setProfileImageUrl("http://api.tumblr.com/v2/blog/{username}.tumblr.com/avatar/24".replace("{username}", profile.getName()));
    socialUserProfile.setScreenName(profile.getName());
    socialUserProfile.setLocation("");
    socialUserProfile.setDescription(profile.getName());
    return socialUserProfile;
  }
View Full Code Here

TOP

Related Classes of org.encuestame.utils.social.TubmlrUserProfile

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.