projects
/
metaproxy-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
limit=0 means unlimited MP-632
[metaproxy-moved-to-github.git]
/
src
/
filter_sort.cpp
diff --git
a/src/filter_sort.cpp
b/src/filter_sort.cpp
index
e36e8cd
..
02ae667
100644
(file)
--- a/
src/filter_sort.cpp
+++ b/
src/filter_sort.cpp
@@
-1,5
+1,5
@@
/* This file is part of Metaproxy.
/* This file is part of Metaproxy.
- Copyright (C) 2005-2013 Index Data
+ Copyright (C) Index Data
Metaproxy is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Metaproxy is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
@@
-70,7
+70,7
@@
namespace metaproxy_1 {
Record(Z_NamePlusRecord *n, const char *namespaces,
const char *expr, bool debug);
~Record();
Record(Z_NamePlusRecord *n, const char *namespaces,
const char *expr, bool debug);
~Record();
- bool operator < (const Record &rhs);
+ bool operator < (const Record &rhs) const;
};
class Sort::RecordList : boost::noncopyable {
Odr_oid *syntax;
};
class Sort::RecordList : boost::noncopyable {
Odr_oid *syntax;
@@
-286,7
+286,7
@@
yf::Sort::Record::~Record()
{
}
{
}
-bool yf::Sort::Record::operator < (const Record &rhs)
+bool yf::Sort::Record::operator < (const Record &rhs) const
{
if (strcmp(this->score.c_str(), rhs.score.c_str()) < 0)
return true;
{
if (strcmp(this->score.c_str(), rhs.score.c_str()) < 0)
return true;
@@
-573,14
+573,12
@@
void yf::Sort::Frontend::handle_search(mp::Package &package, Z_APDU *apdu_req)
{
Z_SearchRequest *req = apdu_req->u.searchRequest;
std::string resultSetId = req->resultSetName;
{
Z_SearchRequest *req = apdu_req->u.searchRequest;
std::string resultSetId = req->resultSetName;
- Package b_package(package.session(), package.origin());
mp::odr odr;
Odr_oid *syntax = 0;
if (req->preferredRecordSyntax)
syntax = odr_oiddup(odr, req->preferredRecordSyntax);
mp::odr odr;
Odr_oid *syntax = 0;
if (req->preferredRecordSyntax)
syntax = odr_oiddup(odr, req->preferredRecordSyntax);
- b_package.copy_filter(package);
Sets_it sets_it = m_sets.find(req->resultSetName);
if (sets_it != m_sets.end())
{
Sets_it sets_it = m_sets.find(req->resultSetName);
if (sets_it != m_sets.end())
{
@@
-601,27
+599,35
@@
void yf::Sort::Frontend::handle_search(mp::Package &package, Z_APDU *apdu_req)
}
ResultSetPtr s(new ResultSet);
m_sets[resultSetId] = s;
}
ResultSetPtr s(new ResultSet);
m_sets[resultSetId] = s;
- package.move();
- Z_GDU *gdu_res = package.response().get();
+
+ Package b_package(package.session(), package.origin());
+ b_package.copy_filter(package);
+ b_package.request() = apdu_req;
+ b_package.move();
+
+ Z_GDU *gdu_res = b_package.response().get();
if (gdu_res && gdu_res->which == Z_GDU_Z3950 && gdu_res->u.z3950->which ==
Z_APDU_searchResponse)
{
Z_SearchResponse *res = gdu_res->u.z3950->u.searchResponse;
if (gdu_res && gdu_res->which == Z_GDU_Z3950 && gdu_res->u.z3950->which ==
Z_APDU_searchResponse)
{
Z_SearchResponse *res = gdu_res->u.z3950->u.searchResponse;
- Z_RecordComposition *record_comp =
+ Z_RecordComposition *record_comp =
mp::util::piggyback_to_RecordComposition(odr,
*res->resultCount, req);
s->hit_count = *res->resultCount;
mp::util::piggyback_to_RecordComposition(odr,
*res->resultCount, req);
s->hit_count = *res->resultCount;
- handle_records(b_package, apdu_req, res->records, 1, s,
+ handle_records(package, apdu_req, res->records, 1, s,
syntax, record_comp, resultSetId.c_str());
package.response() = gdu_res;
}
syntax, record_comp, resultSetId.c_str());
package.response() = gdu_res;
}
+ else
+ package.response() = b_package.response();
+ if (b_package.session().is_closed())
+ b_package.session().close();
}
void yf::Sort::Frontend::handle_present(mp::Package &package, Z_APDU *apdu_req)
{
Z_PresentRequest *req = apdu_req->u.presentRequest;
std::string resultSetId = req->resultSetId;
}
void yf::Sort::Frontend::handle_present(mp::Package &package, Z_APDU *apdu_req)
{
Z_PresentRequest *req = apdu_req->u.presentRequest;
std::string resultSetId = req->resultSetId;
- Package b_package(package.session(), package.origin());
mp::odr odr;
Odr_oid *syntax = 0;
Odr_int start = *req->resultSetStartPoint;
mp::odr odr;
Odr_oid *syntax = 0;
Odr_int start = *req->resultSetStartPoint;
@@
-629,7
+635,6
@@
void yf::Sort::Frontend::handle_present(mp::Package &package, Z_APDU *apdu_req)
if (req->preferredRecordSyntax)
syntax = odr_oiddup(odr, req->preferredRecordSyntax);
if (req->preferredRecordSyntax)
syntax = odr_oiddup(odr, req->preferredRecordSyntax);
- b_package.copy_filter(package);
Sets_it sets_it = m_sets.find(resultSetId);
if (sets_it == m_sets.end())
{
Sets_it sets_it = m_sets.find(resultSetId);
if (sets_it == m_sets.end())
{
@@
-676,17
+681,26
@@
void yf::Sort::Frontend::handle_present(mp::Package &package, Z_APDU *apdu_req)
}
break;
}
}
break;
}
- package.move();
- Z_GDU *gdu_res = package.response().get();
+
+
+ Package b_package(package.session(), package.origin());
+ b_package.copy_filter(package);
+ b_package.request() = apdu_req;
+ b_package.move();
+ Z_GDU *gdu_res = b_package.response().get();
if (gdu_res && gdu_res->which == Z_GDU_Z3950 && gdu_res->u.z3950->which ==
Z_APDU_presentResponse)
{
Z_PresentResponse *res = gdu_res->u.z3950->u.presentResponse;
if (gdu_res && gdu_res->which == Z_GDU_Z3950 && gdu_res->u.z3950->which ==
Z_APDU_presentResponse)
{
Z_PresentResponse *res = gdu_res->u.z3950->u.presentResponse;
- handle_records(b_package, apdu_req, res->records,
+ handle_records(package, apdu_req, res->records,
start, rset, syntax, req->recordComposition,
resultSetId.c_str());
package.response() = gdu_res;
}
start, rset, syntax, req->recordComposition,
resultSetId.c_str());
package.response() = gdu_res;
}
+ else
+ package.response() = b_package.response();
+ if (b_package.session().is_closed())
+ b_package.session().close();
}
void yf::Sort::Frontend::handle_package(mp::Package &package)
}
void yf::Sort::Frontend::handle_package(mp::Package &package)