import org.apache.log4j.Logger;
import org.h2.tools.ChangeFileEncryption;
+import com.evernote.edam.error.EDAMErrorCode;
import com.evernote.edam.error.EDAMNotFoundException;
import com.evernote.edam.error.EDAMSystemException;
import com.evernote.edam.error.EDAMUserException;
syncRunner.status.message.connect(this, "setMessage(String)");
syncRunner.syncSignal.finished.connect(this, "syncThreadComplete(Boolean)");
syncRunner.syncSignal.errorDisconnect.connect(this, "remoteErrorDisconnect()");
+ syncRunner.limitSignal.rateLimitReached.connect(this, "informRateLimit(Integer)");
syncRunning = false;
if (syncTime > 0) {
automaticSync = true;
setMessage("EDAMUserException: " +e.getMessage());
return;
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ QMessageBox.warning(this, tr("Rate limit reached"), tr("Rate limit reached.\nRetry your request in " + e.getRateLimitDuration() + " seconds."));
+ }
setMessage("EDAMSystemException: " +e.getMessage());
return;
} catch (EDAMNotFoundException e) {
waitCursor(false);
return null;
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ QMessageBox.warning(this, tr("Rate limit reached"), tr("Rate limit reached.\nRetry your request in " + e.getRateLimitDuration() + " seconds."));
+ }
setMessage("EDAMSystemException: " +e.getMessage());
waitCursor(false);
return null;
setMessage("EDAMUserException: " +e.getMessage());
return;
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ QMessageBox.warning(this, tr("Rate limit reached"), tr("Rate limit reached.\nRetry your request in " + e.getRateLimitDuration() + " seconds."));
+ }
setMessage("EDAMSystemException: " +e.getMessage());
return;
} catch (TException e) {
public RensoNoteList getRensoNoteList() {
return rensoNoteListDock.getRensoNoteList();
}
+
+ // 帯域制限の超過をユーザに通知
+ @SuppressWarnings("unused")
+ private void informRateLimit(Integer rateLimitDuration) {
+ QMessageBox.warning(this, tr("Rate limit reached"), tr("Rate limit reached.\nRetry your request in " + rateLimitDuration + " seconds."));
+ }
}
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
+import com.evernote.edam.error.EDAMErrorCode;
import com.evernote.edam.error.EDAMNotFoundException;
import com.evernote.edam.error.EDAMSystemException;
import com.evernote.edam.error.EDAMUserException;
import cx.fbn.nevernote.Global;
import cx.fbn.nevernote.signals.ENRelatedNotesSignal;
+import cx.fbn.nevernote.signals.LimitSignal;
import cx.fbn.nevernote.utilities.ApplicationLogger;
import cx.fbn.nevernote.utilities.Pair;
public class ENRelatedNotesRunner extends QObject implements Runnable{
- private final ApplicationLogger logger;
- private final SyncRunner syncRunner;
- public volatile ENRelatedNotesSignal enRelatedNotesSignal;
- public QMutex mutex;
- private volatile boolean keepRunning;
- private volatile LinkedBlockingQueue<String> workQueue;
+ private final ApplicationLogger logger;
+ private final SyncRunner syncRunner;
+ public volatile ENRelatedNotesSignal enRelatedNotesSignal;
+ public QMutex mutex;
+ private volatile boolean keepRunning;
+ private volatile LinkedBlockingQueue<String> workQueue;
private volatile LinkedBlockingQueue<Pair<String, List<String>>> resultQueue; // ペア<元ノートguid, 関連ノートguidリスト>を溜めておくキュー
+ public volatile LimitSignal limitSignal;
public ENRelatedNotesRunner(SyncRunner syncRunner, ApplicationLogger logger) {
this.logger = logger;
this.keepRunning = true;
this.workQueue = new LinkedBlockingQueue<String>();
this.resultQueue = new LinkedBlockingQueue<Pair<String, List<String>>>();
+ this.limitSignal = new LimitSignal();
}
@Override
} catch (EDAMUserException e) {
logger.log(logger.HIGH, "Evernote関連ノート取得中に例外発生:EDAMUserException");
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e.getRateLimitDuration());
+ }
logger.log(logger.HIGH, "Evernote関連ノート取得中に例外発生:EDAMSystemException");
} catch (EDAMNotFoundException e) {
logger.log(logger.HIGH, "Evernote関連ノート取得中に例外発生:EDAMnotFoundException guid = " + guid);
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
+import com.evernote.edam.error.EDAMErrorCode;
import com.evernote.edam.error.EDAMNotFoundException;
import com.evernote.edam.error.EDAMSystemException;
import com.evernote.edam.error.EDAMUserException;
import com.trolltech.qt.core.QTextCodec;
import com.trolltech.qt.gui.QMessageBox;
+import cx.fbn.nevernote.signals.LimitSignal;
import cx.fbn.nevernote.signals.NoteIndexSignal;
import cx.fbn.nevernote.signals.NoteResourceSignal;
import cx.fbn.nevernote.signals.NoteSignal;
public volatile SavedSearchSignal searchSignal;
public volatile NoteResourceSignal resourceSignal;
public volatile SyncSignal syncSignal;
+ public volatile LimitSignal limitSignal;
public volatile boolean authRefreshNeeded;
public volatile boolean syncNeeded;
public volatile boolean disableUploads;
searchSignal = new SavedSearchSignal();
syncSignal = new SyncSignal();
resourceSignal = new NoteResourceSignal();
+ limitSignal = new LimitSignal();
resourceUrl = r;
indexUrl = i;
// ICHANGED
enDisconnect();
return;
} catch (EDAMSystemException e1) {
+ if (e1.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e1.getRateLimitDuration());
+ }
+
e1.printStackTrace();
status.message.emit(tr("System error user account information. Aborting sync and disconnecting!"));
syncSignal.errorDisconnect.emit();
enDisconnect();
return;
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e.getRateLimitDuration());
+ }
e.printStackTrace();
status.message.emit(tr("Error getting sync state! Aborting sync and disconnecting!"));
syncSignal.errorDisconnect.emit();
} catch (EDAMUserException e) {
logger.log(logger.LOW, "EDAM User Excepton in syncExpunged: " +expunged.get(i).guid); // This can happen if we try to delete a deleted note
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e.getRateLimitDuration());
+ }
logger.log(logger.LOW, "EDAM System Excepton in syncExpunged: "+expunged.get(i).guid);
logger.log(logger.LOW, e.getStackTrace());
error=true;
//logger.log(logger.LOW, e.toString());
//error = true;
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e.getRateLimitDuration());
+ }
logger.log(logger.LOW, "*** EDAM System Excepton syncLocalNotes "+e);
status.message.emit(tr("Error: ") +e);
logger.log(logger.LOW, e.toString());
logger.log(logger.LOW, e.toString());
error = true;
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e.getRateLimitDuration());
+ }
logger.log(logger.LOW, "*** EDAM System Excepton syncLocalNotes "+e);
status.message.emit(tr("Error: ") +e);
logger.log(logger.LOW, e.toString());
logger.log(logger.LOW, e1.toString());
error = true;
} catch (EDAMSystemException e1) {
+ if (e1.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e1.getRateLimitDuration());
+ }
logger.log(logger.LOW, "*** EDAM System Excepton syncLocalNotebooks getting remote Notebook List");
status.message.emit(tr("Error: ") +e1);
logger.log(logger.LOW, e1.toString());
logger.log(logger.LOW, e.toString() + ": Stack : " +enNotebook.getStack());
error = true;
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e.getRateLimitDuration());
+ }
logger.log(logger.LOW, "*** EDAM System Excepton syncLocalNotebooks");
logger.log(logger.LOW, e.toString());
error = true;
logger.log(logger.LOW, e1.toString());
error = true;
} catch (EDAMSystemException e1) {
+ if (e1.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e1.getRateLimitDuration());
+ }
logger.log(logger.LOW, "*** EDAM System Excepton syncLocalTags getting remote Tag List");
status.message.emit(tr("Error: ") +e1);
logger.log(logger.LOW, e1.toString());
badTagSync.put(enTag.getGuid(),null);
error = true;
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e.getRateLimitDuration());
+ }
logger.log(logger.LOW, "** EDAM System Excepton syncLocalTags: " +enTag.getName());
logger.log(logger.LOW, e.toString());
badTagSync.put(enTag.getGuid(),null);
error = true;
e.printStackTrace();
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e.getRateLimitDuration());
+ }
logger.log(logger.LOW, "*** EDAM System Excepton syncLocalLinkedNotebooks");
status.message.emit(tr("Error: ") +e);
logger.log(logger.LOW, e.toString());
logger.log(logger.LOW, e1.toString());
error = true;
} catch (EDAMSystemException e1) {
+ if (e1.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e1.getRateLimitDuration());
+ }
logger.log(logger.LOW, "*** EDAM System Excepton syncLocalTags getting remote saved search List");
status.message.emit(tr("Error: ") +e1);
logger.log(logger.LOW, e1.toString());
logger.log(logger.LOW, e.toString());
error = true;
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e.getRateLimitDuration());
+ }
logger.log(logger.LOW, "** EDAM System Excepton syncLocalTags");
logger.log(logger.LOW, e.toString());
error = true;
e.printStackTrace();
status.message.emit(e.getMessage());
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e.getRateLimitDuration());
+ }
error = true;
e.printStackTrace();
status.message.emit(e.getMessage());
error = true;
e.printStackTrace();
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e.getRateLimitDuration());
+ }
logger.log(logger.LOW, "*** EDAM System Excepton getEvernoteNote");
logger.log(logger.LOW, e.toString());
error = true;
error = true;
e.printStackTrace();
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e.getRateLimitDuration());
+ }
logger.log(logger.LOW, "*** EDAM System Excepton getEvernoteNote");
logger.log(logger.LOW, e.toString());
error = true;
isConnected = false;
return false;
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e.getRateLimitDuration());
+ }
QMessageBox mb = new QMessageBox(QMessageBox.Icon.Critical, "EDAM System Excepton", e.getLocalizedMessage());
mb.exec();
e.printStackTrace();
} catch (EDAMUserException e1) {
e1.printStackTrace();
} catch (EDAMSystemException e1) {
+ if (e1.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e1.getRateLimitDuration());
+ }
e1.printStackTrace();
} catch (TException e1) {
e1.printStackTrace();
logger.log(logger.LOW, e1.getMessage());
return;
} catch (EDAMSystemException e1) {
+ if (e1.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e1.getRateLimitDuration());
+ }
e1.printStackTrace();
status.message.emit(tr("System exception Listing shared notebooks."));
logger.log(logger.LOW, e1.getMessage());
logger.log(logger.LOW, e1.getMessage());
return;
} catch (EDAMSystemException e1) {
+ if (e1.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e1.getRateLimitDuration());
+ }
e1.printStackTrace();
status.message.emit(tr("System exception Listing notebooks."));
logger.log(logger.LOW, e1.getMessage());
logger.log(logger.LOW, e1.getMessage());
return;
} catch (EDAMSystemException e1) {
+ if (e1.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e1.getRateLimitDuration());
+ }
e1.printStackTrace();
status.message.emit(tr("System exception Listing linked notebooks."));
logger.log(logger.LOW, e1.getMessage());
error = true;
e.printStackTrace();
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e.getRateLimitDuration());
+ }
error = true;
logger.log(logger.LOW, "System error authenticating against shared notebook. "+
"Key: "+books.get(i).getShareKey() +" Error:" +e.getMessage());
e.printStackTrace();
logger.log(logger.LOW, tr("EDAM UserException synchronizing linked notbook ")+ e.getMessage());
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e.getRateLimitDuration());
+ }
syncError = true;
status.message.emit(tr("EDAM SystemException synchronizing linked notbook. See the log for datails."));
e.printStackTrace();
readOnly = true;
e.printStackTrace();
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e.getRateLimitDuration());
+ }
readOnly = true;
e.printStackTrace();
} catch (TException e) {
} catch (EDAMUserException e) {
e.printStackTrace();
} catch (EDAMSystemException e) {
+ if (e.getErrorCode() == EDAMErrorCode.RATE_LIMIT_REACHED) {
+ limitSignal.rateLimitReached.emit(e.getRateLimitDuration());
+ }
e.printStackTrace();
} catch (EDAMNotFoundException e) {
e.printStackTrace();