private void checkAllBooksInstalled() { BookInstaller bookInstaller = new BookInstaller(); List<Book> books = (List<Book>) bookInstaller.getRepositoryBooks(REPOSITORY, BOOK_FILTER); for (Book book : books) { try { Book installedBook = bookInstaller.getInstalledBook(book.getInitials()); if (installedBook == null) { System.out.println("Not installed:" + book.getInitials() + " Name:" + book.getName()); } else { Version versionObj = (Version) book.getProperty("Version"); String version = versionObj == null ? "No version" : versionObj.toString(); Version installedVersionObj = (Version) installedBook.getBookMetaData().getProperty("Version"); String installedVersion = installedVersionObj == null ? "No version" : installedVersionObj.toString(); if (!version.equals(installedVersion)) { System.out.println( "Incorrect version of " + book.getInitials() + " installed:" + installedVersion + " Repo:" + version); } else { System.out.println("Okay:" + book.getInitials() + " " + version); } } } catch (Exception e) { System.out.println("Error installing:" + book.getInitials()); e.printStackTrace(); } } }
private void installSingleBook(String initials) { BookInstaller bookInstaller = new BookInstaller(); List<Book> books = (List<Book>) bookInstaller.getRepositoryBooks(REPOSITORY, BOOK_FILTER); for (Book book : books) { if (initials.equalsIgnoreCase(book.getInitials())) { String lang = book.getLanguage() == null ? " " : book.getLanguage().getCode(); System.out.println("Found in repo:" + lang + " " + book.getName()); try { if (Books.installed().getBook(book.getInitials()) != null) { System.out.println("Already installed:" + book.getInitials() + ":" + book.getName()); } else { System.out.println( "Downloading and installing:" + book.getInitials() + ":" + book.getName()); bookInstaller.installBook(REPOSITORY, book); waitToFinish(); } Book installedBook = bookInstaller.getInstalledBook(book.getInitials()); if (installedBook == null) { System.out.println("Not installed:" + book.getInitials() + " Name:" + book.getName()); } } catch (Exception e) { System.out.println("Error installing:" + book.getInitials()); e.printStackTrace(); } } } }
private void showRepoBooks() { BookInstaller bookInstaller = new BookInstaller(); List<Book> books = (List<Book>) bookInstaller.getRepositoryBooks(REPOSITORY, BOOK_FILTER); for (Book book : books) { String lang = book.getLanguage() == null ? " " : book.getLanguage().getCode(); System.out.println(lang + " " + book.getName()); } }
private void installRepoBooks() { BookInstaller bookInstaller = new BookInstaller(); List<Book> books = (List<Book>) bookInstaller.getRepositoryBooks(REPOSITORY, BOOK_FILTER); for (Book book : books) { try { if (Books.installed().getBook(book.getInitials()) != null) { System.out.println("Already installed:" + book.getInitials() + ":" + book.getName()); } else { System.out.println( "Downloading and installing:" + book.getInitials() + ":" + book.getName()); bookInstaller.installBook(REPOSITORY, book); waitToFinish(); } } catch (Exception e) { System.out.println("Error installing:" + book.getInitials()); e.printStackTrace(); } } }