protected void extractData( final FacebookProfile profile, final JsonNode json, final String name) { final JsonNode data = (JsonNode) JsonHelper.getElement(json, name); if (data != null) { profile.addAttribute(name, JsonHelper.getElement(data, "data")); } }
@Override protected void buildFromJson(final JsonNode json) { this.id = (String) JsonHelper.convert(Converters.stringConverter, json, "id"); this.category = (String) JsonHelper.convert(Converters.stringConverter, json, "category"); this.name = (String) JsonHelper.convert(Converters.stringConverter, json, "name"); this.createdTime = (Date) JsonHelper.convert(Converters.dateConverter, json, "created_time"); }
@Override protected TestOAuth1Profile extractUserProfile(String body) { final TestOAuth1Profile profile = new TestOAuth1Profile(); JsonNode json = JsonHelper.getFirstNode(body); if (json != null) { profile.setId(JsonHelper.get(json, "id")); } return profile; }
@Override protected void buildFromJson(final JsonNode json) { this.version = (Integer) JsonHelper.convert(Converters.integerConverter, json, "version"); this.name = (String) JsonHelper.convert(Converters.stringConverter, json, "name"); this.id = (String) JsonHelper.convert(Converters.stringConverter, json, "id"); this.administrator = (Boolean) JsonHelper.convert(Converters.booleanConverter, json, "administrator"); this.bookmarkOrder = (Integer) JsonHelper.convert(Converters.integerConverter, json, "bookmark_order"); }
@Override public OkProfile extractUserProfile(String body) throws HttpAction { final OkProfile profile = newProfile(); JsonNode userNode = JsonHelper.getFirstNode(body); if (userNode != null) { profile.setId(JsonHelper.getElement(userNode, OkProfileDefinition.UID)); for (final String attribute : getPrimaryAttributes()) { convertAndAdd(profile, attribute, JsonHelper.getElement(userNode, attribute)); } } return profile; }
@Override protected OkProfile extractUserProfile(String body) { final OkProfile profile = new OkProfile(); JsonNode userNode = JsonHelper.getFirstNode(body); if (userNode != null) { profile.setId(JsonHelper.getElement(userNode, OkAttributesDefinition.UID)); for (final String attribute : profile.getAttributesDefinition().getPrimaryAttributes()) { profile.addAttribute(attribute, JsonHelper.getElement(userNode, attribute)); } } return profile; }
@Override protected Google2Profile extractUserProfile(final String body) { final Google2Profile profile = new Google2Profile(); final JsonNode json = JsonHelper.getFirstNode(body); if (json != null) { profile.setId(JsonHelper.get(json, "id")); for (final String attribute : OAuthAttributesDefinitions.google2Definition.getPrincipalAttributes()) { profile.addAttribute(attribute, JsonHelper.get(json, attribute)); } } return profile; }
@Override protected WordPressProfile extractUserProfile(final String body) { final WordPressProfile profile = new WordPressProfile(); JsonNode json = JsonHelper.getFirstNode(body); if (json != null) { profile.setId(JsonHelper.get(json, "ID")); for (final String attribute : OAuthAttributesDefinitions.wordPressDefinition.getPrincipalAttributes()) { profile.addAttribute(attribute, JsonHelper.get(json, attribute)); } json = json.get("meta"); if (json != null) { final String attribute = WordPressAttributesDefinition.LINKS; profile.addAttribute(attribute, JsonHelper.get(json, attribute)); } } return profile; }
@Override protected FacebookProfile extractUserProfile(final String body) { final FacebookProfile profile = new FacebookProfile(); final JsonNode json = JsonHelper.getFirstNode(body); if (json != null) { profile.setId(JsonHelper.getElement(json, "id")); for (final String attribute : profile.getAttributesDefinition().getPrimaryAttributes()) { profile.addAttribute(attribute, JsonHelper.getElement(json, attribute)); } extractData(profile, json, FacebookAttributesDefinition.FRIENDS); extractData(profile, json, FacebookAttributesDefinition.MOVIES); extractData(profile, json, FacebookAttributesDefinition.MUSIC); extractData(profile, json, FacebookAttributesDefinition.BOOKS); extractData(profile, json, FacebookAttributesDefinition.LIKES); extractData(profile, json, FacebookAttributesDefinition.ALBUMS); extractData(profile, json, FacebookAttributesDefinition.EVENTS); extractData(profile, json, FacebookAttributesDefinition.GROUPS); extractData(profile, json, FacebookAttributesDefinition.MUSIC_LISTENS); extractData(profile, json, FacebookAttributesDefinition.PICTURE); } return profile; }