public ScanResponseType scanOperation(ScanRequestType request)
throws java.rmi.RemoteException {
log.debug("Enter: scanOperation");
MessageContext msgContext=MessageContext.getCurrentContext();
ScanResponseType response;
String dbname=(String)msgContext.getProperty("dbname");
SRWDatabase db=(SRWDatabase)msgContext.getProperty("db");
if(log.isDebugEnabled())
log.debug("db="+db);
if(request.getScanClause()==null) {
response=new ScanResponseType();
db.diagnostic(SRWDiagnostic.MandatoryParameterNotSupplied,
"scanClause", response);
}
else if(request.getResponsePosition()!=null &&
request.getResponsePosition().intValue()==Integer.MAX_VALUE) {
response=new ScanResponseType();
db.diagnostic(SRWDiagnostic.UnsupportedParameterValue,
"responsePosition", response);
}
else if(request.getMaximumTerms()!=null &&
request.getMaximumTerms().intValue()==Integer.MAX_VALUE) {
response=new ScanResponseType();
db.diagnostic(SRWDiagnostic.UnsupportedParameterValue,
"maximumTerms", response);
}
else
try {
response=db.doRequest(request);
// set extraResponseData
StringBuffer extraResponseData = new StringBuffer();
// we're going to stick the database name in extraResponseData every time
if(db.databaseTitle!=null)
extraResponseData.append("<databaseTitle>").append(db.databaseTitle).append("</databaseTitle>");
else
extraResponseData.append("<databaseTitle>").append(dbname).append("</databaseTitle>");
// Hashtable extraRequestDataElements=SRWDatabase.parseElements(request.getExtraRequestData());
// String s=(String)extraRequestDataElements.get("returnTargetURL");
// log.info("returnTargetURL="+s);
// if(s!=null && !s.equals("false")) {
// String targetStr=(String)msgContext.getProperty("targetURL");
// log.info("targetStr="+targetStr);
// if(targetStr!=null && targetStr.length()>0) {
// URL target=new URL(targetStr);
// extraResponseData.append("<targetURL>")
// .append("<host>").append(target.getHost()).append("</host>")
// .append("<port>").append(target.getPort()).append("</port>")
// .append("<path>").append(target.getPath()).append("</path>")
// .append("<query>").append(Utilities.xmlEncode(target.getQuery())).append("</query>")
// .append("</targetURL>");
// }
// }
// set extraResponseData
SRWDatabase.setExtraResponseData(response, extraResponseData.toString());
}
catch(Exception e) {
log.error(e, e);
throw new RemoteException(e.getMessage(), e);
}
finally {
SRWDatabase.putDb(dbname, db);
}
if(response!=null) {
log.info("calling setEchoedScanRequestType");
setEchoedScanRequestType(request, response);
log.info("called setEchoedScanRequestType");
response.setVersion("1.1");
}
log.debug("Exit: scanOperation");
return response;
}