Renames class, removes obsolete, javadoc
[mkjsf-moved-to-github.git] / src / main / java / com / indexdata / mkjsf / pazpar2 / Pz2Client.java
index 6dfe77f..3417a47 100644 (file)
@@ -27,6 +27,20 @@ import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command;
 import com.indexdata.mkjsf.pazpar2.data.CommandError;\r
 import com.indexdata.mkjsf.utils.Utils;\r
 \r
+/**\r
+ * Search client handling straight Pazpar2 requests. \r
+ * \r
+ * <p>Although it is described here as straight Pazpar2, the client itself \r
+ * actually represents a layer between Pazpar2 and the JSF application because it \r
+ * uses the Pazpar2 client from the library masterkey-common.</p>\r
+ * That client, which is the one also used by the Service Proxy, does perform certain \r
+ * types of session handling, bootstraps lost sessions, avoids repeating already \r
+ * executed queries etc, so it is -- in other words -- still a mediated interaction \r
+ * with Pazpar2 that takes place. At least for now.</p>  \r
+ *  \r
+ * @author Niels Erik\r
+ *\r
+ */\r
 public class Pz2Client implements SearchClient {\r
 \r
   private static final long serialVersionUID = 5414266730169982028L;\r
@@ -88,6 +102,13 @@ public class Pz2Client implements SearchClient {
     client.setSearchCommand(clientCommand);    \r
   }\r
 \r
+  /**\r
+   * Runs the give Pazpar2 command and returns a response wrapper with either the received response or \r
+   * with some form of error message. \r
+   * \r
+   * It is intended that this method never throws an exception. All events are supposed to be captured and\r
+   * returned in some form of response. \r
+   */\r
   @Override\r
   public HttpResponseWrapper executeCommand(Pazpar2Command command) {\r
     ClientCommandResponse commandResponse = null;\r
@@ -132,7 +153,7 @@ public class Pz2Client implements SearchClient {
       commandResponse = new ClientCommandResponse(0,CommandError.createErrorXml(command.getCommandName(), "", "ServiceError", e.getMessage(),""),"text/xml");\r
     }\r
     long end = System.currentTimeMillis();      \r
-    logger.debug("Executed " + command.getCommandName() + " in " + (end-start) + " ms." );\r
+    logger.info("Executed " + command.getCommandName() + " in " + (end-start) + " ms." );\r
     return commandResponse;\r
   }\r
 \r
@@ -144,11 +165,17 @@ public class Pz2Client implements SearchClient {
     return clone;\r
   }\r
 \r
+  /**\r
+   * Returns default configuration parameters for the client.\r
+   */\r
   @Override\r
   public Map<String, String> getDefaults() {\r
     return DEFAULTS;\r
   }\r
 \r
+  /**\r
+   * Returns the configuration name of the client\r
+   */\r
   @Override\r
   public String getModuleName() {\r
     return MODULENAME;\r
@@ -178,6 +205,9 @@ public class Pz2Client implements SearchClient {
     }\r
   }\r
 \r
+  /**\r
+   * Provides configuration documentation -- mostly for diagnosing problems   \r
+   */\r
   @Override\r
   public List<String> documentConfiguration() {\r
     List<String> doc = new ArrayList<String>();\r
@@ -189,25 +219,41 @@ public class Pz2Client implements SearchClient {
     return config;\r
   }\r
 \r
+  /**\r
+   * Returns the currently configured Papzar2 URL.\r
+   */\r
   @Override\r
   public String getServiceUrl() {\r
     return cfg.PAZPAR2_URL;    \r
   }\r
 \r
+  /**\r
+   * Returns true if a Papzar2 URL was defined yet. \r
+   */\r
   @Override\r
   public boolean hasServiceUrl() {\r
     return cfg.PAZPAR2_URL != null && cfg.PAZPAR2_URL.length()>0;\r
   }\r
   \r
+  /**\r
+   * Sets the Pazpar2 URL to use for requests. \r
+   */\r
   @Override \r
   public void setServiceUrl (String serviceUrl) {    \r
     cfg.PAZPAR2_URL = serviceUrl;    \r
   }\r
   \r
+  /**\r
+   * Returns the Pazpar2 Service ID \r
+   */\r
   public String getServiceId () {\r
     return cfg.PAZPAR2_SERVICE_ID;\r
   }\r
   \r
+  /**\r
+   * Sets the service ID that Pazpar2 should use when servicing requests\r
+   * @param serviceId\r
+   */\r
   public void setServiceId(String serviceId) {\r
     cfg.PAZPAR2_SERVICE_ID = serviceId;\r
     try {\r