+ ResponseDataObject responseObject = null; \r
+ logger.info("Request "+commandName + ": "+ pzreq.getCommand("search").toString());\r
+ Pazpar2Command command = pzreq.getCommand(commandName);\r
+ long start = System.currentTimeMillis();\r
+ HttpResponseWrapper commandResponse = searchClient.executeCommand(command);\r
+ long end = System.currentTimeMillis();\r
+ logger.debug("Executed " + command.getCommandName() + " in " + (end-start) + " ms." );\r
+ responseLogger.debug("Response was: " + commandResponse.getResponseString());\r
+ if (commandResponse.getContentType().contains("xml")) {\r
+ responseObject = ResponseParser.getParser().getDataObject((ClientCommandResponse)commandResponse);\r
+ if (ResponseParser.docTypes.contains(responseObject.getType())) {\r
+ logger.debug("Storing " + responseObject.getType() + " in pzresp. ");\r
+ pzresp.put(commandName, responseObject);\r
+ } else {\r
+ if (commandName.equals("record")) {\r
+ logger.debug("Command was 'record' but response not '<record>' - assuming raw record response.");\r
+ ResponseDataObject recordResponse = new RecordResponse(); \r
+ recordResponse.setType("record");\r
+ recordResponse.setXml(responseObject.getXml()); \r
+ recordResponse.setAttribute("activeclients", "0");\r
+ pzresp.put("record", recordResponse); \r
+ } \r
+ }\r
+ } else if (commandResponse.isBinary()) {\r
+ responseObject = new RecordResponse(); \r
+ responseObject.setType(commandName);\r
+ logger.info("Binary response");\r
+ responseObject.setAttribute("activeclients", "0");\r
+ responseObject.setXml("<record>binary response</record>");\r
+ responseObject.setBinary(commandResponse.getBytes());\r
+ pzresp.put("record", responseObject);\r
+ } else {\r
+ logger.error("Response was not found to be XML or binary. The response was not handled.");\r
+ }\r
+ return responseObject;\r