Renames class, removes obsolete, javadoc
[mkjsf-moved-to-github.git] / src / main / java / com / indexdata / mkjsf / pazpar2 / CommandThread.java
index e3169b9..678e4a6 100644 (file)
@@ -3,45 +3,42 @@ package com.indexdata.mkjsf.pazpar2;
 import org.apache.log4j.Logger;\r
 \r
 import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command;\r
+import com.indexdata.mkjsf.pazpar2.data.Responses;\r
 \r
+/**\r
+ * Helper class for running multiple concurrent Pazpar2 commands. Basically \r
+ * used for updating display data (show,stat,bytarget,termlist) together.\r
+ * \r
+ * @author Niels Erik\r
+ *\r
+ */\r
 public class CommandThread extends Thread {\r
 \r
   private static Logger logger = Logger.getLogger(CommandThread.class);\r
   Pazpar2Command command;\r
   SearchClient client;\r
-  CommandResponse commandResponse = null;      \r
+  Responses pzresp;\r
+  HttpResponseWrapper commandResponse = null;      \r
   \r
-  public CommandThread (Pazpar2Command command, SearchClient client) {\r
+  public CommandThread (Pazpar2Command command, SearchClient client, Responses pzresp) {\r
     this.command = command;\r
     this.client = client;\r
+    this.pzresp = pzresp;\r
   }\r
   \r
   /**\r
-   * Runs the specified command using the specified Pazpar2 client\r
-   * Sets the Pazpar2 response as an XML response string to be retrieved by\r
-   * getResponse().\r
-   * \r
-   * In case of an exception, an error response is generated, the document\r
-   * element being the same as it would have been if successful (named after\r
-   * the command, that is).  \r
-   *  \r
+   * Executes the specified command using the specified Pazpar2 client\r
    */\r
-  public void run() {\r
-    \r
-    if (command.getCommandName().equals("search")) {\r
-      client.setSearchCommand(command);\r
-    }\r
-    long start = System.currentTimeMillis();\r
-    commandResponse = client.executeCommand(command);\r
-    long end = System.currentTimeMillis();\r
-    logger.debug("Executed " + command.getCommandName() + " in " + (end-start) + " ms." );\r
+  public void run() {    \r
+    logger.debug(command.getCommandName() + " executing asynchronously");\r
+    command.run(client,pzresp);\r
   }\r
   \r
   /**\r
    * \r
    * @return Pazpar2 response as an XML string, possibly a generated error XML\r
    */\r
-  public CommandResponse getCommandResponse () {\r
+  public HttpResponseWrapper getCommandResponse () {\r
     return commandResponse;\r
   }\r
     \r