Generalizes and distinguishes - pz2 and sp. Adds auth.
[mkjsf-moved-to-github.git] / src / main / java / com / indexdata / pz2utils4jsf / pazpar2 / Pz2Bean.java
index dcf75a7..f908d80 100644 (file)
@@ -5,14 +5,15 @@ import java.util.List;
 \r
 import javax.annotation.PostConstruct;\r
 import javax.enterprise.context.SessionScoped;\r
+import javax.enterprise.inject.Alternative;\r
 import javax.inject.Inject;\r
 import javax.inject.Named;\r
 \r
 import org.apache.log4j.Logger;\r
 \r
-import com.indexdata.pz2utils4jsf.config.Pz2Configurator;\r
+import com.indexdata.pz2utils4jsf.config.ConfigurationReader;\r
 import com.indexdata.pz2utils4jsf.controls.ResultsPager;\r
-import com.indexdata.pz2utils4jsf.errors.ApplicationError;\r
+import com.indexdata.pz2utils4jsf.errors.ErrorInterface;\r
 import com.indexdata.pz2utils4jsf.pazpar2.data.ByTarget;\r
 import com.indexdata.pz2utils4jsf.pazpar2.data.RecordResponse;\r
 import com.indexdata.pz2utils4jsf.pazpar2.data.ShowResponse;\r
@@ -21,15 +22,16 @@ import com.indexdata.pz2utils4jsf.pazpar2.data.TermListsResponse;
 import com.indexdata.pz2utils4jsf.pazpar2.data.TermResponse;\r
 import com.indexdata.pz2utils4jsf.utils.Utils;\r
 \r
-@Named("pz2") @SessionScoped\r
+@Named("pz2") @SessionScoped @Alternative\r
 public class Pz2Bean implements Pz2Interface, Serializable {\r
 \r
   private static final long serialVersionUID = 3440277287081557861L;\r
   private static Logger logger = Logger.getLogger(Pz2Bean.class);\r
   \r
-  Pz2Session pz2;  \r
-  @Inject Pz2Configurator pz2conf;\r
-  \r
+  @Inject ConfigurationReader configurator;\r
+  protected Pz2Session pz2;  \r
+  protected SearchClient searchClient;  \r
+    \r
   public Pz2Bean () {\r
     logger.info("Instantiating pz2 bean [" + Utils.objectId(this) + "]");\r
   }\r
@@ -38,10 +40,14 @@ public class Pz2Bean implements Pz2Interface, Serializable {
   public void initiatePz2Session() {\r
     logger.debug(Utils.objectId(this) + " will instantiate a Pz2Session next.");\r
     pz2 = new Pz2Session();\r
-    logger.debug(Utils.objectId(this) + " will forward configuration to the new Pz2Session [" + Utils.objectId(pz2) + "]");\r
-    pz2.init(pz2conf);\r
+    searchClient = new StraightPz2Client();\r
+    logger.info("Using [" + Utils.objectId(searchClient) + "] configured by [" \r
+                          + Utils.objectId(configurator) + "] on session [" \r
+                          + Utils.objectId(pz2) + "]" );    \r
+    pz2.init(searchClient,configurator);\r
   }\r
   \r
+  \r
   /* (non-Javadoc)\r
    * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#doSearch(java.lang.String)\r
    */\r
@@ -278,11 +284,11 @@ public class Pz2Bean implements Pz2Interface, Serializable {
     return pz2.hasErrors();\r
   }\r
     \r
-  public ApplicationError getCommandError() {\r
+  public ErrorInterface getCommandError() {\r
     return pz2.getCommandError();\r
   }\r
   \r
-  public List<ApplicationError> getConfigurationErrors () {\r
+  public List<ErrorInterface> getConfigurationErrors () {\r
     return pz2.getConfigurationErrors();\r
   }\r
 \r