X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fcom%2Findexdata%2Fpz2utils4jsf%2Fpazpar2%2FPz2Session.java;h=1bac38bc4e3d34e98d38db13bdeeaf10c3c68023;hb=6300a68c2452725149ec64bbaac8416dce4b3aa8;hp=29403070bad23418443ec970dd3ea9454cf60a4a;hpb=b8de1214df604ebb0485b0d4b22d28733c963933;p=mkjsf-moved-to-github.git diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Session.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Session.java index 2940307..1bac38b 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Session.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Session.java @@ -18,7 +18,7 @@ import com.indexdata.masterkey.pazpar2.client.Pazpar2ClientGeneric; import com.indexdata.masterkey.pazpar2.client.exceptions.ProxyErrorException; import com.indexdata.pz2utils4jsf.config.Pz2Configurator; import com.indexdata.pz2utils4jsf.controls.ResultsPager; -import com.indexdata.pz2utils4jsf.errors.ApplicationError; +import com.indexdata.pz2utils4jsf.errors.ErrorInterface; import com.indexdata.pz2utils4jsf.errors.ErrorHelper; import com.indexdata.pz2utils4jsf.errors.ConfigurationError; import com.indexdata.pz2utils4jsf.pazpar2.data.CommandError; @@ -48,7 +48,7 @@ public class Pz2Session implements Pz2Interface { private TargetFilter targetFilter = null; private ResultsPager pager = null; private ErrorHelper errorHelper = null; - private List configurationErrors = null; + private List configurationErrors = null; public Pz2Session () { logger.info("Instantiating pz2 session object [" + Utils.objectId(this) + "]"); @@ -56,7 +56,7 @@ public class Pz2Session implements Pz2Interface { public void init(Pz2Configurator pz2conf) { if (client==null) { - configurationErrors = new ArrayList(); + configurationErrors = new ArrayList(); errorHelper = new ErrorHelper(pz2conf); logger.info(Utils.objectId(this) + " is configuring itself using the provided " + Utils.objectId(pz2conf)); try { @@ -68,13 +68,15 @@ public class Pz2Session implements Pz2Interface { logger.error("Could not configure Pazpar2 client: " + io.getMessage()); configurationErrors.add(new ConfigurationError("Pz2Client Config","ProxyError","Could not configure Pazpar2 client: " + io.getMessage(),errorHelper)); } - try { - client = new Pazpar2ClientGeneric(cfg); - } catch (ProxyErrorException pe) { - logger.error("Could not instantiate Pazpar2 client: " + pe.getMessage()); - configurationErrors.add(new ConfigurationError("Pz2Client error","ProxyError","Could not create Pazpar2 client: " +pe.getMessage(),errorHelper)); - } - logger.info("Got " + configurationErrors.size() + " configuration errors"); + if (cfg != null) { + try { + client = new Pazpar2ClientGeneric(cfg); + } catch (ProxyErrorException pe) { + logger.error("Could not instantiate Pazpar2 client: " + pe.getMessage()); + configurationErrors.add(new ConfigurationError("Pz2Client error","ProxyError","Could not create Pazpar2 client: " +pe.getMessage(),errorHelper)); + } + logger.info("Found " + configurationErrors.size() + " configuration errors"); + } resetDataObjects(); } else { logger.warn("Attempt to configure session but it already has a configured client"); @@ -142,11 +144,7 @@ public class Pz2Session implements Pz2Interface { return "0"; } } else { - configurationErrors.add( - new ConfigurationError("Querying while errors", - "App halted", - "Cannot query Pazpar2 while there are configuration errors.", - errorHelper)); + logger.error("Did not attempt to execute query since there are configuration errors."); return "0"; } @@ -293,8 +291,7 @@ public class Pz2Session implements Pz2Interface { return queryStates.getCurrentStateKey(); } - public void setCurrentStateKey(String key) { - logger.debug("************** request to set state key to: [" + key + "]"); + public void setCurrentStateKey(String key) { queryStates.setCurrentStateKey(key); } @@ -323,8 +320,7 @@ public class Pz2Session implements Pz2Interface { return hasConfigurationErrors() || hasCommandErrors(); } - public List getConfigurationErrors() { - logger.info("Returning " + configurationErrors.size() + " configuration errors"); + public List getConfigurationErrors() { return configurationErrors; } @@ -333,7 +329,7 @@ public class Pz2Session implements Pz2Interface { * error found for an arbitrary command, if any, otherwise * an empty dummy error. */ - public ApplicationError getCommandError() { + public ErrorInterface getCommandError() { CommandError error = new CommandError(); if (dataObjects.get("search").hasApplicationError()) { error = dataObjects.get("search").getApplicationError(); @@ -475,5 +471,4 @@ public class Pz2Session implements Pz2Interface { dataObjects.put("search", new SearchResponse()); } - }