#include <yaz/diagbib1.h>
#include <yaz/zgdu.h>
#include <yaz/retrieval.h>
+#include <yaz/oid_db.h>
#include <boost/thread/mutex.hpp>
Z_NamePlusRecord *npr = records->records[i];
if (npr->which == Z_NamePlusRecord_databaseRecord)
{
+ const char *details = 0;
mp::wrbuf output_record;
Z_External *r = npr->u.databaseRecord;
- int ret_trans = 0;
+ int ret_trans = -1;
if (r->which == Z_External_OPAC)
{
ret_trans =
yaz_record_conv_opac_record(rc, r->u.opac,
output_record);
+ details = yaz_record_conv_get_error(rc);
}
else if (r->which == Z_External_octet)
{
r->u.octet_aligned->buf,
r->u.octet_aligned->len,
output_record);
+ details = yaz_record_conv_get_error(rc);
}
- if (ret_trans == 0)
+ else
{
- npr->u.databaseRecord =
- z_ext_record_oid(odr_en, match_syntax,
- output_record.buf(),
- output_record.len());
+ details = "unsupported record type for record_conv";
}
- else
+ if (ret_trans)
{
records->records[i] =
zget_surrogateDiagRec(
odr_en, npr->databaseName,
YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS,
- yaz_record_conv_get_error(rc));
+ details);
+ }
+ else
+ {
+ if (!oid_oidcmp(match_syntax, yaz_oid_recsyn_opac))
+ {
+ yaz_marc_t mt = yaz_marc_create();
+ Z_OPACRecord *opac = 0;
+ if (yaz_xml_to_opac(mt, output_record.buf(),
+ output_record.len(),
+ &opac, 0 /* iconv */,
+ ((ODR )odr_en)->mem, 0)
+ && opac)
+ {
+ npr->u.databaseRecord =
+ z_ext_record_oid(odr_en, match_syntax,
+ (const char *) opac, -1);
+ }
+ else
+ {
+ records->records[i] =
+ zget_surrogateDiagRec(
+ odr_en, npr->databaseName,
+ YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS,
+ "XML to OPAC conversion failed");
+ }
+ yaz_marc_destroy(mt);
+ }
+ else
+ {
+ npr->u.databaseRecord =
+ z_ext_record_oid(odr_en, match_syntax,
+ output_record.buf(),
+ output_record.len());
+ }
}
}
}