@Test public void testFind() throws Exception { String host = System.getProperty("Z3950CatalogTest.host"); String port = System.getProperty("Z3950CatalogTest.port"); String base = System.getProperty("Z3950CatalogTest.base"); String recordCharset = System.getProperty("Z3950CatalogTest.recordCharset"); Assume.assumeNotNull(host, port, base); String fieldName = "sys"; String value = "001704913"; Locale locale = null; final String catalogId = "catalogId"; CatalogConfiguration c = new CatalogConfiguration(catalogId, "", new BaseConfiguration() {{ addProperty(CatalogConfiguration.PROPERTY_FIELDS, "sys"); addProperty(CatalogConfiguration.FIELD_PREFIX + '.' + "sys" + '.' + Z3950Catalog.PROPERTY_FIELD_QUERY, "@attrset bib-1 @attr 1=12 @attr 4=1 \"%s\""); }}); Z3950Catalog instance = new Z3950Catalog(host, Integer.parseInt(port), base, recordCharset == null ? null : Charset.forName(recordCharset), Z3950Catalog.readFields(c) ); List<MetadataItem> result = instance.find(fieldName, value, locale); assertFalse(result.isEmpty()); }
@Override public List<MetadataItem> find(String fieldId, String value, Locale locale) throws TransformerException, IOException { String query = buildQuery(fieldId, value); LOG.fine(query); if (query == null) { return Collections.emptyList(); } ArrayList<MetadataItem> result = new ArrayList<MetadataItem>(); int index = 1; try { for (byte[] content : client.search(query)) { String charset = recordCharset == null ? null : recordCharset.name(); if (LOG.isLoggable(Level.FINE)) { String marc21 = new String(content, charset == null ? "UTF-8" : charset); LOG.fine(marc21); } Document marcXml = Z3950Client.toMarcXml(content, charset); if (LOG.isLoggable(Level.FINE)) { StringBuilder sb = new StringBuilder(); transformers.dump(new DOMSource(marcXml), sb); LOG.fine(sb.toString()); } MetadataItem item = createResponse(index++, new DOMSource(marcXml), locale); result.add(item); } return result; } catch (Z3950ClientException ex) { throw new IOException(ex); } finally { client.close(); } }
Z3950Catalog implements BibliographicCatalog { @Override public List<MetadataItem> find(String fieldId, String value, Locale locale) throws TransformerException, IOException { String query = buildQuery(fieldId, value); LOG.fine(query); if (query == null) { return Collections.emptyList(); } ArrayList<MetadataItem> result = new ArrayList<MetadataItem>(); int index = 1; try { for (byte[] content : client.search(query)) { String charset = recordCharset == null ? null : recordCharset.name(); if (LOG.isLoggable(Level.FINE)) { String marc21 = new String(content, charset == null ? "UTF-8" : charset); LOG.fine(marc21); } Document marcXml = Z3950Client.toMarcXml(content, charset); if (LOG.isLoggable(Level.FINE)) { StringBuilder sb = new StringBuilder(); transformers.dump(new DOMSource(marcXml), sb); LOG.fine(sb.toString()); } MetadataItem item = createResponse(index++, new DOMSource(marcXml), locale); result.add(item); } return result; } catch (Z3950ClientException ex) { throw new IOException(ex); } finally { client.close(); } } }
Z3950Catalog implements BibliographicCatalog { @Override public List<MetadataItem> find(String fieldId, String value, Locale locale) throws TransformerException, IOException { String query = buildQuery(fieldId, value); LOG.fine(query); if (query == null) { return Collections.emptyList(); } ArrayList<MetadataItem> result = new ArrayList<MetadataItem>(); int index = 1; try { for (byte[] content : client.search(query)) { String charset = recordCharset == null ? null : recordCharset.name(); if (LOG.isLoggable(Level.FINE)) { String marc21 = new String(content, charset == null ? "UTF-8" : charset); LOG.fine(marc21); } Document marcXml = Z3950Client.toMarcXml(content, charset); if (LOG.isLoggable(Level.FINE)) { StringBuilder sb = new StringBuilder(); transformers.dump(new DOMSource(marcXml), sb); LOG.fine(sb.toString()); } MetadataItem item = createResponse(index++, new DOMSource(marcXml), locale); result.add(item); } return result; } catch (Z3950ClientException ex) { throw new IOException(ex); } finally { client.close(); } } Z3950Catalog(String host, int port, String base, Charset recordCharset, Map<String, Z3950Field> fields); }
Z3950Catalog implements BibliographicCatalog { @Override public List<MetadataItem> find(String fieldId, String value, Locale locale) throws TransformerException, IOException { String query = buildQuery(fieldId, value); LOG.fine(query); if (query == null) { return Collections.emptyList(); } ArrayList<MetadataItem> result = new ArrayList<MetadataItem>(); int index = 1; try { for (byte[] content : client.search(query)) { String charset = recordCharset == null ? null : recordCharset.name(); if (LOG.isLoggable(Level.FINE)) { String marc21 = new String(content, charset == null ? "UTF-8" : charset); LOG.fine(marc21); } Document marcXml = Z3950Client.toMarcXml(content, charset); if (LOG.isLoggable(Level.FINE)) { StringBuilder sb = new StringBuilder(); transformers.dump(new DOMSource(marcXml), sb); LOG.fine(sb.toString()); } MetadataItem item = createResponse(index++, new DOMSource(marcXml), locale); result.add(item); } return result; } catch (Z3950ClientException ex) { throw new IOException(ex); } finally { client.close(); } } Z3950Catalog(String host, int port, String base, Charset recordCharset, Map<String, Z3950Field> fields); static Z3950Catalog get(CatalogConfiguration c); @Override List<MetadataItem> find(String fieldId, String value, Locale locale); }
Z3950Catalog implements BibliographicCatalog { @Override public List<MetadataItem> find(String fieldId, String value, Locale locale) throws TransformerException, IOException { String query = buildQuery(fieldId, value); LOG.fine(query); if (query == null) { return Collections.emptyList(); } ArrayList<MetadataItem> result = new ArrayList<MetadataItem>(); int index = 1; try { for (byte[] content : client.search(query)) { String charset = recordCharset == null ? null : recordCharset.name(); if (LOG.isLoggable(Level.FINE)) { String marc21 = new String(content, charset == null ? "UTF-8" : charset); LOG.fine(marc21); } Document marcXml = Z3950Client.toMarcXml(content, charset); if (LOG.isLoggable(Level.FINE)) { StringBuilder sb = new StringBuilder(); transformers.dump(new DOMSource(marcXml), sb); LOG.fine(sb.toString()); } MetadataItem item = createResponse(index++, new DOMSource(marcXml), locale); result.add(item); } return result; } catch (Z3950ClientException ex) { throw new IOException(ex); } finally { client.close(); } } Z3950Catalog(String host, int port, String base, Charset recordCharset, Map<String, Z3950Field> fields); static Z3950Catalog get(CatalogConfiguration c); @Override List<MetadataItem> find(String fieldId, String value, Locale locale); static final String TYPE; }