From 437baaa9cfedf7b5abe9dd66b15a531949121136 Mon Sep 17 00:00:00 2001 From: "Niels Erik G. Nielsen" Date: Sat, 13 Apr 2013 13:18:09 -0400 Subject: [PATCH] Creates read-only command for optimization When a class retrieves a command, it's 'checked out' from the state manager, meaning that it is cloned as to not mutate the current state in case the command has it's parameters modified. Oftentimes cloning is obsolete however - when the client only wants to read the values - ie. for log statements or for actual execution. --- .../pz2utils4jsf/pazpar2/CommandThread.java | 8 +- .../indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java | 9 +-- .../indexdata/pz2utils4jsf/pazpar2/Pz2Client.java | 6 +- .../pz2utils4jsf/pazpar2/Pz2Interface.java | 5 +- .../pz2utils4jsf/pazpar2/Pz2ProxyBean.java | 5 +- .../indexdata/pz2utils4jsf/pazpar2/Pz2Session.java | 80 +++++++++++--------- .../pz2utils4jsf/pazpar2/SearchClient.java | 6 +- .../pazpar2/commands/CommandReadOnly.java | 21 +++++ .../pazpar2/commands/Pazpar2Command.java | 15 +++- .../pazpar2/commands/Pazpar2Commands.java | 4 + .../pazpar2/commands/SearchCommand.java | 6 +- .../pazpar2/sp/ServiceProxyClient.java | 7 +- .../pz2utils4jsf/pazpar2/state/StateManager.java | 7 +- 13 files changed, 113 insertions(+), 66 deletions(-) create mode 100644 src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/CommandReadOnly.java diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/CommandThread.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/CommandThread.java index 323ef78..72a4337 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/CommandThread.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/CommandThread.java @@ -6,18 +6,18 @@ import java.io.IOException; import org.apache.log4j.Logger; import com.indexdata.masterkey.pazpar2.client.exceptions.Pazpar2ErrorException; -import com.indexdata.pz2utils4jsf.pazpar2.commands.Pazpar2Command; +import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandReadOnly; import com.indexdata.pz2utils4jsf.pazpar2.data.CommandError; public class CommandThread extends Thread { private static Logger logger = Logger.getLogger(CommandThread.class); - Pazpar2Command command; + CommandReadOnly command; SearchClient client; private ByteArrayOutputStream baos = new ByteArrayOutputStream(); private StringBuilder response = new StringBuilder(""); - public CommandThread (Pazpar2Command command, SearchClient client) { + public CommandThread (CommandReadOnly command, SearchClient client) { this.command = command; this.client = client; } @@ -72,7 +72,7 @@ public class CommandThread extends Thread { return response.toString(); } - public Pazpar2Command getCommand() { + public CommandReadOnly getCommand() { return command; } diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java index 5838626..82f71ed 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java @@ -14,7 +14,6 @@ import org.apache.log4j.Logger; import com.indexdata.pz2utils4jsf.config.ConfigurationReader; import com.indexdata.pz2utils4jsf.controls.ResultsPager; import com.indexdata.pz2utils4jsf.errors.ErrorInterface; -import com.indexdata.pz2utils4jsf.pazpar2.commands.Pazpar2Command; import com.indexdata.pz2utils4jsf.pazpar2.data.ByTarget; import com.indexdata.pz2utils4jsf.pazpar2.data.RecordResponse; import com.indexdata.pz2utils4jsf.pazpar2.data.ShowResponse; @@ -61,7 +60,7 @@ public class Pz2Bean implements Pz2Interface, Serializable { * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#doSearch() */ public void doSearch() { - logger.info(Utils.objectId(this) + " doing search for "+this.getQuery()); + logger.info(Utils.objectId(this) + " doing search for "+pz2.getCommandReadOnly("search").getParameterValue("query")); pz2.doSearch(); } @@ -89,9 +88,11 @@ public class Pz2Bean implements Pz2Interface, Serializable { /* (non-Javadoc) * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getQuery() */ + /* public String getQuery() { return pz2.getQuery(); } + */ /* (non-Javadoc) * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#setFacet(java.lang.String, java.lang.String) @@ -324,8 +325,4 @@ public class Pz2Bean implements Pz2Interface, Serializable { return pz2.getRecordId(); } - public Pazpar2Command getSearchCommand () { - return pz2.getCommand("search"); - } - } diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Client.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Client.java index affd08d..058a3e1 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Client.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Client.java @@ -26,7 +26,7 @@ import com.indexdata.masterkey.pazpar2.client.exceptions.ProxyErrorException; import com.indexdata.pz2utils4jsf.config.Configuration; import com.indexdata.pz2utils4jsf.config.ConfigurationReader; import com.indexdata.pz2utils4jsf.errors.ConfigurationException; -import com.indexdata.pz2utils4jsf.pazpar2.commands.Pazpar2Command; +import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandReadOnly; import com.indexdata.pz2utils4jsf.utils.Utils; @Named @SessionScoped @@ -85,13 +85,13 @@ public class Pz2Client implements SearchClient { } @Override - public void setSearchCommand(Pazpar2Command command) { + public void setSearchCommand(CommandReadOnly command) { ClientCommand clientCommand = new ClientCommand(command.getName(), command.getEncodedQueryString()); client.setSearchCommand(clientCommand); } @Override - public CommandResponse executeCommand(Pazpar2Command command, ByteArrayOutputStream baos) + public CommandResponse executeCommand(CommandReadOnly command, ByteArrayOutputStream baos) throws Pazpar2ErrorException, IOException { ClientCommand clientCommand = new ClientCommand(command.getName(), command.getEncodedQueryString()); Pazpar2HttpResponse pz2HttpResponse = client.executeCommand(clientCommand, baos); diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Interface.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Interface.java index 8a59cfe..789a0a4 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Interface.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Interface.java @@ -57,13 +57,14 @@ public interface Pz2Interface extends Serializable { * @param query a query on pazpar2 query syntax * */ - public void setQuery (String query); + //public void setQuery (String query); + /** * Gets the current query * @return a pazpar2 query string */ - public String getQuery (); + //public String getQuery (); /** * Sets a facet to limit the current query by, diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2ProxyBean.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2ProxyBean.java index ae742f3..15821ea 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2ProxyBean.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2ProxyBean.java @@ -13,6 +13,7 @@ import org.apache.log4j.Logger; import com.indexdata.pz2utils4jsf.config.Configuration; import com.indexdata.pz2utils4jsf.config.ConfigurationReader; +import com.indexdata.pz2utils4jsf.pazpar2.commands.SearchCommand; import com.indexdata.pz2utils4jsf.pazpar2.sp.ForServiceProxy; import com.indexdata.pz2utils4jsf.pazpar2.sp.ServiceProxyClient; import com.indexdata.pz2utils4jsf.pazpar2.sp.ServiceProxyInterface; @@ -49,7 +50,7 @@ public class Pz2ProxyBean extends Pz2Bean implements ServiceProxyInterface { session().setUser(user); session().resetDataObjects(); session().removeCommand("record"); - session().setQuery(null); + ((SearchCommand)session().getCommand("search")).setQuery(null); return session().login(navigateTo); } @@ -90,7 +91,7 @@ public class Pz2ProxyBean extends Pz2Bean implements ServiceProxyInterface { public void setServiceProxyUrl(String url) { logger.info("Setting Service Proxy url: " + url); session().setServiceProxyUrl(url); - session().setQuery(null); + ((SearchCommand)session().getCommand("search")).setQuery(null); session().resetDataObjects(); } diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Session.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Session.java index cdb1a6b..fba8a20 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Session.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Session.java @@ -7,7 +7,6 @@ import java.util.StringTokenizer; import java.util.concurrent.ConcurrentHashMap; import javax.annotation.PostConstruct; -import javax.enterprise.context.SessionScoped; import javax.inject.Inject; import org.apache.log4j.Logger; @@ -19,8 +18,10 @@ 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.Pazpar2Command; import com.indexdata.pz2utils4jsf.pazpar2.commands.Pazpar2Commands; +import com.indexdata.pz2utils4jsf.pazpar2.commands.SearchCommand; import com.indexdata.pz2utils4jsf.pazpar2.data.ByTarget; import com.indexdata.pz2utils4jsf.pazpar2.data.CommandError; import com.indexdata.pz2utils4jsf.pazpar2.data.Pazpar2ResponseData; @@ -95,7 +96,7 @@ public class Pz2Session implements Pz2Interface, StateListener { resetDataObjects(); removeCommand("record"); setCommandParameter("show",new CommandParameter("start","=",0)); - logger.debug(Utils.objectId(this) + " is searching using "+getCommand("search").getParameter("query").getEncodedQueryString()); + logger.debug(Utils.objectId(this) + " is searching using "+req.getCommandReadOnly("search").getUrlEncodedParameterValue("query")); doCommand("search"); } @@ -123,7 +124,7 @@ public class Pz2Session implements Pz2Interface, StateListener { List threadList = new ArrayList(); StringTokenizer tokens = new StringTokenizer(commands,","); while (tokens.hasMoreElements()) { - threadList.add(new CommandThread(getCommand(tokens.nextToken()),searchClient)); + threadList.add(new CommandThread(req.getCommandReadOnly(tokens.nextToken()),searchClient)); } for (CommandThread thread : threadList) { thread.start(); @@ -160,6 +161,7 @@ public class Pz2Session implements Pz2Interface, StateListener { } + /* public void setQuery (String query) { logger.debug("Creating new command parameter for " + query); setCommandParameter("search",new CommandParameter("query","=",query)); @@ -168,10 +170,11 @@ public class Pz2Session implements Pz2Interface, StateListener { public String getQuery () { return getCommandParameterValueSimple("search","query",null); } + */ public void setFacet (String facetKey, String term) { if (term != null && term.length()>0) { - Pazpar2Command command = getCommand("search"); + Pazpar2Command command = req.getCommand("search"); command.getParameter("query").addExpression(new Expression(facetKey,"=",term)); stateMgr.checkIn(command); doSearch(); @@ -181,13 +184,14 @@ public class Pz2Session implements Pz2Interface, StateListener { public void setFacetOnQuery (String facetKey, String term) { String facetExpression = facetKey + "=" + term; if (term != null && term.length()>0) { - setCommandParameter("search",new CommandParameter("query","=", getQuery() + " and " + facetExpression)); + String currentQuery= req.getCommandReadOnly("search").getParameterValue("query"); + setCommandParameter("search",new CommandParameter("query","=", currentQuery + " and " + facetExpression)); doSearch(); } } public void removeFacet(String facetKey, String term) { - Pazpar2Command command = getCommand("search"); + SearchCommand command = req.getSearch(); command.getParameter("query").removeExpression(new Expression(facetKey,"=",term)); stateMgr.checkIn(command); doSearch(); @@ -276,7 +280,7 @@ public class Pz2Session implements Pz2Interface, StateListener { @Override public boolean hasRecord (String recId) { - return getCommand("record").hasParameters() && getRecord().getRecId().equals(recId); + return req.getCommandReadOnly("record").hasParameters() && getRecord().getRecId().equals(recId); } public ShowResponse getShow () { @@ -371,8 +375,7 @@ public class Pz2Session implements Pz2Interface, StateListener { return hasSingleTargetFilter() && targetFilter.equals(this.singleTargetFilter); } - protected boolean hasQuery() { - logger.debug("req is " + req); + protected boolean hasQuery() { return req.getSearch().getParameter("query") != null && req.getSearch().getParameter("query").getValueWithExpressions().length()>0; } @@ -406,7 +409,7 @@ public class Pz2Session implements Pz2Interface, StateListener { if (stateMgr.hasPendingStateChange("record") && ! commands.equals("record")) { logger.debug("Found pending record ID change. Doing record before updating " + commands); stateMgr.hasPendingStateChange("record",false); - if (getCommand("record").hasParameters()) { + if (req.getCommandReadOnly("record").hasParameters()) { update("record"); } else { removeCommand("record"); @@ -439,66 +442,69 @@ public class Pz2Session implements Pz2Interface, StateListener { * @return */ protected Pazpar2Command getCommand(String name) { - return stateMgr.checkOut(name); + return req.getCommand(name); } + /** + * Returns an interface to a Pazpar2Command with only String getters. + * + * Since the command cannot be modified (unless it is cast) we can avoid + * cloning it before returning it from the current state. + * It can be used for log statements, checks and for performing the + * actual pazpar2 request. + * + * @param name + * @return + */ + protected CommandReadOnly getCommandReadOnly(String name) { + return req.getCommandReadOnly(name); + } + + protected void setCommandParameter(String commandName, CommandParameter parameter) { logger.debug("Setting parameter for " + commandName + ": " + parameter); - Pazpar2Command command = getCommand(commandName); + Pazpar2Command command = req.getCommand(commandName); command.setParameter(parameter); stateMgr.checkIn(command); } protected void removeCommandParameter(String commandName, String parameterName) { - Pazpar2Command command = getCommand(commandName); + Pazpar2Command command = req.getCommand(commandName); command.removeParameter(parameterName); stateMgr.checkIn(command); } protected void removeCommand (String commandName) { - Pazpar2Command command = getCommand(commandName); + Pazpar2Command command = req.getCommand(commandName); command.removeParameters(); stateMgr.checkIn(command); } protected String getCommandParameterValue (String commandName, String parameterName, String defaultValue) { - Pazpar2Command command = getCommand(commandName); - if (command != null) { - CommandParameter parameter = command.getParameter(parameterName); - if (parameter != null) { - return parameter.getValueWithExpressions(); - } - } - return defaultValue; - } - - protected String getCommandParameterValueSimple (String commandName, String parameterName, String defaultValue) { - Pazpar2Command command = getCommand(commandName); + CommandReadOnly command = req.getCommandReadOnly(commandName); if (command != null) { - CommandParameter parameter = command.getParameter(parameterName); + String parameter = command.getParameterValue(parameterName); if (parameter != null) { - return parameter.getSimpleValue(); + return parameter; } } return defaultValue; } - - + protected int getCommandParameterValue (String commandName, String parameterName, int defaultValue) { - Pazpar2Command command = getCommand(commandName); + CommandReadOnly command = req.getCommandReadOnly(commandName); if (command != null) { - CommandParameter parameter = command.getParameter(parameterName); + String parameter = command.getParameterValue(parameterName); if (parameter != null) { - return Integer.parseInt(parameter.getSimpleValue()); + return Integer.parseInt(parameter); } } return defaultValue; } - protected String doCommand(String commandName) { - Pazpar2Command command = req.getCommand(commandName); - logger.debug(command.getEncodedQueryString() + ": Results for "+ getCommand("search").getEncodedQueryString()); + protected String doCommand(String commandName) { + logger.debug(req.getCommandReadOnly(commandName).getEncodedQueryString() + ": Results for "+ req.getCommandReadOnly("search").getEncodedQueryString()); return update(commandName); } @@ -520,7 +526,7 @@ public class Pz2Session implements Pz2Interface, StateListener { } public String getFilter() { - return getCommandParameterValueSimple("search", "filter", ""); + return getCommandParameterValue("search", "filter", ""); } public boolean hasFilter () { diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/SearchClient.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/SearchClient.java index c7d0cf9..acce660 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/SearchClient.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/SearchClient.java @@ -7,12 +7,12 @@ import java.io.Serializable; import com.indexdata.masterkey.pazpar2.client.exceptions.Pazpar2ErrorException; import com.indexdata.pz2utils4jsf.config.Configurable; import com.indexdata.pz2utils4jsf.config.Configuration; -import com.indexdata.pz2utils4jsf.pazpar2.commands.Pazpar2Command; +import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandReadOnly; public interface SearchClient extends Configurable, Serializable { - public void setSearchCommand(Pazpar2Command command); - public CommandResponse executeCommand(Pazpar2Command command, ByteArrayOutputStream baos) throws Pazpar2ErrorException, IOException; + public void setSearchCommand(CommandReadOnly command); + public CommandResponse executeCommand(CommandReadOnly command, ByteArrayOutputStream baos) throws Pazpar2ErrorException, IOException; public SearchClient cloneMe(); public boolean isAuthenticatingClient(); public Configuration getConfiguration(); diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/CommandReadOnly.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/CommandReadOnly.java new file mode 100644 index 0000000..68f334b --- /dev/null +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/CommandReadOnly.java @@ -0,0 +1,21 @@ +package com.indexdata.pz2utils4jsf.pazpar2.commands; + +/** + * Interface to Pazpar2Command to be used when the given command + * should not change. Meant to avoid redundant cloning of commands + * for potential state changes. + * + * @author Niels Erik + * + */ +public interface CommandReadOnly { + + public String getName(); + public String getValueWithExpressions(); + public String getEncodedQueryString(); + public boolean hasParameters(); + public boolean hasParameterSet(String parameterName); + public String getParameterValue(String parameterName); + public String getUrlEncodedParameterValue(String parameterName); + +} diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/Pazpar2Command.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/Pazpar2Command.java index a421ff8..680e37d 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/Pazpar2Command.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/Pazpar2Command.java @@ -8,7 +8,7 @@ import org.apache.log4j.Logger; import com.indexdata.pz2utils4jsf.pazpar2.state.StateManager; -public class Pazpar2Command implements Serializable { +public class Pazpar2Command implements CommandReadOnly, Serializable { private static Logger logger = Logger.getLogger(Pazpar2Command.class); private static final long serialVersionUID = -6825491856480675917L; @@ -108,5 +108,18 @@ public class Pazpar2Command implements Serializable { public String toString () { return parameters.toString(); } + + @Override + public String getParameterValue(String parameterName) { + return getParameter(parameterName).getValueWithExpressions(); + + } + + @Override + public String getUrlEncodedParameterValue(String parameterName) { + return getParameter(parameterName).getEncodedQueryString(); + } + + } 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 b0e13b3..e6ecec4 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/Pazpar2Commands.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/Pazpar2Commands.java @@ -78,5 +78,9 @@ public class Pazpar2Commands implements Serializable { public Pazpar2Command getCommand(String name) { return stateMgr.checkOut(name); } + + public CommandReadOnly getCommandReadOnly(String name) { + return stateMgr.getCommand(name); + } } diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/SearchCommand.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/SearchCommand.java index 9486e86..25dc68e 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/SearchCommand.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/SearchCommand.java @@ -20,13 +20,11 @@ public class SearchCommand extends Pazpar2Command { setParameter(new CommandParameter("session","=",sessionId)); } - public void setQuery(String query) { - logger.info("writing query: " + query); + public void setQuery(String query) { setParameter(new CommandParameter("query","=",query)); } - public String getQuery () { - logger.info("retrieving query"); + public String getQuery () { return getParameter("query") == null ? null : getParameter("query").getValueWithExpressions(); } diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/sp/ServiceProxyClient.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/sp/ServiceProxyClient.java index 2f96b13..4aee1cf 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/sp/ServiceProxyClient.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/sp/ServiceProxyClient.java @@ -42,6 +42,7 @@ import com.indexdata.pz2utils4jsf.errors.ConfigurationException; import com.indexdata.pz2utils4jsf.pazpar2.CommandResponse; import com.indexdata.pz2utils4jsf.pazpar2.SearchClient; import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandParameter; +import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandReadOnly; import com.indexdata.pz2utils4jsf.pazpar2.commands.Pazpar2Command; import com.indexdata.pz2utils4jsf.pazpar2.sp.auth.AuthenticationEntity; import com.indexdata.pz2utils4jsf.pazpar2.sp.auth.ServiceProxyUser; @@ -158,7 +159,7 @@ public class ServiceProxyClient implements SearchClient { * @throws ClientProtocolException * @throws IOException */ - private byte[] send(Pazpar2Command command) throws ClientProtocolException, IOException { + private byte[] send(CommandReadOnly command) throws ClientProtocolException, IOException { String url = serviceUrl + "?" + command.getEncodedQueryString(); logger.info("Sending request "+url); HttpGet httpget = new HttpGet(url); @@ -195,12 +196,12 @@ public class ServiceProxyClient implements SearchClient { } @Override - public void setSearchCommand(Pazpar2Command command) { + public void setSearchCommand(CommandReadOnly command) { // Do nothing, Service Proxy is handling this } @Override - public CommandResponse executeCommand(Pazpar2Command command, + public CommandResponse executeCommand(CommandReadOnly command, ByteArrayOutputStream baos) throws Pazpar2ErrorException, IOException { byte[] response = send(command); baos.write(response); diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/state/StateManager.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/state/StateManager.java index 14951e6..4398efa 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/state/StateManager.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/state/StateManager.java @@ -11,6 +11,7 @@ import javax.enterprise.context.SessionScoped; import org.apache.log4j.Logger; +import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandReadOnly; import com.indexdata.pz2utils4jsf.pazpar2.commands.Pazpar2Command; import com.indexdata.pz2utils4jsf.utils.Utils; @@ -83,10 +84,14 @@ public class StateManager implements Serializable { * @return Copy this state's instance of the given command */ public Pazpar2Command checkOut (String commandName) { - logger.info("Getting " + commandName + " from state manager."); + logger.debug("Getting " + commandName + " from state manager."); return getCurrentState().getCommand(commandName).copy(); } + public CommandReadOnly getCommand (String commandName) { + return getCurrentState().getCommand(commandName); + } + public Pazpar2State getCurrentState () { return states.get(currentKey); } -- 1.7.10.4