From 5ab009ec3c4c7c75a52fcbd10dc712bcb50437f7 Mon Sep 17 00:00:00 2001 From: "Niels Erik G. Nielsen" Date: Sun, 14 Apr 2013 19:55:47 -0400 Subject: [PATCH] Fixes resetting of commands on login (SP) .. enables resetting of commands without state changing --- .../pz2utils4jsf/pazpar2/Pz2ProxyBean.java | 10 +++++----- .../pazpar2/commands/Pazpar2Commands.java | 21 +++++++++++++++++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2ProxyBean.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2ProxyBean.java index 773f993..f37f98e 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2ProxyBean.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2ProxyBean.java @@ -12,6 +12,7 @@ import javax.inject.Named; import org.apache.log4j.Logger; import com.indexdata.pz2utils4jsf.config.ConfigurationReader; +import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandParameter; import com.indexdata.pz2utils4jsf.pazpar2.sp.ServiceProxyClient; import com.indexdata.pz2utils4jsf.pazpar2.sp.ServiceProxyInterface; import com.indexdata.pz2utils4jsf.pazpar2.sp.auth.ServiceProxyUser; @@ -49,11 +50,10 @@ public class Pz2ProxyBean extends Pz2Bean implements ServiceProxyInterface { @Override public String login(String navigateTo) { logger.info("doing login"); - ((ServiceProxyClient)searchClient).authenticate(user); + ((ServiceProxyClient)searchClient).authenticate(user); + pzreq.getRecordInState().removeParametersSilently(); + pzreq.getSearchInState().removeParametersSilently(); pzresp.reset(); - pzreq.getRecord().removeParameters(); - pzreq.getSearch().setQuery(null); - return navigateTo; } @@ -61,7 +61,7 @@ public class Pz2ProxyBean extends Pz2Bean implements ServiceProxyInterface { public void setServiceProxyUrl(String url) { logger.info("Setting Service Proxy url: " + url); serviceProxyUrl = url; - pzreq.getSearch().setQuery(null); + pzreq.getSearchInState().removeParametersSilently(); pzresp.reset(); } diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/Pazpar2Commands.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/Pazpar2Commands.java index b91b0c6..4795905 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/Pazpar2Commands.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/Pazpar2Commands.java @@ -54,6 +54,15 @@ public class Pazpar2Commands implements Serializable { public SearchCommand getSearch() { return (SearchCommand) (stateMgr.checkOut(SEARCH)); } + + /** + * Gets a mutable SearchCommand from current state (no checkout) + * Can be used for updating Search parameters without spawning new state. + * @return + */ + public SearchCommand getSearchInState() { + return (SearchCommand) (stateMgr.getCurrentState().getCommand(SEARCH)); + } public StatCommand getStat() { return (StatCommand) (stateMgr.checkOut(STAT)); @@ -63,6 +72,11 @@ public class Pazpar2Commands implements Serializable { return (ShowCommand) (stateMgr.checkOut(SHOW)); } + /** + * Gets a mutable ShowCommand from current state (no checkout) + * Can be used for updating show parameters without spawning new state. + * @return + */ public ShowCommand getShowInState () { return (ShowCommand) (stateMgr.getCurrentState().getCommand(SHOW)); } @@ -70,7 +84,12 @@ public class Pazpar2Commands implements Serializable { public RecordCommand getRecord() { return (RecordCommand) (stateMgr.checkOut(RECORD)); } - + + /** + * Gets a mutable RecordCommand from current state (no checkout) + * Can be used for updating record parameters without spawning new state. + * @return + */ public RecordCommand getRecordInState() { return (RecordCommand)stateMgr.getCurrentState().getCommand(RECORD); } -- 1.7.10.4