From 9cd922c29f423b69da6f52eabf0c7fdb0b0b6ca5 Mon Sep 17 00:00:00 2001 From: "Niels Erik G. Nielsen" Date: Fri, 24 May 2013 22:35:46 -0400 Subject: [PATCH] Renames Pz2Bean to Pz2Service Name exposed to UI is still just 'pz2' --- .../com/indexdata/mkjsf/errors/ErrorCentral.java | 6 +- .../java/com/indexdata/mkjsf/pazpar2/Pz2Bean.java | 520 -------------------- .../com/indexdata/mkjsf/pazpar2/Pz2Service.java | 520 ++++++++++++++++++++ .../mkjsf/pazpar2/ServiceProxyExtensions.java | 20 +- .../mkjsf/pazpar2/commands/Pazpar2Command.java | 8 +- .../mkjsf/pazpar2/commands/Pazpar2Commands.java | 26 +- .../mkjsf/pazpar2/commands/RecordCommand.java | 8 +- .../mkjsf/pazpar2/commands/SearchCommand.java | 12 +- .../mkjsf/pazpar2/commands/sp/AuthCommand.java | 10 +- .../pazpar2/commands/sp/CategoriesCommand.java | 6 +- .../mkjsf/pazpar2/state/StateManager.java | 2 +- 11 files changed, 569 insertions(+), 569 deletions(-) delete mode 100644 src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Bean.java create mode 100644 src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Service.java diff --git a/src/main/java/com/indexdata/mkjsf/errors/ErrorCentral.java b/src/main/java/com/indexdata/mkjsf/errors/ErrorCentral.java index 71bb9c5..b6bbd47 100644 --- a/src/main/java/com/indexdata/mkjsf/errors/ErrorCentral.java +++ b/src/main/java/com/indexdata/mkjsf/errors/ErrorCentral.java @@ -11,7 +11,7 @@ import javax.inject.Named; import org.apache.log4j.Logger; import com.indexdata.mkjsf.config.ConfigurationReader; -import com.indexdata.mkjsf.pazpar2.Pz2Bean; +import com.indexdata.mkjsf.pazpar2.Pz2Service; @SessionScoped @Named public class ErrorCentral implements Serializable { @@ -39,11 +39,11 @@ public class ErrorCentral implements Serializable { } public boolean hasCommandErrors () { - return Pz2Bean.get().getPzresp().hasApplicationError(); + return Pz2Service.get().getPzresp().hasApplicationError(); } public ErrorInterface getCommandError () { - return Pz2Bean.get().getPzresp().getCommandError(); + return Pz2Service.get().getPzresp().getCommandError(); } /** diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Bean.java b/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Bean.java deleted file mode 100644 index 8e3a14d..0000000 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Bean.java +++ /dev/null @@ -1,520 +0,0 @@ -package com.indexdata.mkjsf.pazpar2; - -import java.io.Serializable; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - -import javax.annotation.PostConstruct; -import javax.enterprise.context.SessionScoped; -import javax.enterprise.inject.Produces; -import javax.faces.context.FacesContext; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Qualifier; - -import org.apache.log4j.Logger; - -import com.indexdata.mkjsf.config.Configurable; -import com.indexdata.mkjsf.config.Configuration; -import com.indexdata.mkjsf.config.ConfigurationReader; -import com.indexdata.mkjsf.controls.ResultsPager; -import com.indexdata.mkjsf.errors.ConfigurationError; -import com.indexdata.mkjsf.errors.ConfigurationException; -import com.indexdata.mkjsf.errors.ErrorCentral; -import com.indexdata.mkjsf.errors.ErrorHelper; -import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command; -import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Commands; -import com.indexdata.mkjsf.pazpar2.data.RecordResponse; -import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject; -import com.indexdata.mkjsf.pazpar2.data.Responses; -import com.indexdata.mkjsf.pazpar2.state.StateListener; -import com.indexdata.mkjsf.pazpar2.state.StateManager; -import com.indexdata.mkjsf.utils.Utils; - -@Named("pz2") @SessionScoped -public class Pz2Bean implements Pz2Interface, StateListener, Configurable, Serializable { - - private static final String MODULE_NAME = "service"; - private static String SERVICE_TYPE_TBD = "TBD", SERVICE_TYPE_PZ2 = "PZ2", SERVICE_TYPE_SP = "SP"; - private static final List serviceTypes = - Arrays.asList(SERVICE_TYPE_PZ2,SERVICE_TYPE_SP,SERVICE_TYPE_TBD); - private String serviceType = SERVICE_TYPE_TBD; - private List serviceProxyUrls = new ArrayList(); - public static final String SERVICE_PROXY_URL_LIST = "SERVICE_PROXY_URL_LIST"; - private List pazpar2Urls = new ArrayList(); - public static final String PAZPAR2_URL_LIST = "PAZPAR2_URL_LIST"; - - - private static final long serialVersionUID = 3440277287081557861L; - private static Logger logger = Logger.getLogger(Pz2Bean.class); - protected Pz2Client pz2Client = null; - protected ServiceProxyClient spClient = null; - protected SearchClient searchClient = null; - - @Inject ConfigurationReader configurator; - - private StateManager stateMgr = null; - private Pazpar2Commands pzreq = null; - private Responses pzresp = null; - private ErrorCentral errors = null; - - protected ResultsPager pager = null; - - protected ErrorHelper errorHelper = null; - - public Pz2Bean () { - logger.info("Instantiating pz2 bean [" + Utils.objectId(this) + "]"); - } - - public static Pz2Bean get() { - FacesContext context = FacesContext.getCurrentInstance(); - return (Pz2Bean) context.getApplication().evaluateExpressionGet(context, "#{pz2}", Object.class); - } - - @PostConstruct - public void postConstruct() { - logger.info("Pz2Bean PostConstruct of " + this); - stateMgr = new StateManager(); - pzreq = new Pazpar2Commands(); - pzresp = new Responses(); - errors = new ErrorCentral(); - pzresp.setErrorHelper(errors.getHelper()); - - logger.debug("Pz2Bean PostConstruct: Configurator is " + configurator); - logger.debug(Utils.objectId(this) + " will instantiate a Pz2Client next."); - pz2Client = new Pz2Client(); - configureClient(pz2Client,configurator); - spClient = new ServiceProxyClient(); - configureClient(spClient,configurator); - try { - this.configure(configurator); - } catch (ConfigurationException e) { - logger.error("There was a problem configuring the Pz2Bean (\"pz2\")"); - e.printStackTrace(); - } - stateMgr.addStateListener(this); - } - - @Qualifier - @Target({java.lang.annotation.ElementType.TYPE, - java.lang.annotation.ElementType.METHOD, - java.lang.annotation.ElementType.PARAMETER, - java.lang.annotation.ElementType.FIELD}) - @Retention(java.lang.annotation.RetentionPolicy.RUNTIME) - public @interface Preferred{} - - @Produces @Preferred @SessionScoped @Named("pzresp") public Responses getPzresp () { - logger.trace("Producing pzresp"); - return pzresp; - } - - @Produces @Preferred @SessionScoped @Named("pzreq") public Pazpar2Commands getPzreq () { - logger.trace("Producing pzreq"); - return pzreq; - } - - @Produces @Preferred @SessionScoped @Named("errors") public ErrorCentral getErrors() { - logger.trace("Producing errors"); - return errors; - } - - @Produces @Preferred @SessionScoped @Named("stateMgr") public StateManager getStateMgr() { - logger.trace("Producing stateMgr"); - return stateMgr; - } - - public void configureClient(SearchClient client, ConfigurationReader configReader) { - logger.debug(Utils.objectId(this) + " will configure search client for the session"); - try { - client.configure(configReader); - } catch (ConfigurationException e) { - logger.debug("Pz2Bean adding configuration error"); - errors.addConfigurationError(new ConfigurationError("Search Client","Configuration",e.getMessage())); - } - logger.info(configReader.document()); - pzresp.getSp().resetAuthAndBeyond(true); - } - - public void resetSearchAndRecordCommands () { - pzreq.getRecord().removeParametersInState(); - pzreq.getSearch().removeParametersInState(); - } - - /** - * Refreshes 'show', 'stat', 'termlist', and 'bytarget' data object from pazpar2 - * - * @return Number of activeclients at the time of the 'show' command. - */ - public String update () { - logger.debug("Updating show,stat,termlist,bytarget from pazpar2"); - if (errors.hasConfigurationErrors()) { - logger.error("Ignoring show,stat,termlist,bytarget commands due to configuration errors."); - return ""; - } else if (pzresp.getSearch().hasApplicationError()) { - logger.error("Ignoring show,stat,termlist,bytarget commands due to problem with most recent search."); - return ""; - } else if (!hasQuery()) { - logger.debug("Ignoring show,stat,termlist,bytarget commands because there is not yet a query."); - return ""; - } else { - return update("show,stat,termlist,bytarget"); - } - } - - /** - * Refreshes the data objects listed in 'commands' from pazpar2 - * - * @param commands - * @return Number of activeclients at the time of the 'show' command, - * or 'new' if search was just initiated. - */ - public String update (String commands) { - logger.debug("Request to update: " + commands); - try { - if (commands.equals("search")) { - pzreq.getSearch().run(); - return "new"; - } else if (commands.equals("record")) { - pzreq.getRecord().run(); - return pzresp.getRecord().getActiveClients(); - } else if (pzresp.getSearch().isNew()) { - // For returning notification of 'search started' quickly to UI - logger.info("New search. Marking it old, then returning 'new' to trigger another round-trip."); - pzresp.getSearch().setIsNew(false); - return "new"; - } else { - handleQueryStateChanges(commands); - if (pzresp.getSearch().hasApplicationError()) { - logger.error("The command(s) " + commands + " cancelled because the latest search command had an error."); - return "0"; - } else if (errors.hasConfigurationErrors()) { - logger.error("The command(s) " + commands + " cancelled due to configuration errors."); - return "0"; - } else { - logger.debug("Processing request for " + commands); - List threadList = new ArrayList(); - StringTokenizer tokens = new StringTokenizer(commands,","); - while (tokens.hasMoreElements()) { - threadList.add(new CommandThread(pzreq.getCommand(tokens.nextToken()),searchClient,Pz2Bean.get().getPzresp())); - } - for (CommandThread thread : threadList) { - thread.start(); - } - for (CommandThread thread : threadList) { - try { - thread.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - return pzresp.getActiveClients(); - } - } - } catch (ClassCastException cce) { - cce.printStackTrace(); - return ""; - } catch (NullPointerException npe) { - npe.printStackTrace(); - return ""; - } catch (Exception e) { - e.printStackTrace(); - return ""; - } - - } - - public String toggleRecord (String recId) { - if (hasRecord(recId)) { - pzreq.getRecord().removeParameters(); - pzresp.put("record", new RecordResponse()); - return ""; - } else { - pzreq.getRecord().setId(recId); - doCommand("record"); - return pzresp.getRecord().getActiveClients(); - } - } - - @Override - public boolean hasRecord (String recId) { - return pzreq.getCommand("record").hasParameters() && pzresp.getRecord().getRecId().equals(recId); - } - - public String getCurrentStateKey () { - return stateMgr.getCurrentState().getKey(); - } - - public void setCurrentStateKey(String key) { - stateMgr.setCurrentStateKey(key); - } - - protected boolean hasQuery() { - return pzreq.getCommand("search").hasParameterValue("query"); - } - - - @Override - public ResultsPager getPager () { - if (pager == null) { - pager = new ResultsPager(pzresp); - } - return pager; - } - - @Override - public ResultsPager setPager (int pageRange) { - pager = new ResultsPager(pzresp,pageRange,pzreq); - return pager; - } - - /** - * This methods main purpose is to support browser history. - * - * When the browsers back or forward buttons are pressed, a - * re-search /might/ be required - namely if the query changes. - * So, as the UI requests updates of the page (show,facets, - * etc) this method checks if a search must be executed - * before those updates are performed. - * - * @see {@link com.indexdata.mkjsf.pazpar2.state.StateManager#setCurrentStateKey} - * @param commands - */ - protected void handleQueryStateChanges (String commands) { - if (stateMgr.hasPendingStateChange("search") && hasQuery()) { - logger.info("Triggered search: Found pending search change [" + pzreq.getCommand("search").toString() + "], doing search before updating " + commands); - pzreq.getSearch().run(); - } - if (stateMgr.hasPendingStateChange("record") && ! commands.equals("record")) { - logger.debug("Found pending record ID change. Doing record before updating " + commands); - stateMgr.hasPendingStateChange("record",false); - pzreq.getRecord().run(); - } - } - - /** - * Executes the command and parses the response to create data objects. - * If the parsed response is of a known type it will be cached in 'pzresp' - * - * @param commandName The command to be executed - * @return An XML response parsed to form a response data object - */ - protected ResponseDataObject doCommand(String commandName) { - Pazpar2Command command = pzreq.getCommand(commandName); - if (command.spOnly() && isPazpar2Service()) { - logger.warn("Skipping " + commandName + " - SP-only command, not supported by Pazpar2"); - return new ResponseDataObject(); - } else { - logger.info("Request "+commandName + ". Search command is: "+ pzreq.getCommand("search").toString()); - long start = System.currentTimeMillis(); - ResponseDataObject responseObject = command.run(); - long end = System.currentTimeMillis(); - logger.debug("Executed " + command.getCommandName() + " in " + (end-start) + " ms." ); - return responseObject; - } - } - - @Override - public void stateUpdated(String commandName) { - logger.debug("State change reported for [" + commandName + "]"); - if (commandName.equals("show")) { - logger.debug("Updating show"); - update(commandName); - } - } - - public void setServiceProxyUrl(String url) { - searchClient = spClient; - setServiceType(SERVICE_TYPE_SP); - setServiceUrl(url); - } - - public String getServiceProxyUrl () { - if (isServiceProxyService()) { - return spClient.getServiceUrl(); - } else { - return ""; - } - } - - public void setPazpar2Url(String url) { - searchClient = pz2Client; - setServiceType(SERVICE_TYPE_PZ2); - setServiceUrl(url); - } - - public String getPazpar2Url() { - if (isPazpar2Service()) { - return pz2Client.getServiceUrl(); - } else { - return ""; - } - } - - - @Override - public void setServiceUrl(String url) { - if (url!=null && searchClient != null && !url.equals(searchClient.getServiceUrl())) { - pzreq.getRecord().removeParametersInState(); - pzreq.getSearch().removeParametersInState(); - pzresp.getSp().resetAuthAndBeyond(true); - searchClient.setServiceUrl(url); - } - } - - public String getServiceUrl() { - return (searchClient!=null ? searchClient.getServiceUrl() : ""); - } - - public void setServiceId () { - pzreq.getRecord().removeParametersInState(); - pzreq.getSearch().removeParametersInState(); - pzresp.resetSearchAndBeyond(); - pz2Client.setServiceId(pzreq.getInit().getService()); - } - - public String getServiceId () { - return pzreq.getInit().getService(); - } - - public boolean getServiceUrlIsDefined() { - return (searchClient != null && searchClient.hasServiceUrl()); - } - - public List getServiceProxyUrls() { - List urls = new ArrayList(); - urls.add(""); - urls.addAll(serviceProxyUrls); - return urls; - } - - public List getPazpar2Urls () { - List urls = new ArrayList(); - urls.add(""); - urls.addAll(pazpar2Urls); - return urls; - } - - public String getServiceType () { - return serviceType; - } - - public boolean isPazpar2Service () { - return serviceType.equals(SERVICE_TYPE_PZ2); - } - - public boolean isServiceProxyService() { - return serviceType.equals(SERVICE_TYPE_SP); - } - - public boolean serviceIsToBeDecided () { - return serviceType.equals(SERVICE_TYPE_TBD); - } - - public ServiceProxyClient getSpClient () { - return spClient; - } - - @Override - public boolean getAuthenticationRequired () { - return spClient.isAuthenticatingClient(); - } - - @Override - public String getCheckHistory () { - return ":pz2watch:stateForm:windowlocationhash"; - } - - @Override - public String getWatchActiveclients () { - return ":pz2watch:activeclientsForm:activeclientsField"; - } - - @Override - public String getWatchActiveclientsRecord () { - return ":pz2watch:activeclientsForm:activeclientsFieldRecord"; - } - - @Override - public void configure(ConfigurationReader reader) - throws ConfigurationException { - Configuration config = reader.getConfiguration(this); - if (config == null) { - serviceType = SERVICE_TYPE_TBD; - } else { - String service = config.get("TYPE"); - if (service == null || service.length()==0) { - serviceType = SERVICE_TYPE_TBD; - } else if (serviceTypes.contains(service.toUpperCase())) { - setServiceType(service.toUpperCase()); - } else { - logger.error("Unknown serviceType type in configuration [" + service + "], can be one of " + serviceTypes); - serviceType = SERVICE_TYPE_TBD; - } - serviceProxyUrls = config.getMultiProperty(SERVICE_PROXY_URL_LIST,","); - pazpar2Urls = config.getMultiProperty(PAZPAR2_URL_LIST, ","); - } - logger.info(reader.document()); - logger.info("Service Type is configured to " + serviceType); - - } - - @Override - public Map getDefaults() { - return new HashMap(); - } - - @Override - public String getModuleName() { - return MODULE_NAME; - } - - @Override - public List documentConfiguration() { - return new ArrayList(); - } - - @Override - public void setServiceTypePZ2() { - setServiceType(SERVICE_TYPE_PZ2); - } - - @Override - public void setServiceTypeSP() { - setServiceType(SERVICE_TYPE_SP); - } - - @Override - public void setServiceTypeTBD() { - setServiceType(SERVICE_TYPE_TBD); - } - - private void setServiceType(String type) { - if (!serviceType.equals(type) && - !serviceType.equals(SERVICE_TYPE_TBD)) { - resetSearchAndRecordCommands(); - pzresp.getSp().resetAuthAndBeyond(true); - } - serviceType = type; - if (serviceType.equals(SERVICE_TYPE_PZ2)) { - searchClient = pz2Client; - logger.info("Setting a Pazpar2 client to serve requests."); - } else if (serviceType.equals(SERVICE_TYPE_SP)) { - searchClient = spClient; - logger.info("Setting a Service Proxy client to serve requests."); - } else { - logger.info("Clearing search client. No client defined to serve requests at this point."); - searchClient = null; - } - } - - public SearchClient getSearchClient() { - return searchClient; - } - -} diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Service.java b/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Service.java new file mode 100644 index 0000000..f38d90d --- /dev/null +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Service.java @@ -0,0 +1,520 @@ +package com.indexdata.mkjsf.pazpar2; + +import java.io.Serializable; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; + +import javax.annotation.PostConstruct; +import javax.enterprise.context.SessionScoped; +import javax.enterprise.inject.Produces; +import javax.faces.context.FacesContext; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Qualifier; + +import org.apache.log4j.Logger; + +import com.indexdata.mkjsf.config.Configurable; +import com.indexdata.mkjsf.config.Configuration; +import com.indexdata.mkjsf.config.ConfigurationReader; +import com.indexdata.mkjsf.controls.ResultsPager; +import com.indexdata.mkjsf.errors.ConfigurationError; +import com.indexdata.mkjsf.errors.ConfigurationException; +import com.indexdata.mkjsf.errors.ErrorCentral; +import com.indexdata.mkjsf.errors.ErrorHelper; +import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command; +import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Commands; +import com.indexdata.mkjsf.pazpar2.data.RecordResponse; +import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject; +import com.indexdata.mkjsf.pazpar2.data.Responses; +import com.indexdata.mkjsf.pazpar2.state.StateListener; +import com.indexdata.mkjsf.pazpar2.state.StateManager; +import com.indexdata.mkjsf.utils.Utils; + +@Named("pz2") @SessionScoped +public class Pz2Service implements Pz2Interface, StateListener, Configurable, Serializable { + + private static final String MODULE_NAME = "service"; + private static String SERVICE_TYPE_TBD = "TBD", SERVICE_TYPE_PZ2 = "PZ2", SERVICE_TYPE_SP = "SP"; + private static final List serviceTypes = + Arrays.asList(SERVICE_TYPE_PZ2,SERVICE_TYPE_SP,SERVICE_TYPE_TBD); + private String serviceType = SERVICE_TYPE_TBD; + private List serviceProxyUrls = new ArrayList(); + public static final String SERVICE_PROXY_URL_LIST = "SERVICE_PROXY_URL_LIST"; + private List pazpar2Urls = new ArrayList(); + public static final String PAZPAR2_URL_LIST = "PAZPAR2_URL_LIST"; + + + private static final long serialVersionUID = 3440277287081557861L; + private static Logger logger = Logger.getLogger(Pz2Service.class); + protected Pz2Client pz2Client = null; + protected ServiceProxyClient spClient = null; + protected SearchClient searchClient = null; + + @Inject ConfigurationReader configurator; + + private StateManager stateMgr = null; + private Pazpar2Commands pzreq = null; + private Responses pzresp = null; + private ErrorCentral errors = null; + + protected ResultsPager pager = null; + + protected ErrorHelper errorHelper = null; + + public Pz2Service () { + logger.info("Instantiating pz2 bean [" + Utils.objectId(this) + "]"); + } + + public static Pz2Service get() { + FacesContext context = FacesContext.getCurrentInstance(); + return (Pz2Service) context.getApplication().evaluateExpressionGet(context, "#{pz2}", Object.class); + } + + @PostConstruct + public void postConstruct() { + logger.info("Pz2Service PostConstruct of " + this); + stateMgr = new StateManager(); + pzreq = new Pazpar2Commands(); + pzresp = new Responses(); + errors = new ErrorCentral(); + pzresp.setErrorHelper(errors.getHelper()); + + logger.debug("Pz2Service PostConstruct: Configurator is " + configurator); + logger.debug(Utils.objectId(this) + " will instantiate a Pz2Client next."); + pz2Client = new Pz2Client(); + configureClient(pz2Client,configurator); + spClient = new ServiceProxyClient(); + configureClient(spClient,configurator); + try { + this.configure(configurator); + } catch (ConfigurationException e) { + logger.error("There was a problem configuring the Pz2Service (\"pz2\")"); + e.printStackTrace(); + } + stateMgr.addStateListener(this); + } + + @Qualifier + @Target({java.lang.annotation.ElementType.TYPE, + java.lang.annotation.ElementType.METHOD, + java.lang.annotation.ElementType.PARAMETER, + java.lang.annotation.ElementType.FIELD}) + @Retention(java.lang.annotation.RetentionPolicy.RUNTIME) + public @interface Preferred{} + + @Produces @Preferred @SessionScoped @Named("pzresp") public Responses getPzresp () { + logger.trace("Producing pzresp"); + return pzresp; + } + + @Produces @Preferred @SessionScoped @Named("pzreq") public Pazpar2Commands getPzreq () { + logger.trace("Producing pzreq"); + return pzreq; + } + + @Produces @Preferred @SessionScoped @Named("errors") public ErrorCentral getErrors() { + logger.trace("Producing errors"); + return errors; + } + + @Produces @Preferred @SessionScoped @Named("stateMgr") public StateManager getStateMgr() { + logger.trace("Producing stateMgr"); + return stateMgr; + } + + public void configureClient(SearchClient client, ConfigurationReader configReader) { + logger.debug(Utils.objectId(this) + " will configure search client for the session"); + try { + client.configure(configReader); + } catch (ConfigurationException e) { + logger.debug("Pz2Service adding configuration error"); + errors.addConfigurationError(new ConfigurationError("Search Client","Configuration",e.getMessage())); + } + logger.info(configReader.document()); + pzresp.getSp().resetAuthAndBeyond(true); + } + + public void resetSearchAndRecordCommands () { + pzreq.getRecord().removeParametersInState(); + pzreq.getSearch().removeParametersInState(); + } + + /** + * Refreshes 'show', 'stat', 'termlist', and 'bytarget' data object from pazpar2 + * + * @return Number of activeclients at the time of the 'show' command. + */ + public String update () { + logger.debug("Updating show,stat,termlist,bytarget from pazpar2"); + if (errors.hasConfigurationErrors()) { + logger.error("Ignoring show,stat,termlist,bytarget commands due to configuration errors."); + return ""; + } else if (pzresp.getSearch().hasApplicationError()) { + logger.error("Ignoring show,stat,termlist,bytarget commands due to problem with most recent search."); + return ""; + } else if (!hasQuery()) { + logger.debug("Ignoring show,stat,termlist,bytarget commands because there is not yet a query."); + return ""; + } else { + return update("show,stat,termlist,bytarget"); + } + } + + /** + * Refreshes the data objects listed in 'commands' from pazpar2 + * + * @param commands + * @return Number of activeclients at the time of the 'show' command, + * or 'new' if search was just initiated. + */ + public String update (String commands) { + logger.debug("Request to update: " + commands); + try { + if (commands.equals("search")) { + pzreq.getSearch().run(); + return "new"; + } else if (commands.equals("record")) { + pzreq.getRecord().run(); + return pzresp.getRecord().getActiveClients(); + } else if (pzresp.getSearch().isNew()) { + // For returning notification of 'search started' quickly to UI + logger.info("New search. Marking it old, then returning 'new' to trigger another round-trip."); + pzresp.getSearch().setIsNew(false); + return "new"; + } else { + handleQueryStateChanges(commands); + if (pzresp.getSearch().hasApplicationError()) { + logger.error("The command(s) " + commands + " cancelled because the latest search command had an error."); + return "0"; + } else if (errors.hasConfigurationErrors()) { + logger.error("The command(s) " + commands + " cancelled due to configuration errors."); + return "0"; + } else { + logger.debug("Processing request for " + commands); + List threadList = new ArrayList(); + StringTokenizer tokens = new StringTokenizer(commands,","); + while (tokens.hasMoreElements()) { + threadList.add(new CommandThread(pzreq.getCommand(tokens.nextToken()),searchClient,Pz2Service.get().getPzresp())); + } + for (CommandThread thread : threadList) { + thread.start(); + } + for (CommandThread thread : threadList) { + try { + thread.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + return pzresp.getActiveClients(); + } + } + } catch (ClassCastException cce) { + cce.printStackTrace(); + return ""; + } catch (NullPointerException npe) { + npe.printStackTrace(); + return ""; + } catch (Exception e) { + e.printStackTrace(); + return ""; + } + + } + + public String toggleRecord (String recId) { + if (hasRecord(recId)) { + pzreq.getRecord().removeParameters(); + pzresp.put("record", new RecordResponse()); + return ""; + } else { + pzreq.getRecord().setId(recId); + doCommand("record"); + return pzresp.getRecord().getActiveClients(); + } + } + + @Override + public boolean hasRecord (String recId) { + return pzreq.getCommand("record").hasParameters() && pzresp.getRecord().getRecId().equals(recId); + } + + public String getCurrentStateKey () { + return stateMgr.getCurrentState().getKey(); + } + + public void setCurrentStateKey(String key) { + stateMgr.setCurrentStateKey(key); + } + + protected boolean hasQuery() { + return pzreq.getCommand("search").hasParameterValue("query"); + } + + + @Override + public ResultsPager getPager () { + if (pager == null) { + pager = new ResultsPager(pzresp); + } + return pager; + } + + @Override + public ResultsPager setPager (int pageRange) { + pager = new ResultsPager(pzresp,pageRange,pzreq); + return pager; + } + + /** + * This methods main purpose is to support browser history. + * + * When the browsers back or forward buttons are pressed, a + * re-search /might/ be required - namely if the query changes. + * So, as the UI requests updates of the page (show,facets, + * etc) this method checks if a search must be executed + * before those updates are performed. + * + * @see {@link com.indexdata.mkjsf.pazpar2.state.StateManager#setCurrentStateKey} + * @param commands + */ + protected void handleQueryStateChanges (String commands) { + if (stateMgr.hasPendingStateChange("search") && hasQuery()) { + logger.info("Triggered search: Found pending search change [" + pzreq.getCommand("search").toString() + "], doing search before updating " + commands); + pzreq.getSearch().run(); + } + if (stateMgr.hasPendingStateChange("record") && ! commands.equals("record")) { + logger.debug("Found pending record ID change. Doing record before updating " + commands); + stateMgr.hasPendingStateChange("record",false); + pzreq.getRecord().run(); + } + } + + /** + * Executes the command and parses the response to create data objects. + * If the parsed response is of a known type it will be cached in 'pzresp' + * + * @param commandName The command to be executed + * @return An XML response parsed to form a response data object + */ + protected ResponseDataObject doCommand(String commandName) { + Pazpar2Command command = pzreq.getCommand(commandName); + if (command.spOnly() && isPazpar2Service()) { + logger.warn("Skipping " + commandName + " - SP-only command, not supported by Pazpar2"); + return new ResponseDataObject(); + } else { + logger.info("Request "+commandName + ". Search command is: "+ pzreq.getCommand("search").toString()); + long start = System.currentTimeMillis(); + ResponseDataObject responseObject = command.run(); + long end = System.currentTimeMillis(); + logger.debug("Executed " + command.getCommandName() + " in " + (end-start) + " ms." ); + return responseObject; + } + } + + @Override + public void stateUpdated(String commandName) { + logger.debug("State change reported for [" + commandName + "]"); + if (commandName.equals("show")) { + logger.debug("Updating show"); + update(commandName); + } + } + + public void setServiceProxyUrl(String url) { + searchClient = spClient; + setServiceType(SERVICE_TYPE_SP); + setServiceUrl(url); + } + + public String getServiceProxyUrl () { + if (isServiceProxyService()) { + return spClient.getServiceUrl(); + } else { + return ""; + } + } + + public void setPazpar2Url(String url) { + searchClient = pz2Client; + setServiceType(SERVICE_TYPE_PZ2); + setServiceUrl(url); + } + + public String getPazpar2Url() { + if (isPazpar2Service()) { + return pz2Client.getServiceUrl(); + } else { + return ""; + } + } + + + @Override + public void setServiceUrl(String url) { + if (url!=null && searchClient != null && !url.equals(searchClient.getServiceUrl())) { + pzreq.getRecord().removeParametersInState(); + pzreq.getSearch().removeParametersInState(); + pzresp.getSp().resetAuthAndBeyond(true); + searchClient.setServiceUrl(url); + } + } + + public String getServiceUrl() { + return (searchClient!=null ? searchClient.getServiceUrl() : ""); + } + + public void setServiceId () { + pzreq.getRecord().removeParametersInState(); + pzreq.getSearch().removeParametersInState(); + pzresp.resetSearchAndBeyond(); + pz2Client.setServiceId(pzreq.getInit().getService()); + } + + public String getServiceId () { + return pzreq.getInit().getService(); + } + + public boolean getServiceUrlIsDefined() { + return (searchClient != null && searchClient.hasServiceUrl()); + } + + public List getServiceProxyUrls() { + List urls = new ArrayList(); + urls.add(""); + urls.addAll(serviceProxyUrls); + return urls; + } + + public List getPazpar2Urls () { + List urls = new ArrayList(); + urls.add(""); + urls.addAll(pazpar2Urls); + return urls; + } + + public String getServiceType () { + return serviceType; + } + + public boolean isPazpar2Service () { + return serviceType.equals(SERVICE_TYPE_PZ2); + } + + public boolean isServiceProxyService() { + return serviceType.equals(SERVICE_TYPE_SP); + } + + public boolean serviceIsToBeDecided () { + return serviceType.equals(SERVICE_TYPE_TBD); + } + + public ServiceProxyClient getSpClient () { + return spClient; + } + + @Override + public boolean getAuthenticationRequired () { + return spClient.isAuthenticatingClient(); + } + + @Override + public String getCheckHistory () { + return ":pz2watch:stateForm:windowlocationhash"; + } + + @Override + public String getWatchActiveclients () { + return ":pz2watch:activeclientsForm:activeclientsField"; + } + + @Override + public String getWatchActiveclientsRecord () { + return ":pz2watch:activeclientsForm:activeclientsFieldRecord"; + } + + @Override + public void configure(ConfigurationReader reader) + throws ConfigurationException { + Configuration config = reader.getConfiguration(this); + if (config == null) { + serviceType = SERVICE_TYPE_TBD; + } else { + String service = config.get("TYPE"); + if (service == null || service.length()==0) { + serviceType = SERVICE_TYPE_TBD; + } else if (serviceTypes.contains(service.toUpperCase())) { + setServiceType(service.toUpperCase()); + } else { + logger.error("Unknown serviceType type in configuration [" + service + "], can be one of " + serviceTypes); + serviceType = SERVICE_TYPE_TBD; + } + serviceProxyUrls = config.getMultiProperty(SERVICE_PROXY_URL_LIST,","); + pazpar2Urls = config.getMultiProperty(PAZPAR2_URL_LIST, ","); + } + logger.info(reader.document()); + logger.info("Service Type is configured to " + serviceType); + + } + + @Override + public Map getDefaults() { + return new HashMap(); + } + + @Override + public String getModuleName() { + return MODULE_NAME; + } + + @Override + public List documentConfiguration() { + return new ArrayList(); + } + + @Override + public void setServiceTypePZ2() { + setServiceType(SERVICE_TYPE_PZ2); + } + + @Override + public void setServiceTypeSP() { + setServiceType(SERVICE_TYPE_SP); + } + + @Override + public void setServiceTypeTBD() { + setServiceType(SERVICE_TYPE_TBD); + } + + private void setServiceType(String type) { + if (!serviceType.equals(type) && + !serviceType.equals(SERVICE_TYPE_TBD)) { + resetSearchAndRecordCommands(); + pzresp.getSp().resetAuthAndBeyond(true); + } + serviceType = type; + if (serviceType.equals(SERVICE_TYPE_PZ2)) { + searchClient = pz2Client; + logger.info("Setting a Pazpar2 client to serve requests."); + } else if (serviceType.equals(SERVICE_TYPE_SP)) { + searchClient = spClient; + logger.info("Setting a Service Proxy client to serve requests."); + } else { + logger.info("Clearing search client. No client defined to serve requests at this point."); + searchClient = null; + } + } + + public SearchClient getSearchClient() { + return searchClient; + } + +} diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/ServiceProxyExtensions.java b/src/main/java/com/indexdata/mkjsf/pazpar2/ServiceProxyExtensions.java index 51ab55b..d11a55b 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/ServiceProxyExtensions.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/ServiceProxyExtensions.java @@ -35,7 +35,7 @@ public class ServiceProxyExtensions implements ServiceProxyInterface, Serializab } public String getInitDocPath () { - return Pz2Bean.get().getSpClient().getConfiguration().get("INIT_DOC_PATH"); + return Pz2Service.get().getSpClient().getConfiguration().get("INIT_DOC_PATH"); } @Override @@ -50,20 +50,20 @@ public class ServiceProxyExtensions implements ServiceProxyInterface, Serializab @Override public ClientCommandResponse postInit() throws UnsupportedEncodingException, IOException { - String initDocPath = Pz2Bean.get().getSpClient().getInitDocPaths().get(0); - logger.info("Paths: " + Pz2Bean.get().getSpClient().getInitDocPaths()); + String initDocPath = Pz2Service.get().getSpClient().getInitDocPaths().get(0); + logger.info("Paths: " + Pz2Service.get().getSpClient().getInitDocPaths()); logger.info("Path: " + initDocPath); - Pz2Bean.get().resetSearchAndRecordCommands(); - Pz2Bean.get().getPzresp().getSp().resetAuthAndBeyond(true); - ClientCommandResponse response = Pz2Bean.get().getSpClient().postInitDoc(initDocPath + getInitFileName()); + Pz2Service.get().resetSearchAndRecordCommands(); + Pz2Service.get().getPzresp().getSp().resetAuthAndBeyond(true); + ClientCommandResponse response = Pz2Service.get().getSpClient().postInitDoc(initDocPath + getInitFileName()); return response; } @Override public HttpResponseWrapper postInit(byte[] initDoc, boolean includeDebug) throws UnsupportedEncodingException, IOException { - Pz2Bean.get().resetSearchAndRecordCommands(); - Pz2Bean.get().getPzresp().getSp().resetAuthAndBeyond(true); - HttpResponseWrapper response = Pz2Bean.get().getSpClient().postInitDoc(initDoc,includeDebug); + Pz2Service.get().resetSearchAndRecordCommands(); + Pz2Service.get().getPzresp().getSp().resetAuthAndBeyond(true); + HttpResponseWrapper response = Pz2Service.get().getSpClient().postInitDoc(initDoc,includeDebug); return response; } @@ -83,7 +83,7 @@ public class ServiceProxyExtensions implements ServiceProxyInterface, Serializab public void submitInitDoc () throws IOException { ClientCommandResponse response = (ClientCommandResponse) initDocUpload.submit(); ResponseDataObject responseObject = ResponseParser.getParser().getDataObject(response); - Pz2Bean.get().getPzresp().put("init", responseObject); + Pz2Service.get().getPzresp().put("init", responseObject); } public void setIncludeInitDocDebug(boolean bool) { diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Command.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Command.java index fd74c37..c7bff40 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Command.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Command.java @@ -9,7 +9,7 @@ import org.apache.log4j.Logger; import com.indexdata.mkjsf.pazpar2.ClientCommandResponse; import com.indexdata.mkjsf.pazpar2.HttpResponseWrapper; -import com.indexdata.mkjsf.pazpar2.Pz2Bean; +import com.indexdata.mkjsf.pazpar2.Pz2Service; import com.indexdata.mkjsf.pazpar2.SearchClient; import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommand; import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject; @@ -41,8 +41,8 @@ public abstract class Pazpar2Command implements Serializable { } public ResponseDataObject run() { - return run(Pz2Bean.get().getSearchClient(), - Pz2Bean.get().getPzresp()); + return run(Pz2Service.get().getSearchClient(), + Pz2Service.get().getPzresp()); } public ResponseDataObject runWith(String... parameters) { @@ -187,7 +187,7 @@ public abstract class Pazpar2Command implements Serializable { } private void checkInState(Pazpar2Command command) { - Pz2Bean.get().getStateMgr().checkIn(command); + Pz2Service.get().getStateMgr().checkIn(command); } public String navigateTo (String target) { diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Commands.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Commands.java index 21f86ef..67213e3 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Commands.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Commands.java @@ -7,7 +7,7 @@ import javax.inject.Named; import org.apache.log4j.Logger; -import com.indexdata.mkjsf.pazpar2.Pz2Bean; +import com.indexdata.mkjsf.pazpar2.Pz2Service; import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommands; import com.indexdata.mkjsf.utils.Utils; @@ -32,54 +32,54 @@ public class Pazpar2Commands implements Serializable { logger.info("Initializing Pazpar2Commands [" + Utils.objectId(this) + "]"); } - // public void setService(Pz2Bean service) { + // public void setService(Pz2Service service) { // this.pz2 = service; // logger.info("Post construct Pazpar2Command: Service is " + pz2); // } public InitCommand getInit() { - return (InitCommand) (Pz2Bean.get().getStateMgr().getCommand(INIT)); + return (InitCommand) (Pz2Service.get().getStateMgr().getCommand(INIT)); } public PingCommand getPing() { - return (PingCommand) (Pz2Bean.get().getStateMgr().getCommand(PING)); + return (PingCommand) (Pz2Service.get().getStateMgr().getCommand(PING)); } public SettingsCommand getSettings() { - return (SettingsCommand) (Pz2Bean.get().getStateMgr().getCommand(SETTINGS)); + return (SettingsCommand) (Pz2Service.get().getStateMgr().getCommand(SETTINGS)); } public SearchCommand getSearch() { - return (SearchCommand) (Pz2Bean.get().getStateMgr().getCommand(SEARCH)); + return (SearchCommand) (Pz2Service.get().getStateMgr().getCommand(SEARCH)); } public StatCommand getStat() { - return (StatCommand) (Pz2Bean.get().getStateMgr().getCommand(STAT)); + return (StatCommand) (Pz2Service.get().getStateMgr().getCommand(STAT)); } public ShowCommand getShow() { - return (ShowCommand) (Pz2Bean.get().getStateMgr().getCommand(SHOW)); + return (ShowCommand) (Pz2Service.get().getStateMgr().getCommand(SHOW)); } public RecordCommand getRecord() { - return (RecordCommand) (Pz2Bean.get().getStateMgr().getCommand(RECORD)); + return (RecordCommand) (Pz2Service.get().getStateMgr().getCommand(RECORD)); } public TermlistCommand getTermlist() { - return (TermlistCommand) (Pz2Bean.get().getStateMgr().getCommand(TERMLIST)); + return (TermlistCommand) (Pz2Service.get().getStateMgr().getCommand(TERMLIST)); } public BytargetCommand getBytarget() { - return (BytargetCommand) (Pz2Bean.get().getStateMgr().getCommand(BYTARGET)); + return (BytargetCommand) (Pz2Service.get().getStateMgr().getCommand(BYTARGET)); } public Pazpar2Command getCommand(String name) { - return Pz2Bean.get().getStateMgr().getCommand(name); + return Pz2Service.get().getStateMgr().getCommand(name); } public ServiceProxyCommands getSp() { if (sp == null) { - sp = new ServiceProxyCommands(Pz2Bean.get().getStateMgr()); + sp = new ServiceProxyCommands(Pz2Service.get().getStateMgr()); } return sp; } diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/RecordCommand.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/RecordCommand.java index 50e33d1..c163aba 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/RecordCommand.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/RecordCommand.java @@ -4,7 +4,7 @@ import org.apache.log4j.Logger; import com.indexdata.mkjsf.pazpar2.ClientCommandResponse; import com.indexdata.mkjsf.pazpar2.HttpResponseWrapper; -import com.indexdata.mkjsf.pazpar2.Pz2Bean; +import com.indexdata.mkjsf.pazpar2.Pz2Service; import com.indexdata.mkjsf.pazpar2.commands.sp.RecordCommandSp; import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommand; import com.indexdata.mkjsf.pazpar2.data.RecordResponse; @@ -24,7 +24,7 @@ public class RecordCommand extends Pazpar2Command implements ServiceProxyCommand public ResponseDataObject run() { ResponseDataObject responseObject = null; if (hasParameterValue("id")) { - HttpResponseWrapper commandResponse = Pz2Bean.get().getSearchClient().executeCommand(this); + HttpResponseWrapper commandResponse = Pz2Service.get().getSearchClient().executeCommand(this); if (commandResponse.getContentType().contains("xml")) { responseObject = ResponseParser.getParser().getDataObject((ClientCommandResponse)commandResponse); @@ -48,10 +48,10 @@ public class RecordCommand extends Pazpar2Command implements ServiceProxyCommand } else { logger.error("Response was not found to be XML or binary. The response was not handled."); } - Pz2Bean.get().getPzresp().put(getCommandName(), responseObject); + Pz2Service.get().getPzresp().put(getCommandName(), responseObject); } else { logger.debug("No record id parameter on this command. Ignoring request but clearing any previous record result."); - Pz2Bean.get().getPzresp().put(getCommandName(), new RecordResponse()); + Pz2Service.get().getPzresp().put(getCommandName(), new RecordResponse()); } return responseObject; } diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java index a95ac09..f2eb3be 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java @@ -5,7 +5,7 @@ import javax.inject.Named; import org.apache.log4j.Logger; -import com.indexdata.mkjsf.pazpar2.Pz2Bean; +import com.indexdata.mkjsf.pazpar2.Pz2Service; import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommand; import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject; @@ -22,11 +22,11 @@ public class SearchCommand extends Pazpar2Command implements ServiceProxyCommand public ResponseDataObject run() { logger.info("Running " + getCommandName()); - Pz2Bean.get().getStateMgr().hasPendingStateChange("search",false); - Pz2Bean.get().getPzresp().resetSearchAndBeyond(); - Pz2Bean.get().getPzreq().getRecord().removeParametersInState(); - Pz2Bean.get().getPzreq().getShow().setParameterInState(new CommandParameter("start","=",0)); - Pz2Bean.get().getSearchClient().setSearchCommand(this); + Pz2Service.get().getStateMgr().hasPendingStateChange("search",false); + Pz2Service.get().getPzresp().resetSearchAndBeyond(); + Pz2Service.get().getPzreq().getRecord().removeParametersInState(); + Pz2Service.get().getPzreq().getShow().setParameterInState(new CommandParameter("start","=",0)); + Pz2Service.get().getSearchClient().setSearchCommand(this); return super.run(); } diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/AuthCommand.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/AuthCommand.java index 723bc6a..5013271 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/AuthCommand.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/AuthCommand.java @@ -3,7 +3,7 @@ package com.indexdata.mkjsf.pazpar2.commands.sp; import org.apache.log4j.Logger; import com.indexdata.mkjsf.pazpar2.ClientCommandResponse; -import com.indexdata.mkjsf.pazpar2.Pz2Bean; +import com.indexdata.mkjsf.pazpar2.Pz2Service; import com.indexdata.mkjsf.pazpar2.commands.CommandParameter; import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command; import com.indexdata.mkjsf.pazpar2.data.ResponseParser; @@ -19,14 +19,14 @@ public class AuthCommand extends Pazpar2Command implements ServiceProxyCommand { } public SpResponseDataObject run() { - Pz2Bean.get().resetSearchAndRecordCommands(); - Pz2Bean.get().getPzresp().getSp().resetAuthAndBeyond(true); - ClientCommandResponse response = (ClientCommandResponse) Pz2Bean.get().getSearchClient().executeCommand(this); + Pz2Service.get().resetSearchAndRecordCommands(); + Pz2Service.get().getPzresp().getSp().resetAuthAndBeyond(true); + ClientCommandResponse response = (ClientCommandResponse) Pz2Service.get().getSearchClient().executeCommand(this); String renamedResponse = renameResponseElement(response.getResponseString(), "auth"); response.setResponseToParse(renamedResponse); SpResponseDataObject responseObject = (SpResponseDataObject) ResponseParser.getParser().getDataObject(response); if (ResponseParser.docTypes.contains(responseObject.getType())) { - Pz2Bean.get().getPzresp().put(getCommandName(), responseObject); + Pz2Service.get().getPzresp().put(getCommandName(), responseObject); } if (responseObject.unsupportedCommand()) { logger.error("auth command does not seem to be supported by this Service Proxy"); diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/CategoriesCommand.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/CategoriesCommand.java index 989c21a..bccd65c 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/CategoriesCommand.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/CategoriesCommand.java @@ -2,7 +2,7 @@ package com.indexdata.mkjsf.pazpar2.commands.sp; import org.apache.log4j.Logger; -import com.indexdata.mkjsf.pazpar2.Pz2Bean; +import com.indexdata.mkjsf.pazpar2.Pz2Service; import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command; import com.indexdata.mkjsf.pazpar2.data.sp.CategoriesResponse; @@ -17,11 +17,11 @@ public class CategoriesCommand extends Pazpar2Command implements ServiceProxyCom @Override public CategoriesResponse run () { - if (Pz2Bean.get().getPzresp().getSp().getCategories().unsupportedCommand()) { + if (Pz2Service.get().getPzresp().getSp().getCategories().unsupportedCommand()) { logger.info("Skipping seemingly unsupported categories command"); return new CategoriesResponse(); } else { - if (Pz2Bean.get().isServiceProxyService()) { + if (Pz2Service.get().isServiceProxyService()) { try { CategoriesResponse response = (CategoriesResponse) super.run(); if (response.unsupportedCommand()) { diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/state/StateManager.java b/src/main/java/com/indexdata/mkjsf/pazpar2/state/StateManager.java index 7c6ac91..7616f1e 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/state/StateManager.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/state/StateManager.java @@ -89,7 +89,7 @@ public class StateManager implements Serializable { * @See The state field in pz2watch.xhtml
* The state listeners windowlocationhashListener() and StateListener() * in listeners.js
- * The method {@link com.indexdata.mkjsf.pazpar2.Pz2Bean#handleQueryStateChanges}
+ * The method {@link com.indexdata.mkjsf.pazpar2.Pz2Service#handleQueryStateChanges}
* The class {@link com.indexdata.mkjsf.pazpar2.state.Pazpar2State}
* ... for a complete picture of browser history handling. * -- 1.7.10.4