/* Only one Login Dialog at the same time */
if (shellAr[0] != null && !shellAr[0].isDisposed()) {
fLoginDialogLock.lock();
try {
final AuthenticationRequiredException authEx = (AuthenticationRequiredException) e;
JobRunner.runSyncedInUIThread(shellAr[0], new Runnable() {
public void run() {
/* Return on Cancelation or shutdown or deletion */
if (!shouldProceedReloading(monitor, bookmark))
return;
/* Credentials might have been provided meanwhile in another dialog */
try {
URI normalizedUri = URIUtils.normalizeUri(feedLink, true);
if (Owl.getConnectionService().getAuthCredentials(normalizedUri, authEx.getRealm()) != null) {
reloadQueued(bookmark, shellAr[0]);
return;
}
} catch (CredentialsException exe) {
Activator.getDefault().getLog().log(exe.getStatus());
}
/* Show Login Dialog */
LoginDialog login = new LoginDialog(shellAr[0], feedLink, authEx.getRealm());
if (login.open() == Window.OK && shouldProceedReloading(monitor, bookmark)) {
/* Store info about Realm in Bookmark */
if (StringUtils.isSet(authEx.getRealm())) {
bookmark.setProperty(BM_REALM_PROPERTY, authEx.getRealm());
fBookMarkDAO.save(bookmark);
}
/* Re-Reload Bookmark */
reloadQueued(bookmark, shellAr[0]);
}
/* Update Error Flag if user hit Cancel */
else if (shouldProceedReloading(monitor, bookmark) && !bookmark.isErrorLoading()) {
bookmark.setErrorLoading(true);
if (StringUtils.isSet(authEx.getMessage()))
bookmark.setProperty(LOAD_ERROR_KEY, authEx.getMessage());
fBookMarkDAO.save(bookmark);
}
}
});