public Map<String, ArchivesSet> setArchiveSetMap() { Map<String, JrdsDocument> nodemap = load.getRepository(ConfigType.ARCHIVESSET); archivessetmap = getObjectMap(new ArchivesSetBuilder(), nodemap); archivessetmap.put(ArchivesSet.DEFAULT.getName(), ArchivesSet.DEFAULT); logger.debug(jrds.Util.delayedFormatString("Archives set configured: %s", archivessetmap.keySet())); return archivessetmap; }
@Override ArchivesSet build(JrdsDocument n) throws InvocationTargetException { try { return getArchiveDefs(n.getRootElement()); } catch (IllegalArgumentException e) { throw new InvocationTargetException(e, ArchivesSetBuilder.class.getName()); } }
@Test public void testLoad() throws Exception { JrdsDocument d = Tools.parseRessource("goodarchives.xml"); ArchivesSetBuilder asb = new ArchivesSetBuilder(); ArchivesSet arcset = asb.build(d); ArcDef[] arcs = arcset.getArchives(); Assert.assertEquals("wrong name for archives set", "newarchives", arcset.getName()); Assert.assertEquals("not enough archives", 2, arcs.length); Assert.assertEquals("not enough archives", ConsolFun.AVERAGE, arcs[0].getConsolFun()); Assert.assertEquals("not enough archives", ConsolFun.MAX, arcs[1].getConsolFun()); }
private ArchivesSet getArchiveDefs(JrdsElement archivesSetElements) { String name = archivesSetElements.getAttribute("name"); ArchivesSet arcset = new ArchivesSet(name); for(JrdsElement archiveElement: archivesSetElements.getChildElementsByName("archive")) { ArcDef arcDef = getArchDef(archiveElement); arcset.addArchive(arcDef); } return arcset; } }