public Article loadArticle(ArticleRef ref, OperationObserver observer) throws ParseException { String html = articlePagesCache.loadFromCache(ref.getPageRef(), observer); if (html != null) { Article article = TestDe.parseArticle(ref, html); if (!article.containsLockedSubArticles()) return article; if (loginDataProvider.getLoginData() == null) return article; if (!TestDe.http.isInternetAvailable()) return article; articlePagesCache.delete(ref.getPageRef()); } loginIfAvailable(observer); html = articlePagesCache.load(ref.getPageRef(), observer); return TestDe.parseArticle(ref, html); }
public File loadPdf( SubArticleRef subArticleRef, ArticleRef articleRef, OperationObserver observer) throws ParseException { if (!subArticleRef.isPdf()) throw new IllegalArgumentException("Sub article is not PDF: " + subArticleRef); File pdfFile = getPdfFile(subArticleRef); if (pdfFile.exists()) return pdfFile; loginIfAvailable(observer); TestDe.downloadPdf(subArticleRef, articleRef, pdfFile, observer); return pdfFile; }
public synchronized List<ArticleRef> updateIndex(OperationObserver observer) { getIndex(observer); List<ArticleRef> newArticles; try { newArticles = TestDe.update(index, observer); } catch (ParseException ex1) { throw new RuntimeException(ex1); } File indexFile = getIndexFile(); observer.onOperationInfoChanged(OperationObserver.SAVING, indexFile.getAbsolutePath()); try { JsonMapper.serialize(index, indexFile); } catch (IOException ex) { throw new RuntimeException(ex); } return newArticles; }
private synchronized void login(LoginData loginData, OperationObserver observer) { lastLogin = 0; TestDe.login(loginData, observer); lastLogin = System.currentTimeMillis(); }