我正在将Evernote功能集成到我的项目中。目前,我可以保存便笺,但是当我在便笺对象中添加标签时,它们在evernote方面不会得到更新。另外,当我编辑Evernote笔记对象时,时间戳不会在evernote一侧更新。我究竟做错了什么?到目前为止,没有错误日志。谢谢..
代码:
@Override
public boolean pushNoteToEvernote(int groupNoteId) {
System.out.println("Push note to evernote is called. ");
GroupNotes groupNotes = this.groupNotesService.getGroupNoteById(groupNoteId);
if (!(groupNotes == null)) {
try {
Person person = this.personService.getCurrentlyAuthenticatedUser();
if (person.isEvernoteConsumed()) {
EverNote everNote = getUsersEvernote(person.getId());
com.evernote.auth.EvernoteAuth evernoteAuth = new EvernoteAuth(EVERNOTE_SERVICE, everNote.getAccessToken());
NoteStoreClient noteStoreClient = new ClientFactory(evernoteAuth).createNoteStoreClient();
NoteSelection noteSelection = this.noteSelectionService.checkIfSelectionValid(groupNoteId, person.getId());
if (!(noteSelection == null)) {
if (!(noteSelection.getEverNoteGuid() == null)) {
Note note = findNoteById(noteSelection.getEverNoteGuid());
if ((note != null)) {
if(groupNotes.getMnotetag()!=null) {
String c = groupNotes.getMnotetag();
Pattern pt = Pattern.compile("[^a-zA-Z0-9]");
Matcher match = pt.matcher(c);
while (match.find()) {
String s = match.group();
c = c.replaceAll("\\" + s, "");
}
note.setTitle(c);
}
note.setUpdatedIsSet(true);
//note.setTitle(groupNotes.getMnotetag());
String nBody = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
nBody += "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">";
nBody += "<en-note>" + Jsoup.parse(groupNotes.getMnotetext()).text() + "</en-note>";
note.setContent(nBody);
Note savedNote = noteStoreClient.updateNote(note);
if(groupNotes.getTags()!=null) {
String[] tagsList = groupNotes.getTags().split(",");
List<String> stringList = new ArrayList<>();
Collections.addAll(stringList,tagsList);
note.setTagNames(stringList);
}
this.noteSelectionService.updateSelectionWithGuid(groupNoteId, person.getId(), savedNote.getGuid());
} else {
this.noteSelectionService.deleteSelection(groupNoteId);
saveNoteToEvernote(groupNotes, person.getId(), noteStoreClient);
}
} else {
saveNoteToEvernote(groupNotes, person.getId(), noteStoreClient);
return true;
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
return false;
}
谢谢。
最佳答案
您可能需要尝试以下几件事:
note.updated是服务器端分配的值,因此您无需note.setUpdatedIsSet(true)
。同样,通常,***IsSet
是与节俭相关的标志,除非您确实需要,否则您不想显式设置它。
我不完全知道noteSelectionService
的作用,但是您在拥有note
的同时将标签设置为savedNote
。使用Note#setTagNames
应该很好,因此您可以确保使用正确的参数调用updateNote
API吗?
关于java - Evernote:按下对象时更新时间注释,不包含标签,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45079017/