public static IndexerConf build(InputStream is, Repository repository) throws IndexerConfException { Document doc; try { doc = DocumentHelper.parse(is); } catch (Exception e) { throw new IndexerConfException("Error parsing supplied configuration.", e); } return new IndexerConfBuilder().build(doc, repository); }
@Override public int run(CommandLine cmd) throws Exception { int result = super.run(cmd); if (result != 0) { return result; } String collection = cmd.getOptionValue(collectionOption.getOpt()); if (collection == null) { collection = DEFFAULT_COLLECTION; } String branch = cmd.getOptionValue(branchOption.getOpt()); if (branch == null) { branch = DEFFAULT_BRANCH; } RepositoryManager repositoryManager = new RemoteRepositoryManager( "http://lilyproject.org:9263", new Credentials("guest", "guest")); Repository repository = repositoryManager.getRepository(new Credentials("guest", "guest")); QueryManager queryManager = repository.getQueryManager(); RepositorySchema schema = repository.getRepositorySchema(); String query = "select id, name where InCollection('" + collection + "') and branch = '" + branch + "'"; VariantKey[] keys = queryManager.performQueryReturnKeys(query, Locale.getDefault()); for (VariantKey key : keys) { Document doc = repository.getDocument(key, false); Version version = doc.getLiveVersion(); if (version == null) { continue; } for (Part part : version.getParts().getArray()) { if (schema.getPartTypeById(part.getTypeId(), false).isDaisyHtml()) { InputStream is = part.getDataStream(); org.w3c.dom.Document domDoc = DocumentHelper.parse(is); NodeList links = XPathUtils.evalNodeList("//a/@href", domDoc.getDocumentElement()); for (int j = 0; j < links.getLength(); j++) { String link = ((Attr) links.item(j)).getValue(); System.out.printf( "[%1$10.10s][%2$30.30s][%3$10.10s] %4$s\n", key.getDocumentId(), version.getDocumentName(), part.getTypeName(), link); } is.close(); } } } return 0; }