record_schema = "meta" ;
String query = params.get(OP_SR_QUERY);
ExplicitRecordFormatSpecification display_spec = new ExplicitRecordFormatSpecification("xml","","f");
if(Log.isDebugEnabled(Geonet.SRU))
Log.debug(Geonet.SRU,"getting reference to search session factory");
// TODO: would be nice to move this to init method but I dont know where to get the context from there..
// not supported by Geonetwork modules URL layout schema
// TODO: collections could also be mapped to GeoNetwork categories?
LandscapeSpecification landscape = new SimpleLandscapeSpecification("geonetwork");
DefaultContextSetCQLString model = new DefaultContextSetCQLString(query, "geo", "cql", "geo");
// we assume that all incoming queries are from the geo (attributes,structure) and cql (relation) context sets
// if we set this to false we have to write a crosswalk for bib-1,dc....
//model.setForceContextSet(true);
SearchSessionFactory search_session_factory = getSearchSession(context);
if(Log.isDebugEnabled(Geonet.SRU))
Log.debug(Geonet.SRU,"Calling search_session_factory.getResultsPageFor");
StatelessSearchResultsPageDTO result = search_session_factory.getResultsPageFor(null,
model,
landscape,
first_record,
num_hits_per_page,
request_spec,
display_spec,
null);
if(Log.isDebugEnabled(Geonet.SRU))
Log.debug(Geonet.SRU,"Call to getResultsPageFor completed : "+result);
Element myresponse = new Element("sruresponse");
response.addContent(myresponse);
int num_records = 0;
String res_id = "";
long idle = 0;
if ( ( result.records != null ) && ( result.records.length > 0 ) ) {
DOMBuilder builder = new DOMBuilder();
num_records = result.records.length;
res_id = result.result_set_id;
idle = result.result_set_idle_time ;
for ( int i=0; i<result.records.length;i++ ) {
Element elem = new Element("record");
elem.setAttribute( new Attribute("recordPosition",""+first_record+i));
ExplicitRecordFormatSpecification res = result.records[i].getFormatSpecification();
// check if the format corresponds to what we are requesting
if ( ! res.toString().equals(display_spec.toString()) ) {
Log.error(Geonet.SRU, "error, format specification "+result.records[i].getFormatSpecification()+" does not correspond to "+display_spec+" :"+result.records[i].getOriginalObject() );
addToDiag(elem, "info:srw/diagnostic/1/67", "Record not available in this schema", result.records[i].getOriginalObject().toString());