1 package com.indexdata.mkjsf.pazpar2;
\r
3 import org.apache.log4j.Logger;
\r
5 import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command;
\r
7 public class CommandThread extends Thread {
\r
9 private static Logger logger = Logger.getLogger(CommandThread.class);
\r
10 Pazpar2Command command;
\r
11 SearchClient client;
\r
12 CommandResponse commandResponse = null;
\r
14 public CommandThread (Pazpar2Command command, SearchClient client) {
\r
15 this.command = command;
\r
16 this.client = client;
\r
20 * Runs the specified command using the specified Pazpar2 client
\r
21 * Sets the Pazpar2 response as an XML response string to be retrieved by
\r
24 * In case of an exception, an error response is generated, the document
\r
25 * element being the same as it would have been if successful (named after
\r
26 * the command, that is).
\r
31 if (command.getCommandName().equals("search")) {
\r
32 client.setSearchCommand(command);
\r
34 long start = System.currentTimeMillis();
\r
35 commandResponse = client.executeCommand(command);
\r
36 long end = System.currentTimeMillis();
\r
37 logger.debug("Executed " + command.getCommandName() + " in " + (end-start) + " ms." );
\r
42 * @return Pazpar2 response as an XML string, possibly a generated error XML
\r
44 public CommandResponse getCommandResponse () {
\r
45 return commandResponse;
\r
48 public Pazpar2Command getCommand() {
\r