/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * List the resources. We skip the filter for now. */ @Override public List<ResourceDescriptorImpl> filter(String repoId, String filter) throws Exception { List<ResourceDescriptorImpl> result = new ArrayList<>(); for (ResourceDescriptorImpl rdi : getIndex().descriptors) { if (repoId == null || rdi.repositories.contains(repoId)) result.add(rdi); } return result; }
/** * List the resources. We skip the filter for now. */ public List<ResourceDescriptorImpl> filter(String repoId, String filter) throws Exception { List<ResourceDescriptorImpl> result = new ArrayList<ResourceDescriptorImpl>(); for (ResourceDescriptorImpl rdi : getIndex().descriptors) { if (repoId == null || rdi.repositories.contains(repoId)) result.add(rdi); } return result; }
/** * List the resources. We skip the filter for now. */ @Override public List<ResourceDescriptorImpl> filter(String repoId, String filter) throws Exception { List<ResourceDescriptorImpl> result = new ArrayList<>(); for (ResourceDescriptorImpl rdi : getIndex().descriptors) { if (repoId == null || rdi.repositories.contains(repoId)) result.add(rdi); } return result; }
/** * List the resources. We skip the filter for now. */ public List<ResourceDescriptorImpl> filter(String repoId, String filter) throws Exception { List<ResourceDescriptorImpl> result = new ArrayList<ResourceDescriptorImpl>(); for (ResourceDescriptorImpl rdi : getIndex().descriptors) { if (repoId == null || rdi.repositories.contains(repoId)) result.add(rdi); } return result; }
/** * Save the index file. * * @throws Exception */ private void save() throws Exception { if (!dirty) return; File tmp = new File(indexFile.getAbsolutePath() + ".tmp"); tmp.getParentFile().mkdirs(); PrintWriter ps = new PrintWriter(tmp, "UTF-8"); try { Formatter frm = new Formatter(ps); getIndex().write(frm); frm.close(); } finally { ps.close(); } IO.rename(tmp, indexFile); }
/** * 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(); }
/** * 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(); }
/** * Save the index file. * * @throws Exception */ private void save() throws Exception { if (!dirty) return; File tmp = new File(indexFile.getAbsolutePath() + ".tmp"); tmp.getParentFile().mkdirs(); PrintWriter ps = new PrintWriter(tmp, "UTF-8"); try { Formatter frm = new Formatter(ps); getIndex().write(frm); frm.close(); } finally { ps.close(); } IO.rename(tmp, indexFile); }
/** * 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(); }
/** * 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(); }
/** * Save the index file. * * @throws Exception */ private void save() throws Exception { if (!dirty) return; Path index = indexFile.toPath(); Path tmp = Files.createTempFile(IO.mkdirs(index.getParent()), "index", null); try (PrintWriter ps = IO.writer(tmp); Formatter frm = new Formatter(ps)) { getIndex().write(frm); } IO.rename(tmp, index); }
/** * Save the index file. * * @throws Exception */ private void save() throws Exception { if (!dirty) return; Path index = indexFile.toPath(); Path tmp = Files.createTempFile(IO.mkdirs(index.getParent()), "index", null); try (PrintWriter ps = IO.writer(tmp); Formatter frm = new Formatter(ps)) { getIndex().write(frm); } IO.rename(tmp, index); }
/** * Add a resource descriptor to the index. */ @Override public boolean add(String repoId, ResourceDescriptor rd) throws Exception { ResourceDescriptorImpl rdi = getResourceDescriptor(rd.id); boolean add = false; if (rdi != null) { add = true; logger.debug("adding repo {} to resource {} to index", repoId, rdi); } else { rdi = new ResourceDescriptorImpl(rd); getIndex().descriptors.add(rdi); logger.debug("adding resource {} to index", rdi); } rdi.repositories.add(repoId); event(TYPE.ADD, rdi, null); setDirty(); save(); return add; }
/** * Add a resource descriptor to the index. */ @Override public boolean add(String repoId, ResourceDescriptor rd) throws Exception { ResourceDescriptorImpl rdi = getResourceDescriptor(rd.id); boolean add = false; if (rdi != null) { add = true; logger.debug("adding repo {} to resource {} to index", repoId, rdi); } else { rdi = new ResourceDescriptorImpl(rd); getIndex().descriptors.add(rdi); logger.debug("adding resource {} to index", rdi); } rdi.repositories.add(repoId); event(TYPE.ADD, rdi, null); setDirty(); save(); return add; }
/** * Add a resource descriptor to the index. */ public boolean add(String repoId, ResourceDescriptor rd) throws Exception { ResourceDescriptorImpl rdi = getResourceDescriptor(rd.id); boolean add = false; if (rdi != null) { add = true; reporter.trace("adding repo %s to resource %s to index", repoId, rdi); } else { rdi = new ResourceDescriptorImpl(rd); getIndex().descriptors.add(rdi); reporter.trace("adding resource %s to index", rdi); } rdi.repositories.add(repoId); event(TYPE.ADD, rdi, null); setDirty(); save(); return add; }
/** * Add a resource descriptor to the index. */ public boolean add(String repoId, ResourceDescriptor rd) throws Exception { ResourceDescriptorImpl rdi = getResourceDescriptor(rd.id); boolean add = false; if (rdi != null) { add = true; reporter.trace("adding repo %s to resource %s to index", repoId, rdi); } else { rdi = new ResourceDescriptorImpl(rd); getIndex().descriptors.add(rdi); reporter.trace("adding resource %s to index", rdi); } rdi.repositories.add(repoId); event(TYPE.ADD, rdi, null); setDirty(); save(); return add; }