Avoids npe in case of main config file missing
[mkjsf-moved-to-github.git] / src / main / java / com / indexdata / pz2utils4jsf / pazpar2 / Pz2Session.java
index 2940307..886a0b8 100644 (file)
@@ -68,13 +68,15 @@ public class Pz2Session implements Pz2Interface {
         logger.error("Could not configure Pazpar2 client: " + io.getMessage());\r
         configurationErrors.add(new ConfigurationError("Pz2Client Config","ProxyError","Could not configure Pazpar2 client: " + io.getMessage(),errorHelper));\r
       }\r
-      try {\r
-        client = new Pazpar2ClientGeneric(cfg);     \r
-      } catch (ProxyErrorException pe) {\r
-        logger.error("Could not instantiate Pazpar2 client: " + pe.getMessage());\r
-        configurationErrors.add(new ConfigurationError("Pz2Client error","ProxyError","Could not create Pazpar2 client: " +pe.getMessage(),errorHelper));                \r
-      } \r
-      logger.info("Got " + configurationErrors.size() + " configuration errors");\r
+      if (cfg != null) {\r
+        try {\r
+          client = new Pazpar2ClientGeneric(cfg);     \r
+        } catch (ProxyErrorException pe) {\r
+          logger.error("Could not instantiate Pazpar2 client: " + pe.getMessage());\r
+          configurationErrors.add(new ConfigurationError("Pz2Client error","ProxyError","Could not create Pazpar2 client: " +pe.getMessage(),errorHelper));                \r
+        } \r
+        logger.info("Got " + configurationErrors.size() + " configuration errors");        \r
+      }\r
       resetDataObjects();\r
     } else {\r
       logger.warn("Attempt to configure session but it already has a configured client");\r
@@ -293,8 +295,7 @@ public class Pz2Session implements Pz2Interface {
     return queryStates.getCurrentStateKey();\r
   }\r
       \r
-  public void setCurrentStateKey(String key) {\r
-    logger.debug("************** request to set state key to: [" + key + "]");    \r
+  public void setCurrentStateKey(String key) {       \r
     queryStates.setCurrentStateKey(key);\r
   }\r
   \r
@@ -323,8 +324,7 @@ public class Pz2Session implements Pz2Interface {
     return hasConfigurationErrors() || hasCommandErrors();\r
   }\r
 \r
-  public List<ApplicationError> getConfigurationErrors() {\r
-    logger.info("Returning " + configurationErrors.size() + " configuration errors");\r
+  public List<ApplicationError> getConfigurationErrors() {    \r
     return configurationErrors;\r
   }\r
   \r
@@ -475,5 +475,4 @@ public class Pz2Session implements Pz2Interface {
     dataObjects.put("search", new SearchResponse());\r
   }\r
   \r
-\r
 }\r