1,
maxListSize,
"xml");
} catch (IOException e) {
e.printStackTrace();
throw new OAIInternalServerError(e.getMessage());
} catch (SAXException e) {
e.printStackTrace();
throw new OAIInternalServerError(e.getMessage());
} catch (ParserConfigurationException e) {
e.printStackTrace();
throw new OAIInternalServerError(e.getMessage());
}
try {
NodeList nodeList = getRecords(srResponse);
// logger.debug("SRUOAICatalog.listRecords: nodeList.size=" + nodeList.getLength());
if (nodeList != null) {
RecordFactory recordFactory = getRecordFactory();
String schemaURL = null;
if (metadataPrefix != null) {
if ((schemaURL = getCrosswalks().getSchemaURL(metadataPrefix))
== null)
throw new CannotDisseminateFormatException(metadataPrefix);
}
// logger.debug("schemaURL=" + schemaURL);
for (int i = 0; i < nodeList.getLength(); ++i) {
Object rec = getRecordData(nodeList.item(i));
HashMap hashMap = new HashMap();
hashMap.put("header", rec);
String localIdentifier = getRecordFactory().getLocalIdentifier(hashMap);
// logger.debug("SRUOAICatalog.listRecords: localIdentifier=" + localIdentifier);
try {
hashMap.put("metadata", getNativeMetadata(localIdentifier,
metadataPrefix));
} catch (IOException e) {
e.printStackTrace();
throw new OAIInternalServerError(e.getMessage());
} catch (ParserConfigurationException e) {
e.printStackTrace();
throw new OAIInternalServerError(e.getMessage());
} catch (SAXException e) {
e.printStackTrace();
throw new OAIInternalServerError(e.getMessage());
}
recordsList.add(
recordFactory.create(hashMap,
schemaURL,
metadataPrefix));
}
String nextRecordPosition = XPathAPI.eval(srResponse, "/srw:searchRetrieveResponse/srw:nextRecordPosition", xmlnsEl).str();
if (nextRecordPosition != null && nextRecordPosition.length() > 0) {
String resultSetId = XPathAPI.eval(srResponse, "/srw:searchRetrieveResponse/srw:resultSetId", xmlnsEl).str();
StringBuffer resumptionToken = new StringBuffer();
resumptionToken.append(resultSetId);
resumptionToken.append(":");
resumptionToken.append(nextRecordPosition);
resumptionToken.append(":");
resumptionToken.append(metadataPrefix);
listRecordsMap.put(
"resumptionMap",
getResumptionMap(resumptionToken.toString()));
// StringBuffer resumptionToken = new StringBuffer();
// resumptionToken.append(from);
// resumptionToken.append(":");
// resumptionToken.append(until);
// resumptionToken.append(":");
// resumptionToken.append(set);
// resumptionToken.append(":");
// resumptionToken.append(metadataPrefix);
// resumptionToken.append(":");
// resumptionToken.append(nodeList.getLength());
// listRecordsMap.put(
// "resumptionMap",
// getResumptionMap(resumptionToken.toString()));
}
} else {
throw new NoItemsMatchException();
}
listRecordsMap.put("records", recordsList.iterator());
return listRecordsMap;
} catch (TransformerException e) {
// logger.warn("failure", e);
e.printStackTrace();
throw new OAIInternalServerError(e.getMessage());
} catch (SAXException e) {
// logger.warn("failure", e);
e.printStackTrace();
throw new OAIInternalServerError(e.getMessage());
} catch (IOException e) {
// logger.warn("failure", e);
e.printStackTrace();
throw new OAIInternalServerError(e.getMessage());
} catch (ParserConfigurationException e) {
// logger.warn("failure", e);
e.printStackTrace();
throw new OAIInternalServerError(e.getMessage());
}
}