Plus plus = new Plus.Builder(TRANSPORT, JSON_FACTORY, credential)
.setApplicationName(Constants.GOOGLE_APPLICATION_NAME)
.build();
Person person = plus.people().get("me").execute();
// 表示名
if(person.getDisplayName() != null && !person.getDisplayName().isEmpty()) {
userModel.setDisplayName(person.getDisplayName());
}
// 写真
if(person.getImage() != null && !person.getImage().isEmpty()) {
userModel.setImageUrl(new Text(person.getImage().getUrl()));
}
// キャッチ
if(person.getTagline() != null && !person.getTagline().isEmpty()) {
userModel.setTagline(new Text(person.getTagline()));
}
// 特技
if(person.getBraggingRights() != null && !person.getBraggingRights().isEmpty()) {
userModel.setBraggingRights(new Text(person.getBraggingRights()));
}
// About Me
if(person.getAboutMe() != null && !person.getAboutMe().isEmpty()) {
userModel.setAboutMe(new Text(person.getAboutMe()));
}
// 背景画像url
if(person.getCover() != null
&& person.getCover().getCoverPhoto() != null
&& person.getCover().getCoverPhoto().getUrl() != null
&& !person.getCover().getCoverPhoto().getUrl().isEmpty()) {
userModel.setCoverPhotoUrl(new Text(person.getCover().getCoverPhoto().getUrl()));
}
userModel.setUpdateCheckDate(new Date());
UserService.put(userModel);
// URLSを削除して再登録
UserUrlsService.deleteAll(userModel);
if(person.getUrls() != null && person.getUrls().size() > 0) {
List<Urls> urlsList = person.getUrls();
for(Urls urls: urlsList) {
UserUrlsService.put(userModel, urls.getValue(), urls.getType(), urls.getLabel());
}
}