public boolean delete(String repoId, byte[] id) throws Exception { ResourceDescriptorImpl rd = getResourceDescriptor(id); if (rd == null) return false; if (repoId == null) { delete(id); return true; } boolean remove = rd.repositories.remove(repoId); if (rd.repositories.isEmpty()) { delete(rd.id); } else save(); return remove; }
void download(ResourceDescriptor rds, File path) throws Exception { logger.debug("starting download {}", path); Exception exception = new Exception(); event(TYPE.START_DOWNLOAD, rds, null); for (int i = 0; i < 3; sleep(3000), i++) try { download0(rds.url, path, rds.id); event(TYPE.END_DOWNLOAD, rds, null); logger.debug("succesful download {}", path); failures.remove(rds.url); return; } catch (FileNotFoundException e) { logger.debug("no such file download {}", path); exception = e; break; // no use retrying } catch (Exception e) { logger.debug("exception download {}", path); exception = e; } failures.put(rds.url, System.currentTimeMillis()); logger.debug("failed download {}", path, exception); event(TYPE.ERROR, rds, exception); event(TYPE.END_DOWNLOAD, rds, exception); throw exception; }
public SortedSet<ResourceDescriptor> find(String repoId, String bsn, VersionRange range) throws Exception { TreeSet<ResourceDescriptor> result = new TreeSet<ResourceDescriptor>(RESOURCE_DESCRIPTOR_COMPARATOR); for (ResourceDescriptorImpl r : filter(repoId, null)) { if (!bsn.equals(r.bsn)) continue; if (range != null && !range.includes(r.version)) continue; result.add(r); } return result; }
/** * Delete a resource from the text file (not from the cache) */ void delete(byte[] id) throws Exception { for (Iterator<ResourceDescriptorImpl> i = getIndex().descriptors.iterator(); i.hasNext();) { ResourceDescriptorImpl d = i.next(); if (Arrays.equals(id, d.id)) { i.remove(); logger.debug("removing resource {} from index", d); event(TYPE.REMOVE, d, null); setDirty(); } } save(); }
@Override protected void setTypeSpecificPlugins(Set<Object> list) { try { super.setTypeSpecificPlugins(list); list.add(this); list.add(maven); list.add(settings); if (!isTrue(getProperty(NOBUILDINCACHE))) { list.add(new CachedFileRepo()); } resourceRepositoryImpl = new ResourceRepositoryImpl(); resourceRepositoryImpl.setCache(IO.getFile(getProperty(CACHEDIR, "~/.bnd/caches/shas"))); resourceRepositoryImpl.setExecutor(getExecutor()); resourceRepositoryImpl.setIndexFile(getFile(buildDir, "repo.json")); resourceRepositoryImpl.setURLConnector(new MultiURLConnectionHandler(this)); customize(resourceRepositoryImpl, null); list.add(resourceRepositoryImpl); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
public void run() { try { download(rds, path); synchronized (queues) { ok(queues.get(path).toArray(EMPTY_LISTENER), path); } } catch (Exception e) { synchronized (queues) { fail(e, queues.get(path).toArray(EMPTY_LISTENER), path); } } finally { synchronized (queues) { queues.remove(path); } limitDownloads.release(); } } });
final ResourceDescriptorImpl rds = getResourceDescriptor(rd); ok(blockers, path); return path; download(rds, path); return path;
SortedSet<ResourceDescriptor> matches = resourceRepositoryImpl.find(null, bsn, new VersionRange(stringRange)); if (matches.isEmpty()) { resourceRepositoryImpl.getResource(matches.last().id, blocker); } catch (Exception e) { error("Failed to load extension %s-%s, %s", bsn, stringRange, e);
/** * List the resources. We skip the filter for now. */ @Override public ResourceDescriptorImpl getResourceDescriptor(byte[] rd) throws Exception { for (ResourceDescriptorImpl d : getIndex().descriptors) { if (Arrays.equals(d.id, rd)) return d; } return null; }
/** * Delete a resource from the text file (not from the cache) */ void delete(byte[] id) throws Exception { for (Iterator<ResourceDescriptorImpl> i = getIndex().descriptors.iterator(); i.hasNext();) { ResourceDescriptorImpl d = i.next(); if (Arrays.equals(id, d.id)) { i.remove(); logger.debug("removing resource {} from index", d); event(TYPE.REMOVE, d, null); setDirty(); } } save(); }
@Override protected void setTypeSpecificPlugins(Set<Object> list) { try { super.setTypeSpecificPlugins(list); list.add(this); list.add(maven); list.add(settings); if (!isTrue(getProperty(NOBUILDINCACHE))) { list.add(new CachedFileRepo()); } resourceRepositoryImpl = new ResourceRepositoryImpl(); resourceRepositoryImpl.setCache(IO.getFile(getProperty(CACHEDIR, "~/.bnd/caches/shas"))); resourceRepositoryImpl.setExecutor(getExecutor()); resourceRepositoryImpl.setIndexFile(getFile(buildDir, "repo.json")); resourceRepositoryImpl.setURLConnector(new MultiURLConnectionHandler(this)); customize(resourceRepositoryImpl, null); list.add(resourceRepositoryImpl); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
public void run() { try { download(rds, path); synchronized (queues) { ok(queues.get(path).toArray(EMPTY_LISTENER), path); } } catch (Exception e) { synchronized (queues) { fail(e, queues.get(path).toArray(EMPTY_LISTENER), path); } } finally { synchronized (queues) { queues.remove(path); } limitDownloads.release(); } } });
final ResourceDescriptorImpl rds = getResourceDescriptor(rd); ok(blockers, path); return path; download(rds, path); return path;
SortedSet<ResourceDescriptor> matches = resourceRepositoryImpl.find(null, bsn, new VersionRange(stringRange)); if (matches.isEmpty()) { resourceRepositoryImpl.getResource(matches.last().id, blocker); } catch (Exception e) { error("Failed to load extension %s-%s, %s", bsn, stringRange, e);
/** * List the resources. We skip the filter for now. */ public ResourceDescriptorImpl getResourceDescriptor(byte[] rd) throws Exception { for (ResourceDescriptorImpl d : getIndex().descriptors) { if (Arrays.equals(d.id, rd)) return d; } return null; }
/** * Delete a resource from the text file (not from the cache) */ void delete(byte[] id) throws Exception { for (Iterator<ResourceDescriptorImpl> i = getIndex().descriptors.iterator(); i.hasNext();) { ResourceDescriptorImpl d = i.next(); if (Arrays.equals(id, d.id)) { i.remove(); reporter.trace("removing resource %s from index", d); event(TYPE.REMOVE, d, null); setDirty(); } } save(); }
resourceRepositoryImpl = new ResourceRepositoryImpl(); resourceRepositoryImpl.setCache(IO.getFile(getProperty(CACHEDIR, "~/.bnd/caches/shas"))); resourceRepositoryImpl.setExecutor(getExecutor()); resourceRepositoryImpl.setIndexFile(getFile(getBuildDir(), "repo.json")); resourceRepositoryImpl.setURLConnector(new MultiURLConnectionHandler(this)); customize(resourceRepositoryImpl, null); list.add(resourceRepositoryImpl);
@Override public boolean delete(String repoId, byte[] id) throws Exception { ResourceDescriptorImpl rd = getResourceDescriptor(id); if (rd == null) return false; if (repoId == null) { delete(id); return true; } boolean remove = rd.repositories.remove(repoId); if (rd.repositories.isEmpty()) { delete(rd.id); } else save(); return remove; }
@Override public void run() { try { download(rds, path); synchronized (queues) { ok(queues.get(path) .toArray(EMPTY_LISTENER), path); } } catch (Exception e) { synchronized (queues) { fail(e, queues.get(path) .toArray(EMPTY_LISTENER), path); } } finally { synchronized (queues) { queues.remove(path); } limitDownloads.release(); } } });
void download(ResourceDescriptor rds, File path) throws Exception { logger.debug("starting download {}", path); Exception exception = new Exception(); event(TYPE.START_DOWNLOAD, rds, null); for (int i = 0; i < 3; sleep(3000), i++) try { download0(rds.url, path, rds.id); event(TYPE.END_DOWNLOAD, rds, null); logger.debug("succesful download {}", path); failures.remove(rds.url); return; } catch (FileNotFoundException e) { logger.debug("no such file download {}", path); exception = e; break; // no use retrying } catch (Exception e) { logger.debug("exception download {}", path); exception = e; } failures.put(rds.url, System.currentTimeMillis()); logger.debug("failed download {}", path, exception); event(TYPE.ERROR, rds, exception); event(TYPE.END_DOWNLOAD, rds, exception); throw exception; }