From aeccbd85eff3e6da817fadc3566b7a9ac944fe63 Mon Sep 17 00:00:00 2001 From: "Niels Erik G. Nielsen" Date: Sun, 14 Apr 2013 09:42:17 -0400 Subject: [PATCH] Renames pz2 requests,responses to pzreq,pzresp throughout --- .../indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java | 53 ++++++++++---------- .../pz2utils4jsf/pazpar2/Pz2ProxyBean.java | 14 +++--- .../pazpar2/commands/Pazpar2Commands.java | 2 +- .../pazpar2/data/Pazpar2Responses.java | 2 +- 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java index 9864e06..ad684b3 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java @@ -20,6 +20,7 @@ import com.indexdata.pz2utils4jsf.errors.ConfigurationException; import com.indexdata.pz2utils4jsf.errors.ErrorHelper; import com.indexdata.pz2utils4jsf.errors.ErrorInterface; import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandParameter; +import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandReadOnly; import com.indexdata.pz2utils4jsf.pazpar2.commands.Pazpar2Commands; import com.indexdata.pz2utils4jsf.pazpar2.data.Pazpar2ResponseData; import com.indexdata.pz2utils4jsf.pazpar2.data.Pazpar2ResponseParser; @@ -39,8 +40,8 @@ public class Pz2Bean implements Pz2Interface, StateListener, Serializable { @Inject ConfigurationReader configurator; @Inject StateManager stateMgr; - @Inject Pazpar2Commands req; - @Inject Pazpar2Responses data; + @Inject Pazpar2Commands pzreq; + @Inject Pazpar2Responses pzresp; protected ResultsPager pager = null; @@ -82,22 +83,22 @@ public class Pz2Bean implements Pz2Interface, StateListener, Serializable { configurationErrors.add(new ConfigurationError("Search Client","Configuration",e.getMessage(),new ErrorHelper(configReader))); } logger.info(configReader.document()); - data.reset(); + pzresp.reset(); } public void doSearch(String query) { - req.getSearch().setParameter(new CommandParameter("query","=",query)); + pzreq.getSearch().setParameter(new CommandParameter("query","=",query)); doSearch(); } public void doSearch() { stateMgr.hasPendingStateChange("search",false); - data.reset(); + pzresp.reset(); // TODO: avoid state proliferation here: - req.getRecord().removeParameters(); - req.getShow().setParameter(new CommandParameter("start","=",0)); - logger.debug(Utils.objectId(this) + " is searching using "+req.getCommandReadOnly("search").getUrlEncodedParameterValue("query")); + pzreq.getRecord().removeParameters(); + pzreq.getShow().setParameter(new CommandParameter("start","=",0)); + logger.debug(Utils.objectId(this) + " is searching using "+pzreq.getCommandReadOnly("search").getUrlEncodedParameterValue("query")); doCommand("search"); } @@ -125,7 +126,7 @@ public class Pz2Bean implements Pz2Interface, StateListener, Serializable { List threadList = new ArrayList(); StringTokenizer tokens = new StringTokenizer(commands,","); while (tokens.hasMoreElements()) { - threadList.add(new CommandThread(req.getCommandReadOnly(tokens.nextToken()),searchClient)); + threadList.add(new CommandThread(pzreq.getCommandReadOnly(tokens.nextToken()),searchClient)); } for (CommandThread thread : threadList) { thread.start(); @@ -142,17 +143,17 @@ public class Pz2Bean implements Pz2Interface, StateListener, Serializable { String response = thread.getResponse(); logger.debug("Response was: " + response); Pazpar2ResponseData responseObject = Pazpar2ResponseParser.getParser().getDataObject(response); - data.put(commandName, responseObject); + pzresp.put(commandName, responseObject); } if (commands.equals("record")) { - logger.debug("Record: Active clients: "+data.getRecord().getActiveClients()); - return data.getRecord().getActiveClients(); + logger.debug("Record: Active clients: "+pzresp.getRecord().getActiveClients()); + return pzresp.getRecord().getActiveClients(); } else { - return data.getActiveClients(); + return pzresp.getActiveClients(); } } else { logger.debug("Skipped requests for " + commands + " as there's not yet a query."); - data.reset(); + pzresp.reset(); return "0"; } } else { @@ -164,18 +165,18 @@ public class Pz2Bean implements Pz2Interface, StateListener, Serializable { public String toggleRecord (String recId) { if (hasRecord(recId)) { - req.getRecord().removeParameters(); - data.put("record", new RecordResponse()); + pzreq.getRecord().removeParameters(); + pzresp.put("record", new RecordResponse()); return ""; } else { - req.getRecord().setRecordId(recId); + pzreq.getRecord().setRecordId(recId); return doCommand("record"); } } @Override public boolean hasRecord (String recId) { - return req.getCommandReadOnly("record").hasParameters() && data.getRecord().getRecId().equals(recId); + return pzreq.getCommandReadOnly("record").hasParameters() && pzresp.getRecord().getRecId().equals(recId); } public String getCurrentStateKey () { @@ -191,7 +192,7 @@ public class Pz2Bean implements Pz2Interface, StateListener, Serializable { } public boolean hasCommandErrors () { - return data.hasApplicationError(); + return pzresp.hasApplicationError(); } /** @@ -206,20 +207,20 @@ public class Pz2Bean implements Pz2Interface, StateListener, Serializable { } - protected boolean hasQuery() { - return req.getSearch().getParameter("query") != null && req.getSearch().getParameter("query").getValueWithExpressions().length()>0; + protected boolean hasQuery() { + return pzreq.getCommandReadOnly("search").hasParameterSet("query"); } public ResultsPager getPager () { if (pager == null) { - pager = new ResultsPager(data); + pager = new ResultsPager(pzresp); } return pager; } public ResultsPager setPager (int pageRange) { - pager = new ResultsPager(data,pageRange,req); + pager = new ResultsPager(pzresp,pageRange,pzreq); return pager; } @@ -235,16 +236,16 @@ public class Pz2Bean implements Pz2Interface, StateListener, Serializable { if (stateMgr.hasPendingStateChange("record") && ! commands.equals("record")) { logger.debug("Found pending record ID change. Doing record before updating " + commands); stateMgr.hasPendingStateChange("record",false); - if (req.getCommandReadOnly("record").hasParameters()) { + if (pzreq.getCommandReadOnly("record").hasParameters()) { update("record"); } else { - data.put("record", new RecordResponse()); + pzresp.put("record", new RecordResponse()); } } } protected String doCommand(String commandName) { - logger.debug(req.getCommandReadOnly(commandName).getEncodedQueryString() + ": Results for "+ req.getCommandReadOnly("search").getEncodedQueryString()); + logger.debug(pzreq.getCommandReadOnly(commandName).getEncodedQueryString() + ": Results for "+ pzreq.getCommandReadOnly("search").getEncodedQueryString()); return update(commandName); } diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2ProxyBean.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2ProxyBean.java index b585485..773f993 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2ProxyBean.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2ProxyBean.java @@ -50,9 +50,9 @@ public class Pz2ProxyBean extends Pz2Bean implements ServiceProxyInterface { public String login(String navigateTo) { logger.info("doing login"); ((ServiceProxyClient)searchClient).authenticate(user); - data.reset(); - req.getRecord().removeParameters(); - req.getSearch().setQuery(null); + pzresp.reset(); + pzreq.getRecord().removeParameters(); + pzreq.getSearch().setQuery(null); return navigateTo; } @@ -61,8 +61,8 @@ public class Pz2ProxyBean extends Pz2Bean implements ServiceProxyInterface { public void setServiceProxyUrl(String url) { logger.info("Setting Service Proxy url: " + url); serviceProxyUrl = url; - req.getSearch().setQuery(null); - data.reset(); + pzreq.getSearch().setQuery(null); + pzresp.reset(); } public String getServiceProxyUrl() { @@ -89,7 +89,7 @@ public class Pz2ProxyBean extends Pz2Bean implements ServiceProxyInterface { String initDocPath = ((ServiceProxyClient)searchClient).getInitDocPaths()[0]; logger.info("Paths: " + ((ServiceProxyClient)searchClient).getInitDocPaths()); logger.info("Path: " + initDocPath); - data.reset(); + pzresp.reset(); byte[] response = ((ServiceProxyClient)searchClient).postInitDoc(initDocPath + getInitFileName()); initDocResponse = new String(response,"UTF-8"); return initDocResponse; @@ -97,7 +97,7 @@ public class Pz2ProxyBean extends Pz2Bean implements ServiceProxyInterface { @Override public String postInit(byte[] initDoc) throws UnsupportedEncodingException, IOException { - data.reset(); + pzresp.reset(); byte[] response = ((ServiceProxyClient)searchClient).postInitDoc(initDoc); initDocResponse = new String(response,"UTF-8"); return initDocResponse; 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 e6ecec4..f1ed7f6 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/Pazpar2Commands.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/Pazpar2Commands.java @@ -12,7 +12,7 @@ import org.apache.log4j.Logger; import com.indexdata.pz2utils4jsf.pazpar2.state.StateManager; import com.indexdata.pz2utils4jsf.utils.Utils; -@Named("req") @SessionScoped +@Named("pzreq") @SessionScoped public class Pazpar2Commands implements Serializable { private static final long serialVersionUID = -5172466320351302413L; diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/data/Pazpar2Responses.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/data/Pazpar2Responses.java index 25b7670..4f0daa1 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/data/Pazpar2Responses.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/data/Pazpar2Responses.java @@ -12,7 +12,7 @@ import org.apache.log4j.Logger; import com.indexdata.pz2utils4jsf.errors.ErrorInterface; -@Named("data") @SessionScoped +@Named("pzresp") @SessionScoped public class Pazpar2Responses implements Serializable { private static final long serialVersionUID = -7543231258346154642L; -- 1.7.10.4