我正致力于将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;
}
谢谢。
答案 0 :(得分:1)
您可能想尝试一些事项:
note.setUpdatedIsSet(true)
。另外,一般情况下,***IsSet
是一个与节俭相关的标志,除非你真的需要,否则你不想明确设置。noteSelectionService
做了什么,但是当你有note
时,你正在设置标签savedNote
。使用Note#setTagNames
应该是好的,那么您是否可以确保使用正确的参数调用updateNote
API?