/** * This can be optimized to use the download technique with the listeners. * Now just a quick hack to make it work. I actually think these classes * should extend FileRepo. TODO */ @Override public File get(String bsn, Version version, Map<String, String> properties, DownloadListener... listeners) throws Exception { init(); String versionStr; if (version != null) versionStr = version.toString(); else versionStr = properties.get(PROP_VERSION_KEY); ResourceHandle handle = resolveBundle(bsn, versionStr, Strategy.EXACT, properties); if (handle == null) return null; File f = handle.request(); if (f == null) return null; for (DownloadListener l : listeners) { try { l.success(f); } catch (Exception e) { error("Download listener for %s: %s", f, e); } } return f; }
/** * Get a bundle */ @Override public File get(String bsn, Version version, Map<String, String> properties, final DownloadListener... listeners) throws Exception { init(); index.sync(); // make sure all is downloaded & parsed Archive archive = index.find(bsn, version); if (archive == null) { return null; } File f = storage.toLocalFile(archive); File withSources = new File(f.getParentFile(), "+" + f.getName()); if (withSources.isFile() && withSources.lastModified() > f.lastModified()) f = withSources; if (listeners.length == 0) { return f; } for (DownloadListener dl : listeners) { try { dl.success(f); } catch (Exception e) { logger.warn("updating listener has error", e); } } return f; }
/** * This can be optimized to use the download technique with the listeners. * Now just a quick hack to make it work. I actually think these classes * should extend FileRepo. TODO */ @Override public File get(String bsn, Version version, Map<String, String> properties, DownloadListener... listeners) throws Exception { init(); String versionStr; if (version != null) versionStr = version.toString(); else versionStr = properties.get(PROP_VERSION_KEY); ResourceHandle handle = resolveBundle(bsn, versionStr, Strategy.EXACT, properties); if (handle == null) return null; File f = handle.request(); if (f == null) return null; for (DownloadListener l : listeners) { try { l.success(f); } catch (Exception e) { error("Download listener for %s: %s", f, e); } } return f; }
/** * Get a bundle */ @Override public File get(String bsn, Version version, Map<String, String> properties, final DownloadListener... listeners) throws Exception { init(); index.sync(); // make sure all is downloaded & parsed Archive archive = index.find(bsn, version); if (archive == null) { return null; } File f = storage.toLocalFile(archive); File withSources = new File(f.getParentFile(), "+" + f.getName()); if (withSources.isFile() && withSources.lastModified() > f.lastModified()) f = withSources; if (listeners.length == 0) { return f; } for (DownloadListener dl : listeners) { try { dl.success(f); } catch (Exception e) { logger.warn("updating listener has error", e); } } return f; }
@Override public File get(String bsn, Version version, Map<String, String> properties, DownloadListener... listeners) throws Exception { init(); beforeGet(bsn, version); File file = getLocal(bsn, version, properties); if (file.exists()) { for (DownloadListener l : listeners) { try { l.success(file); } catch (Exception e) { reporter.exception(e, "Download listener for %s", file); } } return file; } return null; }
public File get(String bsn, Version version, Map<String,String> properties, DownloadListener... listeners) throws Exception { init(); beforeGet(bsn, version); File file = getLocal(bsn, version, properties); if (file.exists()) { for (DownloadListener l : listeners) { try { l.success(file); } catch (Exception e) { reporter.exception(e, "Download listener for %s", file); } } return file; } return null; }
public File get(String bsn, Version version, Map<String,String> properties, DownloadListener... listeners) throws Exception { init(); beforeGet(bsn, version); File file = getLocal(bsn, version, properties); if (file.exists()) { for (DownloadListener l : listeners) { try { l.success(file); } catch (Exception e) { reporter.exception(e, "Download listener for %s", file); } } return file; } return null; }
public File get(String bsn, Version version, Map<String,String> properties, DownloadListener... listeners) throws Exception { init(); beforeGet(bsn, version); File file = getLocal(bsn, version, properties); if (file.exists()) { for (DownloadListener l : listeners) { try { l.success(file); } catch (Exception e) { reporter.exception(e, "Download listener for %s", file); } } return file; } return null; }
/** * Just report success to all download listeners * * @param blockers * @param file */ void ok(DownloadListener[] blockers, File file) { for (DownloadListener dl : blockers) { try { dl.success(file); } catch (Exception e) { // } } }
@Override public File get(String bsn, Version version, Map<String, String> properties, DownloadListener... listeners) throws Exception { File file = get(bsn, version.toString(), Strategy.EXACT, properties); if (file == null) return null; for (DownloadListener l : listeners) { try { l.success(file); } catch (Exception e) { reporter.exception(e, "Download listener for %s", file); } } return file; } }
/** * Just report success to all download listeners * * @param blockers * @param file */ void ok(DownloadListener[] blockers, File file) { for (DownloadListener dl : blockers) { try { dl.success(file); } catch (Exception e) { // } } }
@Override public File get(String bsn, Version version, Map<String, String> properties, DownloadListener... listeners) throws Exception { init(); beforeGet(bsn, version); File file = getLocal(bsn, version, properties); if (file.exists()) { for (DownloadListener l : listeners) { try { l.success(file); } catch (Exception e) { reporter.exception(e, "Download listener for %s", file); } } return file; } return null; }
public File get(String bsn, Version version, Map<String,String> properties, DownloadListener... listeners) throws Exception { File file = get(bsn, version.toString(), Strategy.EXACT, properties); if (file == null) return null; for (DownloadListener l : listeners) { try { l.success(file); } catch (Exception e) { workspace.exception(e, "Workspace repo listener callback for %s", file); } } return file; }
@Override public File get(String bsn, Version version, Map<String, String> properties, DownloadListener... listeners) throws Exception { File file = get(bsn, version.toString(), Strategy.EXACT, properties); if (file == null) return null; for (DownloadListener l : listeners) { try { l.success(file); } catch (Exception e) { workspace.exception(e, "Workspace repo listener callback for %s", file); } } return file; }
public File get(String bsn, Version version, Map<String,String> properties, DownloadListener... listeners) throws Exception { File file = get(bsn, version.toString(), Strategy.EXACT, properties); if (file == null) return null; for (DownloadListener l : listeners) { try { l.success(file); } catch (Exception e) { workspace.exception(e, "Workspace repo listener callback for %s", file); } } return file; }
public File get(String bsn, Version version, Map<String,String> properties, DownloadListener ... listeners) throws Exception { File file = get(bsn, version.toString(), Strategy.EXACT, properties); if ( file == null) return null; for (DownloadListener l : listeners) { try { l.success(file); } catch (Exception e) { reporter.exception(e, "Download listener for %s", file); } } return file; } }
/** * Just report success to all download listeners * * @param blockers * @param file */ void ok(DownloadListener[] blockers, File file) { for (DownloadListener dl : blockers) { try { dl.success(file); } catch (Exception e) { // } } }
@Override public File get(String bsn, Version version, Map<String, String> properties, DownloadListener... listeners) throws Exception { File f = get(bsn, version.toString(), Strategy.EXACT, properties); if (f == null) return null; for (DownloadListener l : listeners) { try { l.success(f); } catch (Exception e) { reporter.exception(e, "Download listener for %s", f); } } return f; }