protected static final JacksonFactory JSON_FACTORY = new JacksonFactory();
@Override
public Navigation run() throws Exception {
UserModel userModel = null;
try{
userModel = getUser();
}catch(Exception e) {
return null;
};
// タスクは成功するまで実行されるため、失敗時は例外をキャッチして再実行をさせない
try{
// アクティビティの取得
String activityId = asString("activityId");
ActivityModel activityModel = ActivityService.getActivity(activityId);
if(activityModel == null) return null;
// 再共有の場合は投稿対象外にする
if(activityModel.getVerb().getCategory().equals(Constants.GOOGLE_ACTIVITY_VERB_TYPE_SHARE)) {
return null;
}
// Evernote オブジェクトの取得
NoteStoreClient noteStoreClient = getNoteStoreClient(userModel);
Note note = new Note();
note.setTitle(getNoteTitle(activityModel));
// ノートBody
String nBody = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
nBody += "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">";
nBody += "<en-note>";
nBody += "<div style=\"font-family: 'Helvetica Neue', Helvetica, Arial, 'Liberation Sans', FreeSans, sans-serif; color: rgb(88, 89, 87); font-size: 14px; line-height: 1.5; overflow-y: hidden; background: rgb(230, 230, 230);margin: -20px;\">";
nBody += "<div style=\"height: 40px;\"> </div>";
nBody += "<div style=\"max-width: 600px;padding: 25px 0px 0px 0px;background-color: #fff;margin: 0 auto;box-shadow: 0 0px 5px rgba(0, 0, 0, 0.2);\">";
nBody += Utils.removeLinkTags(getNoteContents(activityModel));
nBody += getNoteAttachmentsContents(activityModel);
// 下部メニュー
nBody += "<div style=\"background: #f5f5f5;min-height: 16px;padding: 1px 30px;text-align: center;border-top: 1px solid #ebebeb;margin-top: 20px;\">";
nBody += "<p style=\"color: #747474;line-height: 1.5em;\">";
nBody += "<a href=\"" + activityModel.getUrlString() + "\" style=\"text-decoration: none;color: #747474;\" target=\"_blank\">Google+で見る</a>";
nBody += "</p>";
nBody += "</div>";
nBody += "</div>";
nBody += "<div style=\"height: 40px;\"> </div>";
nBody += "</div>";
nBody += "</en-note>";
note.setContent(nBody);
if(userModel.getEvernoteNotebookId() != null) {
note.setNotebookGuid(userModel.getEvernoteNotebookId());
}
noteStoreClient.createNote(note);