@Test public void testOaiErrorResponseTransformation() throws Exception { OaiCatalog c = new OaiCatalog("", ""); String srcUrl = OaiCatalogTest.class.getResource("oaiErrorResponse.xml").toExternalForm(); try { c.transformOaiResponse(new StreamSource(srcUrl), new StreamResult(new StringWriter())); fail(); } catch (TransformerException result) { String msg = result.getMessage(); assertTrue(msg, msg.contains("cannotDisseminateFormat")); } }
<T extends Result> T transformOaiResponse(Source src, T dst) throws TransformerException { Transformer t = getOai2MarcXslt().newTransformer(); XslErrorListener errorListener = new XslErrorListener(); t.setErrorListener(errorListener); try { t.transform(src, dst); return dst; } catch (TransformerException ex) { if (errorListener.containError(XslErrorListener.ERR_ID_DOESNOT_EXIST)) { return null; } else if (!errorListener.getMessages().isEmpty()) { throw new TransformerException(errorListener.getMessages().toString(), ex); } throw ex; } }
OaiCatalog implements BibliographicCatalog { <T extends Result> T transformOaiResponse(Source src, T dst) throws TransformerException { Transformer t = getOai2MarcXslt().newTransformer(); XslErrorListener errorListener = new XslErrorListener(); t.setErrorListener(errorListener); try { t.transform(src, dst); return dst; } catch (TransformerException ex) { if (errorListener.containError(XslErrorListener.ERR_ID_DOESNOT_EXIST)) { return null; } else if (!errorListener.getMessages().isEmpty()) { throw new TransformerException(errorListener.getMessages().toString(), ex); } throw ex; } } }
OaiCatalog implements BibliographicCatalog { <T extends Result> T transformOaiResponse(Source src, T dst) throws TransformerException { Transformer t = getOai2MarcXslt().newTransformer(); XslErrorListener errorListener = new XslErrorListener(); t.setErrorListener(errorListener); try { t.transform(src, dst); return dst; } catch (TransformerException ex) { if (errorListener.containError(XslErrorListener.ERR_ID_DOESNOT_EXIST)) { return null; } else if (!errorListener.getMessages().isEmpty()) { throw new TransformerException(errorListener.getMessages().toString(), ex); } throw ex; } } OaiCatalog(String url, String metadataPrefix);  OaiCatalog(String url, String metadataPrefix, String identifierPrefix); }
OaiCatalog implements BibliographicCatalog { <T extends Result> T transformOaiResponse(Source src, T dst) throws TransformerException { Transformer t = getOai2MarcXslt().newTransformer(); XslErrorListener errorListener = new XslErrorListener(); t.setErrorListener(errorListener); try { t.transform(src, dst); return dst; } catch (TransformerException ex) { if (errorListener.containError(XslErrorListener.ERR_ID_DOESNOT_EXIST)) { return null; } else if (!errorListener.getMessages().isEmpty()) { throw new TransformerException(errorListener.getMessages().toString(), ex); } throw ex; } } OaiCatalog(String url, String metadataPrefix);  OaiCatalog(String url, String metadataPrefix, String identifierPrefix); static OaiCatalog get(CatalogConfiguration c); void setDebug(boolean debug); void setIdentifierPrefix(String identifierPrefix); void setUser(String user); void setPassword(String password); @Override List<MetadataItem> find(String fieldName, String value, Locale locale); String findOaiRecord(String id); }
OaiCatalog implements BibliographicCatalog { <T extends Result> T transformOaiResponse(Source src, T dst) throws TransformerException { Transformer t = getOai2MarcXslt().newTransformer(); XslErrorListener errorListener = new XslErrorListener(); t.setErrorListener(errorListener); try { t.transform(src, dst); return dst; } catch (TransformerException ex) { if (errorListener.containError(XslErrorListener.ERR_ID_DOESNOT_EXIST)) { return null; } else if (!errorListener.getMessages().isEmpty()) { throw new TransformerException(errorListener.getMessages().toString(), ex); } throw ex; } } OaiCatalog(String url, String metadataPrefix);  OaiCatalog(String url, String metadataPrefix, String identifierPrefix); static OaiCatalog get(CatalogConfiguration c); void setDebug(boolean debug); void setIdentifierPrefix(String identifierPrefix); void setUser(String user); void setPassword(String password); @Override List<MetadataItem> find(String fieldName, String value, Locale locale); String findOaiRecord(String id); static final String TYPE; }