import com.indexdata.pz2utils4jsf.errors.ErrorHelper;\r
import com.indexdata.pz2utils4jsf.errors.ErrorInterface;\r
import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandParameter;\r
+import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandReadOnly;\r
import com.indexdata.pz2utils4jsf.pazpar2.commands.Pazpar2Commands;\r
import com.indexdata.pz2utils4jsf.pazpar2.data.Pazpar2ResponseData;\r
import com.indexdata.pz2utils4jsf.pazpar2.data.Pazpar2ResponseParser;\r
\r
@Inject ConfigurationReader configurator;\r
@Inject StateManager stateMgr;\r
- @Inject Pazpar2Commands req;\r
- @Inject Pazpar2Responses data;\r
+ @Inject Pazpar2Commands pzreq;\r
+ @Inject Pazpar2Responses pzresp;\r
\r
protected ResultsPager pager = null; \r
\r
configurationErrors.add(new ConfigurationError("Search Client","Configuration",e.getMessage(),new ErrorHelper(configReader))); \r
} \r
logger.info(configReader.document());\r
- data.reset(); \r
+ pzresp.reset(); \r
}\r
\r
\r
public void doSearch(String query) {\r
- req.getSearch().setParameter(new CommandParameter("query","=",query)); \r
+ pzreq.getSearch().setParameter(new CommandParameter("query","=",query)); \r
doSearch();\r
}\r
\r
public void doSearch() { \r
stateMgr.hasPendingStateChange("search",false);\r
- data.reset();\r
+ pzresp.reset();\r
// TODO: avoid state proliferation here:\r
- req.getRecord().removeParameters();\r
- req.getShow().setParameter(new CommandParameter("start","=",0)); \r
- logger.debug(Utils.objectId(this) + " is searching using "+req.getCommandReadOnly("search").getUrlEncodedParameterValue("query"));\r
+ pzreq.getRecord().removeParameters();\r
+ pzreq.getShow().setParameter(new CommandParameter("start","=",0)); \r
+ logger.debug(Utils.objectId(this) + " is searching using "+pzreq.getCommandReadOnly("search").getUrlEncodedParameterValue("query"));\r
doCommand("search"); \r
}\r
\r
List<CommandThread> threadList = new ArrayList<CommandThread>();\r
StringTokenizer tokens = new StringTokenizer(commands,",");\r
while (tokens.hasMoreElements()) { \r
- threadList.add(new CommandThread(req.getCommandReadOnly(tokens.nextToken()),searchClient)); \r
+ threadList.add(new CommandThread(pzreq.getCommandReadOnly(tokens.nextToken()),searchClient)); \r
}\r
for (CommandThread thread : threadList) {\r
thread.start();\r
String response = thread.getResponse();\r
logger.debug("Response was: " + response);\r
Pazpar2ResponseData responseObject = Pazpar2ResponseParser.getParser().getDataObject(response);\r
- data.put(commandName, responseObject); \r
+ pzresp.put(commandName, responseObject); \r
}\r
if (commands.equals("record")) {\r
- logger.debug("Record: Active clients: "+data.getRecord().getActiveClients());\r
- return data.getRecord().getActiveClients();\r
+ logger.debug("Record: Active clients: "+pzresp.getRecord().getActiveClients());\r
+ return pzresp.getRecord().getActiveClients();\r
} else {\r
- return data.getActiveClients();\r
+ return pzresp.getActiveClients();\r
} \r
} else {\r
logger.debug("Skipped requests for " + commands + " as there's not yet a query."); \r
- data.reset();\r
+ pzresp.reset();\r
return "0";\r
}\r
} else {\r
\r
public String toggleRecord (String recId) {\r
if (hasRecord(recId)) {\r
- req.getRecord().removeParameters(); \r
- data.put("record", new RecordResponse());\r
+ pzreq.getRecord().removeParameters(); \r
+ pzresp.put("record", new RecordResponse());\r
return "";\r
} else {\r
- req.getRecord().setRecordId(recId);\r
+ pzreq.getRecord().setRecordId(recId);\r
return doCommand("record");\r
}\r
}\r
\r
@Override\r
public boolean hasRecord (String recId) {\r
- return req.getCommandReadOnly("record").hasParameters() && data.getRecord().getRecId().equals(recId);\r
+ return pzreq.getCommandReadOnly("record").hasParameters() && pzresp.getRecord().getRecId().equals(recId);\r
}\r
\r
public String getCurrentStateKey () { \r
}\r
\r
public boolean hasCommandErrors () {\r
- return data.hasApplicationError();\r
+ return pzresp.hasApplicationError();\r
}\r
\r
/**\r
}\r
\r
\r
- protected boolean hasQuery() { \r
- return req.getSearch().getParameter("query") != null && req.getSearch().getParameter("query").getValueWithExpressions().length()>0;\r
+ protected boolean hasQuery() { \r
+ return pzreq.getCommandReadOnly("search").hasParameterSet("query"); \r
}\r
\r
\r
public ResultsPager getPager () {\r
if (pager == null) {\r
- pager = new ResultsPager(data); \r
+ pager = new ResultsPager(pzresp); \r
} \r
return pager; \r
}\r
\r
public ResultsPager setPager (int pageRange) {\r
- pager = new ResultsPager(data,pageRange,req);\r
+ pager = new ResultsPager(pzresp,pageRange,pzreq);\r
return pager;\r
}\r
\r
if (stateMgr.hasPendingStateChange("record") && ! commands.equals("record")) { \r
logger.debug("Found pending record ID change. Doing record before updating " + commands);\r
stateMgr.hasPendingStateChange("record",false);\r
- if (req.getCommandReadOnly("record").hasParameters()) {\r
+ if (pzreq.getCommandReadOnly("record").hasParameters()) {\r
update("record");\r
} else { \r
- data.put("record", new RecordResponse());\r
+ pzresp.put("record", new RecordResponse());\r
}\r
}\r
}\r
\r
protected String doCommand(String commandName) { \r
- logger.debug(req.getCommandReadOnly(commandName).getEncodedQueryString() + ": Results for "+ req.getCommandReadOnly("search").getEncodedQueryString());\r
+ logger.debug(pzreq.getCommandReadOnly(commandName).getEncodedQueryString() + ": Results for "+ pzreq.getCommandReadOnly("search").getEncodedQueryString());\r
return update(commandName);\r
}\r
\r
public String login(String navigateTo) {\r
logger.info("doing login");\r
((ServiceProxyClient)searchClient).authenticate(user);\r
- data.reset();\r
- req.getRecord().removeParameters();\r
- req.getSearch().setQuery(null);\r
+ pzresp.reset();\r
+ pzreq.getRecord().removeParameters();\r
+ pzreq.getSearch().setQuery(null);\r
\r
return navigateTo;\r
}\r
public void setServiceProxyUrl(String url) {\r
logger.info("Setting Service Proxy url: " + url);\r
serviceProxyUrl = url;\r
- req.getSearch().setQuery(null);\r
- data.reset();\r
+ pzreq.getSearch().setQuery(null);\r
+ pzresp.reset();\r
}\r
\r
public String getServiceProxyUrl() {\r
String initDocPath = ((ServiceProxyClient)searchClient).getInitDocPaths()[0];\r
logger.info("Paths: " + ((ServiceProxyClient)searchClient).getInitDocPaths());\r
logger.info("Path: " + initDocPath);\r
- data.reset();\r
+ pzresp.reset();\r
byte[] response = ((ServiceProxyClient)searchClient).postInitDoc(initDocPath + getInitFileName());\r
initDocResponse = new String(response,"UTF-8");\r
return initDocResponse;\r
\r
@Override\r
public String postInit(byte[] initDoc) throws UnsupportedEncodingException, IOException { \r
- data.reset();\r
+ pzresp.reset();\r
byte[] response = ((ServiceProxyClient)searchClient).postInitDoc(initDoc);\r
initDocResponse = new String(response,"UTF-8");\r
return initDocResponse;\r