Sets up error central. Lets page author decide to show.
[mkjsf-moved-to-github.git] / src / main / java / com / indexdata / pz2utils4jsf / pazpar2 / Pz2Bean.java
index 5a07794..b12082b 100644 (file)
@@ -18,7 +18,7 @@ import com.indexdata.pz2utils4jsf.controls.ResultsPager;
 import com.indexdata.pz2utils4jsf.errors.ConfigurationError;\r
 import com.indexdata.pz2utils4jsf.errors.ConfigurationException;\r
 import com.indexdata.pz2utils4jsf.errors.ErrorHelper;\r
-import com.indexdata.pz2utils4jsf.errors.ErrorInterface;\r
+import com.indexdata.pz2utils4jsf.errors.ErrorCentral;\r
 import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandParameter;\r
 import com.indexdata.pz2utils4jsf.pazpar2.commands.Pazpar2Commands;\r
 import com.indexdata.pz2utils4jsf.pazpar2.data.Pazpar2ResponseData;\r
@@ -42,10 +42,11 @@ public class Pz2Bean implements Pz2Interface, StateListener, Serializable {
   @Inject StateManager stateMgr;\r
   @Inject Pazpar2Commands pzreq;\r
   @Inject Pazpar2Responses pzresp;\r
+  @Inject ErrorCentral errors;\r
   \r
   protected ResultsPager pager = null; \r
 \r
-  protected List<ErrorInterface> configurationErrors = null;\r
+  \r
   protected ErrorHelper errorHelper = null;\r
               \r
   public Pz2Bean () {\r
@@ -64,15 +65,12 @@ public class Pz2Bean implements Pz2Interface, StateListener, Serializable {
   }  \r
   \r
   public void configureClient(SearchClient searchClient, ConfigurationReader configReader) {\r
-    errorHelper = new ErrorHelper(configurator);\r
-    logger.info("pz2 " + Utils.objectId(this) + " sets error helper " + Utils.objectId(errorHelper) + " on pzresp " + Utils.objectId(pzresp));\r
-    pzresp.setErrorHelper(errorHelper);\r
-    configurationErrors = new ArrayList<ErrorInterface>();        \r
     logger.debug(Utils.objectId(this) + " will configure search client for the session");\r
     try {\r
       searchClient.configure(configReader);            \r
     } catch (ConfigurationException e) {\r
-      configurationErrors.add(new ConfigurationError("Search Client","Configuration",e.getMessage(),new ErrorHelper(configReader)));          \r
+      logger.debug("Pz2Bean adding configuration error");\r
+      errors.addConfigurationError(new ConfigurationError("Search Client","Configuration",e.getMessage()));                \r
     } \r
     logger.info(configReader.document());\r
     pzresp.reset();    \r
@@ -112,7 +110,7 @@ public class Pz2Bean implements Pz2Interface, StateListener, Serializable {
    * @return Number of activeclients at the time of the 'show' command\r
    */\r
   public String update (String commands) {\r
-    if (! hasConfigurationErrors()) {\r
+    if (! errors.hasConfigurationErrors()) {\r
       if (commandsAreValid(commands)) {\r
         if (hasQuery()) {\r
           handleQueryStateChanges(commands);\r
@@ -195,25 +193,6 @@ public class Pz2Bean implements Pz2Interface, StateListener, Serializable {
     stateMgr.setCurrentStateKey(key);\r
   }\r
   \r
-  public boolean hasConfigurationErrors () {\r
-      return (configurationErrors.size()>0);      \r
-  }\r
-  \r
-  public boolean hasCommandErrors () {\r
-    return pzresp.hasApplicationError();\r
-  }\r
-  \r
-  /**\r
-   * Returns true if application error found in any response data objects \r
-   */\r
-  public boolean hasErrors () {\r
-    logger.debug("Checking for configuration errors or command errors.");\r
-    return hasConfigurationErrors() || hasCommandErrors();\r
-  }\r
-\r
-  public List<ErrorInterface> getConfigurationErrors() {    \r
-    return configurationErrors;\r
-  }\r
   \r
   \r
   protected boolean hasQuery() {        \r