Package org.encuestame.utils.social

Examples of org.encuestame.utils.social.SocialUserProfile


    * @see org.encuestame.social.api.support.SocialAPIOperations#getProfile()
    */
  @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


     * (non-Javadoc)
     * @see org.encuestame.core.social.SocialAPIOperations#getProfile()
     */
    @Override
    public SocialUserProfile getProfile() throws Exception {
        final SocialUserProfile profile = new SocialUserProfile();
        User user = this.getUser();
        profile.setId(String.valueOf(user.getId()));
        profile.setCreatedAt(user.getCreatedAt());
        profile.setProfileUrl("http://www.twitter.com/"+user.getScreenName());
        profile.setName(user.getName());
        profile.setScreenName(user.getScreenName());
        profile.setUsername(user.getScreenName());
        profile.setProfileImageUrl(user.getProfileImageURL().toString());
        profile.setDescription(user.getDescription());
        profile.setCreatedAt(user.getCreatedAt());
        profile.setLocation(user.getLocation());
        return profile;
    }
View Full Code Here

    /**
     *
     */
    @Override
    public SocialUserProfile getProfile() throws Exception {
        final SocialUserProfile profile = new SocialUserProfile();
        final LinkedInProfile inProfile = getUserProfile();
        profile.setFirstName(inProfile.getFirstName());
        profile.setId(inProfile.getId());
        profile.setHeadline(inProfile.getHeadline());
        profile.setIndustry(inProfile.getIndustry());
        profile.setLastName(inProfile.getLastName());
        profile.setProfileUrl(inProfile.getPublicProfileUrl());
        profile.setProfileImageUrl(inProfile.getPictureUrl());
        profile.setUrl(inProfile.getStandardProfileUrl());
        profile.setUsername(inProfile.getProfileUrl()); //TODO: linkedIn provide username?
        return profile;
    }
View Full Code Here

     *
     */
    public SocialUserProfile getProfile() {
        Map profileMap = getRestTemplate().getForObject(
                this.GOOGLE_CONTACTS_FULL_REST, Map.class, this.GOOGLE_KEY);
        final SocialUserProfile profile = new SocialUserProfile();
        log.debug(profileMap);
        Map feed = (Map) profileMap.get("feed");
        LinkedHashMap mail = (LinkedHashMap) feed.get("id");
        return profile;
    }
