+ wrbuf_printf(wr, "SRWScan %d+%d",
+ (srw_req->responsePosition ?
+ *srw_req->responsePosition : 1),
+ (srw_req->maximumTerms ?
+ *srw_req->maximumTerms : 1));
+ if (srw_res->num_diagnostics)
+ wrbuf_printf(wr, " ERROR %s", srw_res->diagnostics[0].uri);
+ else
+ wrbuf_printf(wr, " OK -");
+ wrbuf_printf(wr, " %s: %s", querytype, querystr);
+ yaz_log(log_request, "%s", wrbuf_buf(wr) );
+ wrbuf_free(wr, 1);
+ }
+
+}
+
+static void srw_bend_update(association *assoc, request *req,
+ Z_SRW_PDU *sr,
+ Z_SRW_updateResponse *srw_res,
+ int *http_code)
+{
+ Z_SRW_updateRequest *srw_req = sr->u.update_request;
+ yaz_log(YLOG_DEBUG, "Got SRW UpdateRequest");
+ yaz_log(YLOG_DEBUG, "num_diag = %d", srw_res->num_diagnostics );
+ *http_code = 404;
+ srw_bend_init(assoc, &srw_res->diagnostics, &srw_res->num_diagnostics, sr);
+ if (assoc->init)
+ {
+ bend_update_rr rr;
+
+ rr.stream = assoc->encode;
+ rr.print = assoc->print;
+ rr.num_bases = 1;
+ rr.basenames = &srw_req->database;
+ rr.operation = srw_req->operation;
+ rr.operation_status = "failed";
+ rr.record_id = 0;
+ rr.record_version = 0;
+ rr.record_checksum = 0;
+ rr.record_old_version = 0;
+ rr.record_packing = "xml";
+ rr.record_schema = 0;
+ rr.record_data = 0;
+ rr.request_extra_record = 0;
+ rr.response_extra_record = 0;
+ rr.extra_request_data = 0;
+ rr.extra_response_data = 0;
+ rr.uri = 0;
+ rr.message = 0;
+ rr.details = 0;
+
+ yaz_log(YLOG_DEBUG, "basename = %s", rr.basenames[0] );
+ yaz_log(YLOG_DEBUG, "Operation = %s", rr.operation );
+ if ( !strcmp( rr.operation, "delete" ) ){
+ if ( !srw_req->recordId ){
+ yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
+ &srw_res->num_diagnostics,
+ 7, "recordId" );
+ }
+ else {
+ rr.record_id = srw_req->recordId;
+ }
+ if ( !srw_req->recordVersion ){
+ yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
+ &srw_res->num_diagnostics,
+ 7, "recordVersion" );
+ }
+ else {
+ rr.record_version = odr_strdup( assoc->encode,
+ srw_req->recordVersion );
+
+ }
+ if ( srw_req->recordOldVersion ){
+ rr.record_old_version = odr_strdup(assoc->encode,
+ srw_req->recordOldVersion );
+ }
+ if ( srw_req->extraRequestData ){
+ rr.extra_request_data = odr_strdup(assoc->encode,
+ srw_req->extraRequestData );
+ }
+ }
+ else if ( !strcmp( rr.operation, "replace" ) ){
+ if ( !srw_req->recordId ){
+ yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
+ &srw_res->num_diagnostics,
+ 7, "recordId" );
+ }
+ else {
+ rr.record_id = srw_req->recordId;
+ }
+ if ( srw_req->record.recordSchema == 0 ){
+ yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
+ &srw_res->num_diagnostics,
+ 7, "recordSchema" );
+ }
+ else {
+ rr.record_schema = odr_strdup(assoc->encode,
+ srw_req->record.recordSchema );
+ }
+ switch (srw_req->record.recordPacking)
+ {
+ case Z_SRW_recordPacking_string:
+ rr.record_packing = "string";
+ break;
+ case Z_SRW_recordPacking_XML:
+ rr.record_packing = "xml";
+ break;
+ case Z_SRW_recordPacking_URL:
+ rr.record_packing = "url";
+ break;
+ }
+ if ( srw_req->record.recordData_len ){
+ rr.record_data = odr_strdupn(assoc->encode,
+ srw_req->record.recordData_buf,
+ srw_req->record.recordData_len );
+ rr.request_extra_record = srw_req->extra_record;
+ }
+ else {
+ yaz_add_srw_diagnostic(assoc->encode, &srw_res->diagnostics,
+ &srw_res->num_diagnostics,
+ 7, "recordData" );
+ }
+ if (srw_req->extraRequestData)
+ rr.extra_request_data = odr_strdup(assoc->encode,
+ srw_req->extraRequestData );
+ }
+ else if ( !strcmp( rr.operation, "insert" ) )