@Override public List<RepoPackage> getAllPackages() throws IOException { final Map<String, String> packageToVersionMap; try { packageToVersionMap = PyPIPackageUtil.INSTANCE.loadAndGetPackages(); } catch (IOException e) { throw new IOException( "Could not reach URL " + e.getMessage() + ". Please, check your internet connection."); } List<RepoPackage> packages = versionMapToPackageList(packageToVersionMap); packages.addAll(PyPIPackageUtil.INSTANCE.getAdditionalPackageNames()); return packages; }
@Override public List<RepoPackage> reloadAllPackages() throws IOException { final PyPackageService service = PyPackageService.getInstance(); PyPIPackageUtil.INSTANCE.updatePyPICache(service); service.LAST_TIME_CHECKED = System.currentTimeMillis(); return getAllPackages(); }
@Override public void fetchPackageDetails( final String packageName, final CatchingConsumer<String, Exception> consumer) { PyPIPackageUtil.INSTANCE.fillPackageDetails( packageName, new AsyncCallback() { @Override public void handleResult(Object result, URL url, String method) { final Hashtable details = (Hashtable) result; PyPIPackageUtil.INSTANCE.addPackageDetails(packageName, details); consumer.consume(formatPackageDetails(details)); } @Override public void handleError(Exception exception, URL url, String method) { consumer.consume(exception); } }); }
@Override public void fetchPackageVersions( final String packageName, final CatchingConsumer<List<String>, Exception> consumer) { PyPIPackageUtil.INSTANCE.usePackageReleases( packageName, new AsyncCallback() { @Override public void handleResult(Object result, URL url, String method) { final List<String> releases = (List<String>) result; PyPIPackageUtil.INSTANCE.addPackageReleases(packageName, releases); consumer.consume(releases); } @Override public void handleError(Exception exception, URL url, String method) { consumer.consume(exception); } }); }