View Full Code Here

                IdenticaAPIOperations apiOperations = new IdenticaAPITemplate(
                        apiKey, consumerSecret, accessToken.getValue(),
                        accessToken.getSecret());
                IdentiCaProfile profile = apiOperations.getUserProfile();
                log.debug("identica profile "+profile.toString());
                SocialUserProfile profileAPI = apiOperations.getProfile();
                final SocialAccount socialAccount = getSecurityService().getCurrentSocialAccount(socialProvider,
                        String.valueOf(profile.getId()));
                if (socialAccount == null) {
                    getSecurityService().addNewSocialAccount(
                            accessToken.getValue(), accessToken.getSecret(), null, profileAPI,
                            socialProvider, getUserAccount());
                } else {
                    log.warn("This account already exist");
                    throw new EnMeExistPreviousConnectionException(getMessage("social.repeated.account"));
                }
            } else if (socialProvider.equals(SocialProvider.LINKEDIN)) {
                LinkedInAPIOperations apiOperations = new LinkedInAPITemplate(
                        apiKey, consumerSecret, accessToken.getValue(),
                        accessToken.getSecret());
                LinkedInProfile profile = apiOperations.getUserProfile();
                SocialUserProfile profileAPI = apiOperations.getProfile();
                log.debug("linkedin profile "+profile.toString());
                final SocialAccount socialAccount = getSecurityService().getCurrentSocialAccount(socialProvider, profile.getId());
                if (socialAccount == null) {
                    getSecurityService().addNewSocialAccount(
                            accessToken.getValue(), accessToken.getSecret(), null, profileAPI,
                            socialProvider, getUserAccount());
                } else {
                    log.warn("This account already exist");
                    throw new EnMeExistPreviousConnectionException(getMessage("social.repeated.account"));
                }
            } else if (socialProvider.equals(SocialProvider.TWITTER)) {
                TwitterAPIOperations operations = new TwitterAPITemplate(consumerSecret, apiKey, accessToken.getValue(),
                        accessToken.getSecret());
                SocialUserProfile profile = operations.getProfile();
                log.debug("twitter profile "+profile.toString());
                final SocialAccount socialAccount = getSecurityService().getCurrentSocialAccount(socialProvider, profile.getId());
                if (socialAccount == null) {
                    getSecurityService().addNewSocialAccount(
                            accessToken.getValue(), accessToken.getSecret(), null, profile,
                            socialProvider, getUserAccount());
                } else {
                    log.warn("This account already exist");
                    throw new EnMeExistPreviousConnectionException(getMessage("social.repeated.account"));
                }
                //FUTURE - Issues with OAuth1 request.
            } else if (socialProvider.equals(SocialProvider.YAHOO)) {
                //FUTURE - Only valid on defined domain.
                log.debug("Yahoo provider is disabled");
               
            } else if (socialProvider.equals(SocialProvider.PLURK)) {
              PlurkAPIOperations  apiOperations = new PlurkAPITemplate(
                        apiKey, consumerSecret, accessToken.getValue(),
                        accessToken.getSecret());
                SocialUserProfile profile = apiOperations.getProfile();
                log.debug("plurk profile " + profile.toString());
                final SocialAccount socialAccount = getSecurityService().getCurrentSocialAccount(socialProvider, profile.getId());
                if (socialAccount == null) {
                    getSecurityService().addNewSocialAccount(
                            accessToken.getValue(), accessToken.getSecret(), null, profile,
                            socialProvider, getUserAccount());
                } else {
                    log.warn("This account already exist");
                    throw new EnMeExistPreviousConnectionException(getMessage("social.repeated.account"));
                }
            } else if (socialProvider.equals(SocialProvider.TUMBLR)) {
              TumblrAPIOperations apiOperations = new TumblrAPITemplate(
                        apiKey, consumerSecret, accessToken.getValue(),
                        accessToken.getSecret());
                SocialUserProfile profile = apiOperations.getProfile();
                log.debug("linkedin profile "+profile.toString());
                final SocialAccount socialAccount = getSecurityService().getCurrentSocialAccount(socialProvider, profile.getId());
                if (socialAccount == null) {
                    getSecurityService().addNewSocialAccount(
                            accessToken.getValue(), accessToken.getSecret(), null, profile,
                            socialProvider, getUserAccount());
                } else {
View Full Code Here

    /**
     * Test {@link SocialUserProfile}.
     */
    @Test
    public void testSocialUserProfile(){
        final SocialUserProfile socialUserProfile = new SocialUserProfile();
        socialUserProfile.setContributorsEnabled(Boolean.TRUE);
        socialUserProfile.setCreatedAt(new Date());
        socialUserProfile.setDescription("user profile description");
        socialUserProfile.setEmail("jhonnyATencuestame.org");
        socialUserProfile.setFavouritesCount(5);
        socialUserProfile.setFirstName("Jhonny");
        socialUserProfile.setFollowersCount(5);
        socialUserProfile.setFollowRequestSent(Boolean.TRUE);
        socialUserProfile.setFriendsCount(2);
        socialUserProfile.setGeoEnabled(Boolean.FALSE);
        socialUserProfile.setHeadline("headline");
        socialUserProfile.setId("1");
        socialUserProfile.setIndustry("encuestame,Inc");
        socialUserProfile.setLang("");
        socialUserProfile.setLastName("English");
        socialUserProfile.setListedCount(1);
        socialUserProfile.setLocation("spain");
        socialUserProfile.setName("Jhonny");
        socialUserProfile.setProfileBackgroundColor("#393CCA");
        socialUserProfile.setProfileBackgroundImageUrl("/images/test.jpg");
        socialUserProfile.setProfileBackgroundTiled(Boolean.FALSE);
        socialUserProfile.setProfileImageUrl("/images/profile.jpg");
        socialUserProfile.setProfileLinkColor("#8B3232");
        socialUserProfile.setProfileSidebarBorderColor("#39CA51");
        socialUserProfile.setProfileSidebarFillColor("F0B615");
        socialUserProfile.setProfileTextColor("060606");
        socialUserProfile.setProfileUrl("/profile/jhonny");
        socialUserProfile.setProfileUseBackgroundImage(Boolean.FALSE);
        socialUserProfile.setProtected(Boolean.TRUE);
        socialUserProfile.setScreenName("myprofile");
        socialUserProfile.setShowAllInlineMedia(Boolean.FALSE);
        socialUserProfile.setStatusesCount(1);
        socialUserProfile.setTimeZone("GMT");
        socialUserProfile.setTranslator(Boolean.FALSE);
        socialUserProfile.setUrl("www.encuestame/profile/jhonny");
        socialUserProfile.setUsername("jhonny");
        socialUserProfile.setUtcOffset(0);
        socialUserProfile.setVerified(Boolean.FALSE);

        assertNotNull(socialUserProfile.isContributorsEnabled());
        assertNotNull(socialUserProfile.getCreatedAt());
        assertNotNull(socialUserProfile.getDescription());
        assertNotNull(socialUserProfile.getEmail());
        assertNotNull(socialUserProfile.getFavouritesCount());
        assertNotNull(socialUserProfile.getFirstName());
        assertNotNull(socialUserProfile.getFollowersCount());
        assertNotNull(socialUserProfile.isFollowRequestSent());
        assertNotNull(socialUserProfile.getFriendsCount());
        assertNotNull(socialUserProfile.isGeoEnabled());
        assertNotNull(socialUserProfile.getHeadline());
        assertNotNull(socialUserProfile.getId());
        assertNotNull(socialUserProfile.getIndustry());
        assertNotNull(socialUserProfile.getLang());
        assertNotNull(socialUserProfile.getLastName());
        assertNotNull(socialUserProfile.getListedCount());
        assertNotNull(socialUserProfile.getLocation());
        assertNotNull(socialUserProfile.getName());
        assertNotNull(socialUserProfile.getProfileBackgroundColor());
        assertNotNull(socialUserProfile.getProfileBackgroundImageUrl());
        assertNotNull(socialUserProfile.isProfileBackgroundTiled());
        assertNotNull(socialUserProfile.getProfileImageUrl());
        assertNotNull(socialUserProfile.getProfileLinkColor());
        assertNotNull(socialUserProfile.getProfileSidebarBorderColor());
        assertNotNull(socialUserProfile.getProfileSidebarFillColor());
        assertNotNull(socialUserProfile.getProfileTextColor());
        assertNotNull(socialUserProfile.getProfileUrl());
        assertNotNull(socialUserProfile.isProfileUseBackgroundImage());
        assertNotNull(socialUserProfile.isProtected());
        assertNotNull(socialUserProfile.getScreenName());
        assertNotNull(socialUserProfile.isShowAllInlineMedia());
        assertNotNull(socialUserProfile.getStatusesCount());
        assertNotNull(socialUserProfile.getTimeZone());
        assertNotNull(socialUserProfile.isTranslator());
        assertNotNull(socialUserProfile.getUrl());
        assertNotNull(socialUserProfile.getUsername());
        assertNotNull(socialUserProfile.getUtcOffset());
        assertNotNull(socialUserProfile.isVerified());
    }
View Full Code Here

     * @return
     */
    @Override
    public SocialUserProfile getProfile() {
        IdentiCaProfile profile = this.getUserProfile();
        final SocialUserProfile socialUserProfile = new SocialUserProfile();
        socialUserProfile.setDescription(profile.getDescription());
        socialUserProfile.setCreatedAt(profile.getCreatedDate());
        socialUserProfile.setId(String.valueOf(profile.getId()));
        socialUserProfile.setLocation(profile.getLocation());
        socialUserProfile.setProfileImageUrl(profile.getProfileImageUrl());
        socialUserProfile.setProfileUrl(profile.getProfileUrl());
        socialUserProfile.setScreenName(profile.getScreenName());
        socialUserProfile.setUsername(profile.getScreenName());
        socialUserProfile.setUrl(profile.getUrl());
        return socialUserProfile;
    }
View Full Code Here

     */
    @Override
    public SocialUserProfile getProfile() {
        final FacebookProfile facebookProfile = this.getUserProfile();
        Log.debug("Facebook PRofile "+facebookProfile.toString());
        final SocialUserProfile profile = new SocialUserProfile();
        profile.setEmail(facebookProfile.getEmail());
        profile.setFirstName(facebookProfile.getFirstName());
        profile.setLastName(facebookProfile.getLastName());
        profile.setId(String.valueOf(facebookProfile.getId()));
        profile.setProfileImageUrl(PICTURE_PROFILE_URL.replace("{objectId}", facebookProfile.getUsername()));
        profile.setName(facebookProfile.getName());
        profile.setUsername(facebookProfile.getUsername());
        return profile;
    }
View Full Code Here

    //about=,
    //nick_name=encuestame,
    //gender=2,
    //setup_twitter_sync=false,
    //karma=5.35}
    final SocialUserProfile socialUserProfile = new SocialUserProfile();
    socialUserProfile.setFollowersCount(0);
    socialUserProfile.setUsername(response.get("nick_name").toString());
    socialUserProfile.setId(response.get("id").toString());
    //get the primary blog
    socialUserProfile.setEmail(null);
    socialUserProfile.setCreatedAt(Calendar.getInstance().getTime());
    socialUserProfile.setName(response.get("full_name").toString());
    socialUserProfile.setUrl("http://www.plurk.com/" + socialUserProfile.getUsername());
    socialUserProfile.setProfileImageUrl("http://avatars.plurk.com/{user_id}-small.gif".replace("{user_id}", socialUserProfile.getId()));
    socialUserProfile.setScreenName(response.get("nick_name").toString());
    socialUserProfile.setLocation(response.get("location").toString());
    socialUserProfile.setDescription(response.get("about").toString());
    return socialUserProfile;
  }
View Full Code Here

     */
    public SocialUserProfile getProfile(){
        //TOOD: conver to BuzzProfile.
        //{data={id=null, displayName=null, kind=kined, aboutMe=abbout me, profileUrl=null, emails=[], url=[], photos=null, organizations=[]}}
        Map profileMap = getRestTemplate().getForObject(this.GOOGLE_REST_PROFILE, Map.class);
        final SocialUserProfile profile = new SocialUserProfile();
        Map data = (Map) profileMap.get("data");
        profile.setId(data.get("id").toString());
        profile.setName(data.get("displayName") == null ? "" : data.get("displayName").toString());
        profile.setProfileUrl(data.get("profileUrl") == null ? "" : data.get("profileUrl").toString());
        profile.setProfileImageUrl(data.get("thumbnailUrl") == null ? "" : data.get("thumbnailUrl").toString());
        profile.setDescription(data.get("aboutMe") == null ? "" : data.get("aboutMe").toString());
        //get list of emails.
        List emails = (ArrayList) data.get("emails");
        log.debug("email list "+emails.size());
        if (emails.size() == 0) {
            log.error("email list is emtpy");
        }
        final Map email = (Map) emails.get(0);
        log.debug("email  "+email);
        profile.setEmail(email.get("value") == null ? "" : email.get("value").toString());
        //split username.
        final String[] tokens = email.get("value").toString().split("@");
        profile.setScreenName(tokens[0]);
        profile.setUsername(tokens[0]);
        return profile;
    }
View Full Code Here

TOP

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

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.