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
One line log: scan, init
[metaproxy-moved-to-github.git]
/
src
/
filter_virt_db.cpp
diff --git
a/src/filter_virt_db.cpp
b/src/filter_virt_db.cpp
index
8d68ceb
..
b84e087
100644
(file)
--- a/
src/filter_virt_db.cpp
+++ b/
src/filter_virt_db.cpp
@@
-1,5
+1,5
@@
/* This file is part of Metaproxy.
/* This file is part of Metaproxy.
- Copyright (C) 2005-2011 Index Data
+ Copyright (C) 2005-2012 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
@@
-52,6
+52,7
@@
namespace metaproxy_1 {
};
struct VirtualDB::Map {
Map(std::string database, std::list<std::string> targets, std::string route);
};
struct VirtualDB::Map {
Map(std::string database, std::list<std::string> targets, std::string route);
+ Map(std::string database, std::string target, std::string route);
Map();
bool match(const std::string db) const;
std::string m_dbpattern;
Map();
bool match(const std::string db) const;
std::string m_dbpattern;
@@
-108,6
+109,7
@@
namespace metaproxy_1 {
FrontendPtr get_frontend(Package &package);
void release_frontend(Package &package);
FrontendPtr get_frontend(Package &package);
void release_frontend(Package &package);
+ void refresh_torus();
private:
std::list<VirtualDB::Map>m_maps;
typedef std::map<std::string,VirtualDB::Set>::iterator Sets_it;
private:
std::list<VirtualDB::Map>m_maps;
typedef std::map<std::string,VirtualDB::Set>::iterator Sets_it;
@@
-175,7
+177,7
@@
yf::VirtualDB::BackendPtr yf::VirtualDB::Frontend::create_backend_from_databases
// see if we have a route conflict.
if (!first_route && b->m_route != map_it->m_route)
{
// see if we have a route conflict.
if (!first_route && b->m_route != map_it->m_route)
{
- // we have a conflict..
+ // we have a conflict.. routing must be same for all
error_code = YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP;
BackendPtr ptr;
return ptr;
error_code = YAZ_BIB1_COMBI_OF_SPECIFIED_DATABASES_UNSUPP;
BackendPtr ptr;
return ptr;
@@
-231,10
+233,9
@@
yf::VirtualDB::BackendPtr yf::VirtualDB::Frontend::init_backend(
Z_GDU *gdu = init_package.response().get();
// we hope to get an init response
Z_GDU *gdu = init_package.response().get();
// we hope to get an init response
- error_code = YAZ_BIB1_DATABASE_UNAVAILABLE;
+ error_code = 0;
if (gdu && gdu->which == Z_GDU_Z3950
if (gdu && gdu->which == Z_GDU_Z3950
- && gdu->u.z3950->which == Z_APDU_initResponse
- && *gdu->u.z3950->u.initResponse->result)
+ && gdu->u.z3950->which == Z_APDU_initResponse)
{
Z_InitResponse *res = gdu->u.z3950->u.initResponse;
if (ODR_MASK_GET(res->options, Z_Options_namedResultSets))
{
Z_InitResponse *res = gdu->u.z3950->u.initResponse;
if (ODR_MASK_GET(res->options, Z_Options_namedResultSets))
@@
-248,6
+249,13
@@
yf::VirtualDB::BackendPtr yf::VirtualDB::Frontend::init_backend(
}
mp::util::get_init_diagnostics(res, error_code, addinfo);
}
}
mp::util::get_init_diagnostics(res, error_code, addinfo);
}
+ if (error_code == 0)
+ {
+ std::list<std::string>::const_iterator db_it = databases.begin();
+ error_code = YAZ_BIB1_ACCESS_TO_SPECIFIED_DATABASE_DENIED;
+ if (db_it != databases.end())
+ addinfo = *db_it;
+ }
if (!init_package.session().is_closed())
{
Package close_package(b->m_backend_session, package.origin());
if (!init_package.session().is_closed())
{
Package close_package(b->m_backend_session, package.origin());
@@
-261,7
+269,8
@@
yf::VirtualDB::BackendPtr yf::VirtualDB::Frontend::init_backend(
void yf::VirtualDB::Frontend::search(mp::Package &package, Z_APDU *apdu_req)
{
void yf::VirtualDB::Frontend::search(mp::Package &package, Z_APDU *apdu_req)
{
- Z_SearchRequest *req = apdu_req->u.searchRequest;
+ yazpp_1::GDU ngdu(apdu_req);
+ Z_SearchRequest *req = ngdu.get()->u.z3950->u.searchRequest;
std::string vhost;
std::string resultSetId = req->resultSetName;
mp::odr odr;
std::string vhost;
std::string resultSetId = req->resultSetName;
mp::odr odr;
@@
-350,8
+359,8
@@
void yf::VirtualDB::Frontend::search(mp::Package &package, Z_APDU *apdu_req)
*req->replaceIndicator = 1;
*req->replaceIndicator = 1;
- search_package.request() = yazpp_1::GDU(apdu_req);
-
+ search_package.request() = ngdu;
+
search_package.move(b->m_route);
if (search_package.session().is_closed())
search_package.move(b->m_route);
if (search_package.session().is_closed())
@@
-437,6
+446,7
@@
void yf::VirtualDB::Rep::release_frontend(mp::Package &package)
}
}
}
}
+
yf::VirtualDB::Set::Set(BackendPtr b, std::string setname)
: m_backend(b), m_setname(setname)
{
yf::VirtualDB::Set::Set(BackendPtr b, std::string setname)
: m_backend(b), m_setname(setname)
{
@@
-458,6
+468,14
@@
yf::VirtualDB::Map::Map(std::string database,
{
}
{
}
+yf::VirtualDB::Map::Map(std::string database,
+ std::string target, std::string route)
+ : m_dbpattern(database), m_route(route)
+{
+ m_targets.push_back(target);
+}
+
+
yf::VirtualDB::Map::Map()
{
}
yf::VirtualDB::Map::Map()
{
}
@@
-561,7
+579,8
@@
void yf::VirtualDB::Frontend::fixup_package(mp::Package &p, BackendPtr b)
void yf::VirtualDB::Frontend::present(mp::Package &package, Z_APDU *apdu_req)
{
void yf::VirtualDB::Frontend::present(mp::Package &package, Z_APDU *apdu_req)
{
- Z_PresentRequest *req = apdu_req->u.presentRequest;
+ yazpp_1::GDU ngdu(apdu_req);
+ Z_PresentRequest *req = ngdu.get()->u.z3950->u.presentRequest;
std::string resultSetId = req->resultSetId;
mp::odr odr;
std::string resultSetId = req->resultSetId;
mp::odr odr;
@@
-585,7
+604,7
@@
void yf::VirtualDB::Frontend::present(mp::Package &package, Z_APDU *apdu_req)
req->resultSetId = odr_strdup(odr, sets_it->second.m_setname.c_str());
req->resultSetId = odr_strdup(odr, sets_it->second.m_setname.c_str());
- present_package.request() = yazpp_1::GDU(apdu_req);
+ present_package.request() = ngdu;
present_package.move(sets_it->second.m_backend->m_route);
present_package.move(sets_it->second.m_backend->m_route);
@@
-627,7
+646,8
@@
int yf::VirtualDB::Frontend::relay_apdu(mp::Package &package, Z_APDU *apdu_req)
void yf::VirtualDB::Frontend::scan(mp::Package &package, Z_APDU *apdu_req)
{
void yf::VirtualDB::Frontend::scan(mp::Package &package, Z_APDU *apdu_req)
{
- Z_ScanRequest *req = apdu_req->u.scanRequest;
+ yazpp_1::GDU ngdu(apdu_req);
+ Z_ScanRequest *req = ngdu.get()->u.z3950->u.scanRequest;
std::string vhost;
mp::odr odr;
std::string vhost;
mp::odr odr;
@@
-677,7
+697,8
@@
void yf::VirtualDB::Frontend::scan(mp::Package &package, Z_APDU *apdu_req)
&req->num_databaseNames,
&req->databaseNames);
}
&req->num_databaseNames,
&req->databaseNames);
}
- scan_package.request() = yazpp_1::GDU(apdu_req);
+
+ scan_package.request() = ngdu;
scan_package.move(b->m_route);
scan_package.move(b->m_route);
@@
-692,8
+713,8
@@
void yf::VirtualDB::Frontend::scan(mp::Package &package, Z_APDU *apdu_req)
void yf::VirtualDB::add_map_db2targets(std::string db,
void yf::VirtualDB::add_map_db2targets(std::string db,
- std::list<std::string> targets,
- std::string route)
+ std::list<std::string> targets,
+ std::string route)
{
m_p->m_maps.push_back(
VirtualDB::Map(mp::util::database_name_normalize(db), targets, route));
{
m_p->m_maps.push_back(
VirtualDB::Map(mp::util::database_name_normalize(db), targets, route));
@@
-701,13
+722,12
@@
void yf::VirtualDB::add_map_db2targets(std::string db,
void yf::VirtualDB::add_map_db2target(std::string db,
void yf::VirtualDB::add_map_db2target(std::string db,
- std::string target,
- std::string route)
-{
- std::list<std::string> targets;
- targets.push_back(target);
+ std::string target,
+ std::string route)
- add_map_db2targets(db, targets, route);
+{
+ m_p->m_maps.push_back(
+ VirtualDB::Map(mp::util::database_name_normalize(db), target, route));
}
void yf::VirtualDB::process(mp::Package &package) const
}
void yf::VirtualDB::process(mp::Package &package) const
@@
-821,8
+841,8
@@
void yf::VirtualDB::process(mp::Package &package) const
m_p->release_frontend(package);
}
m_p->release_frontend(package);
}
-
-void mp::filter::VirtualDB::configure(const xmlNode * ptr, bool test_only)
+void mp::filter::VirtualDB::configure(const xmlNode * ptr, bool test_only,
+ const char *path)
{
for (ptr = ptr->children; ptr; ptr = ptr->next)
{
{
for (ptr = ptr->children; ptr; ptr = ptr->next)
{
@@
-830,7
+850,7
@@
void mp::filter::VirtualDB::configure(const xmlNode * ptr, bool test_only)
continue;
if (!strcmp((const char *) ptr->name, "pass-vhosts"))
{
continue;
if (!strcmp((const char *) ptr->name, "pass-vhosts"))
{
- m_p->pass_vhosts = mp::xml::get_bool(ptr->children, false);
+ m_p->pass_vhosts = mp::xml::get_bool(ptr, false);
}
else if (!strcmp((const char *) ptr->name, "virtual"))
{
}
else if (!strcmp((const char *) ptr->name, "virtual"))
{
@@
-854,7
+874,10
@@
void mp::filter::VirtualDB::configure(const xmlNode * ptr, bool test_only)
);
}
std::string route = mp::xml::get_route(ptr);
);
}
std::string route = mp::xml::get_route(ptr);
- add_map_db2targets(database, targets, route);
+
+ VirtualDB::Map vmap(mp::util::database_name_normalize(database),
+ targets, route);
+ m_p->m_maps.push_back(vmap);
}
else
{
}
else
{