String axlResponse = "";
if (axlRequest.indexOf("<GET_METADATA><GET_METADATA_DOCUMENT") != -1
|| axlRequest.indexOf("<SEARCH_METADATA") != -1) {
XsltTemplate template = getAxlToCswXsltTemplate();
Map<String, String> params = new HashMap<String, String>();
if (axlRequest.contains("{thisHHHH-isHH-aHHH-dumm-ydocidHHHhhh}")) {
params.put("all", "all");
}
int start = axlRequest.indexOf("startresult=\"");
int end = 0;
String parts = null;
if(start != -1){
end = axlRequest.indexOf("\"",start+13);
parts = axlRequest.substring(start+13,end);
}
start = axlRequest.indexOf("maxresults=\"");
String max = null;
if(start != -1){
end = axlRequest.indexOf("\"",start+12);
max = axlRequest.substring(start+12,end);
}
String cswRequest = template.transform(axlRequest, params);
getLogger().finest(" AXL2CSW transformed request : " + cswRequest);
String cswResponse = "";
try {
RequestHandler handler = ProviderFactory.newHandler(context);
OperationResponse resp = handler.handleXML(cswRequest);
cswResponse = resp.getResponseXml();
} catch (Exception e) {
throw new SearchException(e);
}
getLogger().finest(" CSW response : " + cswResponse);
String metadataUrl = "/csw?service=CSW&request=GetRecordById&version=2.0.2&ElementSetName=full&outputSchema=original&ID=";
String requestUrl = request.getRequestURL().toString();
String contextPath = request.getContextPath();
String baseUrl = requestUrl.substring(0, requestUrl.indexOf(contextPath));
metadataUrl = baseUrl + contextPath + metadataUrl;
params = new HashMap<String, String>();
params.put("partialMetadataUrl", metadataUrl);
params.put("partialThumbnailUrl", baseUrl);
if (axlRequest.indexOf("<GET_METADATA><GET_METADATA_DOCUMENT") != -1) {
start = axlRequest.indexOf("docid=\"");
end = axlRequest.indexOf("/></GET_METADATA>");
String docid = axlRequest.substring(start + 7, end).trim();
docid = docid.substring(0, docid.length() - 1);
String url = "/csw?service=CSW&request=GetRecordById&version=2.0.2&ElementSetName=full&outputSchema=original&ID="
+ docid;
params.put("metadataUrl", url);
}
if(parts != null && parts.length() > 0){
params.put("startResult", parts);
}
if(max != null && max.length() > 0){
params.put("maxResults", max);
}
template = getCswToAxlXsltTemplate();
axlResponse = template.transform(cswResponse, params);
} else if (axlRequest.indexOf("<GET_METADATA><GET_ROOT_DATASET") != -1) {
StringBuffer sb = new StringBuffer();
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
.append(