*/
private Set<RecordInfo> search(CswServer server, Search s) throws Exception
{
int start = 1;
GetRecordsRequest request = new GetRecordsRequest(context);
request.setResultType(ResultType.RESULTS);
//request.setOutputSchema(OutputSchema.OGC_CORE); // Use default value
request.setElementSetName(ElementSetName.SUMMARY);
request.setMaxRecords(GETRECORDS_NUMBER_OF_RESULTS_PER_PAGE + "");
request.setDistribSearch(params.queryScope.equalsIgnoreCase("true"));
request.setHopCount(params.hopCount + "");
CswOperation oper = server.getOperation(CswServer.GET_RECORDS);
// Use the preferred HTTP method and check one exist.
configRequest(request, oper, server, s, PREFERRED_HTTP_METHOD);
if (params.useAccount) {
log.debug("Logging into server (" + params.username + ")");
request.setCredentials(params.username, params.password);
}
// Simple fallback mechanism. Try search with PREFERRED_HTTP_METHOD method, if fails change it
try {
log.info("Re-trying the search with another HTTP method.");
request.setStartPosition(start +"");
doSearch(request, start, 1);
} catch(Exception ex) {
if(log.isDebugEnabled()) {
log.debug(ex.getMessage());
log.debug("Changing to CSW harvester to use " + (PREFERRED_HTTP_METHOD.equals("GET")?"POST":"GET"));
}
errors.add(new HarvestError(ex, log));
configRequest(request, oper, server, s, PREFERRED_HTTP_METHOD.equals("GET")?"POST":"GET");
}
Set<RecordInfo> records = new HashSet<RecordInfo>();
while (true)
{
request.setStartPosition(start +"");
Element response = doSearch(request, start, GETRECORDS_NUMBER_OF_RESULTS_PER_PAGE);
if(log.isDebugEnabled())
log.debug("Number of child elements in response: " + response.getChildren().size());
Element results = response.getChild("SearchResults", Csw.NAMESPACE_CSW);