<h:outputText id="activeClientsLabel" value="Active clients: show: " style="${cc.attrs.debug == 'true' ? '' : 'display:none;'}"/> \r
<h:outputText id="activeclientsField" value="${pz2.update()}" style="${cc.attrs.debug == 'true' ? '' : 'display:none;'}"/>\r
<h:outputText id="space" value=" - record: " style="${cc.attrs.debug == 'true' ? '' : 'display:none;'}"/>\r
- <h:outputText id="activeclientsFieldRecord" value="${pz2.doRecord()}" style="${cc.attrs.debug == 'true' ? '' : 'display:none;'}"/> \r
+ <h:outputText id="activeclientsFieldRecord" value="${pzreq.record.run().getActiveClients()}" style="${cc.attrs.debug == 'true' ? '' : 'display:none;'}"/> \r
</h:form>\r
\r
<h:form id="stateForm" prependId="false" rendered="${cc.attrs.trackHistory == 'true'}" style="${cc.attrs.debug == 'true' ? '' : 'display:none;'}">\r
import org.apache.log4j.Logger;\r
\r
import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command;\r
+import com.indexdata.mkjsf.pazpar2.data.Responses;\r
\r
public class CommandThread extends Thread {\r
\r
private static Logger logger = Logger.getLogger(CommandThread.class);\r
Pazpar2Command command;\r
SearchClient client;\r
+ Responses pzresp;\r
HttpResponseWrapper commandResponse = null; \r
\r
- public CommandThread (Pazpar2Command command, SearchClient client) {\r
+ public CommandThread (Pazpar2Command command, SearchClient client, Responses pzresp) {\r
this.command = command;\r
this.client = client;\r
+ this.pzresp = pzresp;\r
}\r
\r
/**\r
*/\r
public void run() { \r
logger.debug(command.getCommandName() + " executing asynchronously");\r
- commandResponse = client.executeCommand(command);\r
+ command.run(client,pzresp);\r
}\r
\r
/**\r
import com.indexdata.mkjsf.errors.ConfigurationException;\r
import com.indexdata.mkjsf.errors.ErrorCentral;\r
import com.indexdata.mkjsf.errors.ErrorHelper;\r
-import com.indexdata.mkjsf.pazpar2.commands.CommandParameter;\r
import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command;\r
import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Commands;\r
import com.indexdata.mkjsf.pazpar2.data.RecordResponse;\r
import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject;\r
-import com.indexdata.mkjsf.pazpar2.data.ResponseParser;\r
import com.indexdata.mkjsf.pazpar2.data.Responses;\r
import com.indexdata.mkjsf.pazpar2.state.StateListener;\r
import com.indexdata.mkjsf.pazpar2.state.StateManager;\r
\r
\r
private static final long serialVersionUID = 3440277287081557861L;\r
- private static Logger logger = Logger.getLogger(Pz2Bean.class);\r
- private static Logger responseLogger = Logger.getLogger("com.indexdata.mkjsf.pazpar2.responses"); \r
+ private static Logger logger = Logger.getLogger(Pz2Bean.class); \r
protected Pz2Client pz2Client = null;\r
protected ServiceProxyClient spClient = null;\r
protected SearchClient searchClient = null; \r
public @interface Preferred{}\r
\r
@Produces @Preferred @SessionScoped @Named("pzresp") public Responses getPzresp () {\r
- logger.info("Producing pzresp");\r
+ logger.trace("Producing pzresp");\r
return pzresp;\r
}\r
\r
@Produces @Preferred @SessionScoped @Named("pzreq") public Pazpar2Commands getPzreq () {\r
- logger.info("Producing pzreq");\r
+ logger.trace("Producing pzreq");\r
return pzreq;\r
}\r
\r
@Produces @Preferred @SessionScoped @Named("errors") public ErrorCentral getErrors() {\r
- logger.info("Producing errors");\r
+ logger.trace("Producing errors");\r
return errors;\r
}\r
\r
@Produces @Preferred @SessionScoped @Named("stateMgr") public StateManager getStateMgr() {\r
- logger.info("Produces stateMgr");\r
+ logger.trace("Producing stateMgr");\r
return stateMgr;\r
}\r
-\r
\r
public void configureClient(SearchClient client, ConfigurationReader configReader) {\r
logger.debug(Utils.objectId(this) + " will configure search client for the session");\r
pzreq.getRecord().removeParametersInState();\r
pzreq.getSearch().removeParametersInState(); \r
}\r
- \r
- public void doSearch(String query) {\r
- pzreq.getSearch().setParameter(new CommandParameter("query","=",query)); \r
- doSearch();\r
- }\r
-\r
- public void doSearch() {\r
- try {\r
- if (errors.hasConfigurationErrors()) {\r
- logger.error("Ignoring search request due to configuration errors.");\r
- } else if (searchClient == null){\r
- logger.error("No search client defined. A client must either be pre-configured or selected before searching.");\r
- errors.addConfigurationError(new ConfigurationError("No client defined","Client is null","No search client defined. A client must be pre-configured or selected runtime, prior to searching."));\r
- } else {\r
- stateMgr.hasPendingStateChange("search",false);\r
- pzresp.resetSearchAndBeyond();\r
- pzreq.getRecord().removeParametersInState(); \r
- pzreq.getShow().setParameterInState(new CommandParameter("start","=",0)); \r
- logger.debug(Utils.objectId(this) + " is searching using "+pzreq.getCommand("search").getUrlEncodedParameterValue("query"));\r
- searchClient.setSearchCommand(pzreq.getCommand("search"));\r
- doCommand("search");\r
- }\r
- } catch (NullPointerException npe) {\r
- npe.printStackTrace(); \r
- }\r
- }\r
- \r
- public String doRecord() {\r
- if (errors.hasConfigurationErrors()) {\r
- logger.error("Ignoring record request due to configuration errors.");\r
- return "";\r
- } else if (!pzreq.getCommand("record").hasParameterValue("id")) {\r
- logger.debug("Ignoring record request due to no id parameter.");\r
- return "";\r
- } else if (pzresp.getSearch().hasApplicationError()) {\r
- logger.debug("Ignoring record request due search error.");\r
- return "";\r
- } else {\r
- logger.debug("Executing record command");\r
- doCommand("record");\r
- return pzresp.getRecord().getActiveClients();\r
- }\r
- }\r
\r
/**\r
* Refreshes 'show', 'stat', 'termlist', and 'bytarget' data object from pazpar2\r
logger.debug("Request to update: " + commands);\r
try {\r
if (commands.equals("search")) {\r
- doSearch();\r
+ pzreq.getSearch().run();\r
return "new";\r
} else if (commands.equals("record")) {\r
- return doRecord();\r
+ pzreq.getRecord().run();\r
+ return pzresp.getRecord().getActiveClients();\r
} else if (pzresp.getSearch().isNew()) {\r
// For returning notification of 'search started' quickly to UI\r
logger.info("New search. Marking it old, then returning 'new' to trigger another round-trip.");\r
List<CommandThread> threadList = new ArrayList<CommandThread>();\r
StringTokenizer tokens = new StringTokenizer(commands,",");\r
while (tokens.hasMoreElements()) { \r
- threadList.add(new CommandThread(pzreq.getCommand(tokens.nextToken()),searchClient)); \r
+ threadList.add(new CommandThread(pzreq.getCommand(tokens.nextToken()),searchClient,Pz2Bean.get().getPzresp())); \r
}\r
for (CommandThread thread : threadList) {\r
thread.start();\r
e.printStackTrace();\r
}\r
}\r
- for (CommandThread thread : threadList) {\r
- String commandName = thread.getCommand().getCommandName();\r
- ClientCommandResponse response = (ClientCommandResponse) thread.getCommandResponse();\r
- responseLogger.debug("Response was: " + response.getResponseString());\r
- ResponseDataObject responseObject = ResponseParser.getParser().getDataObject(response);\r
- if (ResponseParser.docTypes.contains(responseObject.getType())) {\r
- pzresp.put(commandName, responseObject);\r
- } else {\r
- logger.info("Unknown doc type [" + responseObject.getType() + "]. Was not cached.");\r
- }\r
- }\r
return pzresp.getActiveClients();\r
}\r
} \r
protected void handleQueryStateChanges (String commands) {\r
if (stateMgr.hasPendingStateChange("search") && hasQuery()) { \r
logger.info("Triggered search: Found pending search change [" + pzreq.getCommand("search").toString() + "], doing search before updating " + commands); \r
- doSearch();\r
+ pzreq.getSearch().run();\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 (pzreq.getCommand("record").hasParameterValue("id")) {\r
- doRecord();\r
- } else { \r
- pzresp.put("record", new RecordResponse());\r
- }\r
+ pzreq.getRecord().run();\r
}\r
}\r
\r
pzreq.getSearch().removeParametersInState();\r
pzresp.getSp().resetAuthAndBeyond(true); \r
searchClient.setServiceUrl(url);\r
- // pzreq.setService(this);\r
} \r
}\r
\r
* \r
* @param query\r
*/\r
- public void doSearch(String query);\r
+ //public void doSearch(String query);\r
\r
/**\r
* Executes a Pazpar2 search using the current query \r
*/\r
- public void doSearch();\r
+ // public void doSearch();\r
\r
/**\r
* Executes a Pazpar2 record requests\r
* @return Active clients for the record request\r
*/\r
- public String doRecord();\r
+ // public String doRecord();\r
\r
/**\r
* Updates display data objects by issuing the following pazpar2 commands: \r
private String initDocResponse = ""; \r
private InitDocUpload initDocUpload; \r
\r
- @Inject ConfigurationReader configurator; \r
- @Inject Pz2Bean pz2;\r
+ @Inject ConfigurationReader configurator; \r
\r
public ServiceProxyExtensions() {\r
this.initDocUpload = new InitDocUpload(this);\r
}\r
\r
public void authenticate() { \r
- if (pz2.getPzresp().getSp().getAuth().unsupportedCommand()) {\r
+ if (Pz2Bean.get().getPzresp().getSp().getAuth().unsupportedCommand()) {\r
logger.warn("Running seemingly unsupported command [auth] against SP.");\r
}\r
- pz2.resetSearchAndRecordCommands();\r
- pz2.getPzresp().getSp().resetAuthAndBeyond(true);\r
- AuthCommand auth = pz2.getPzreq().getSp().getAuth(); \r
- ClientCommandResponse commandResponse = pz2.getSpClient().send(auth); \r
- String renamedResponse = renameResponseElement(commandResponse.getResponseString(), "auth"); \r
- commandResponse.setResponseToParse(renamedResponse);\r
- SpResponseDataObject responseObject = (SpResponseDataObject) ResponseParser.getParser().getDataObject(commandResponse); \r
- if (ResponseParser.docTypes.contains(responseObject.getType())) {\r
- pz2.getPzresp().put(auth.getCommandName(), responseObject);\r
- }\r
- if (responseObject.unsupportedCommand()) {\r
- logger.error("auth command does not seem to be supported by this Service Proxy");\r
- }\r
- String responseStr = commandResponse.getResponseString();\r
- logger.info(responseStr); \r
+ Pz2Bean.get().resetSearchAndRecordCommands();\r
+ Pz2Bean.get().getPzresp().getSp().resetAuthAndBeyond(true);\r
+ Pz2Bean.get().getPzreq().getSp().getAuth().run();\r
}\r
\r
public void login(String un, String pw) { \r
}\r
\r
public void login(String un, String pw, String navigateTo) { \r
- pz2.getPzreq().getSp().getAuth().setUsername(un);\r
- pz2.getPzreq().getSp().getAuth().setPassword(pw);\r
+ Pz2Bean.get().getPzreq().getSp().getAuth().setUsername(un);\r
+ Pz2Bean.get().getPzreq().getSp().getAuth().setPassword(pw);\r
login("");\r
} \r
\r
@Override \r
public String login(String navigateTo) {\r
- AuthCommand auth = pz2.getPzreq().getSp().getAuth(); \r
+ AuthCommand auth = Pz2Bean.get().getPzreq().getSp().getAuth(); \r
auth.setParameterInState(new CommandParameter("action","=","login"));\r
authenticate();\r
return navigateTo;\r
}\r
\r
public void ipAuthenticate () { \r
- AuthCommand auth = pz2.getPzreq().getSp().getAuth(); \r
+ AuthCommand auth = Pz2Bean.get().getPzreq().getSp().getAuth(); \r
auth.setParameterInState(new CommandParameter("action","=","ipAuth"));\r
authenticate();\r
}\r
- \r
- private String renameResponseElement(String responseString, String newName) {\r
- responseString = responseString.replace("<response>", "<" + newName + ">");\r
- responseString = responseString.replace("</response>", "</" + newName + ">");\r
- return responseString;\r
- }\r
- \r
+ \r
public String getInitDocPath () {\r
- return pz2.getSpClient().getConfiguration().get("INIT_DOC_PATH");\r
+ return Pz2Bean.get().getSpClient().getConfiguration().get("INIT_DOC_PATH");\r
}\r
\r
@Override\r
\r
@Override\r
public ClientCommandResponse postInit() throws UnsupportedEncodingException, IOException { \r
- String initDocPath = pz2.getSpClient().getInitDocPaths().get(0);\r
- logger.info("Paths: " + pz2.getSpClient().getInitDocPaths());\r
+ String initDocPath = Pz2Bean.get().getSpClient().getInitDocPaths().get(0);\r
+ logger.info("Paths: " + Pz2Bean.get().getSpClient().getInitDocPaths());\r
logger.info("Path: " + initDocPath); \r
- pz2.resetSearchAndRecordCommands();\r
- pz2.getPzresp().getSp().resetAuthAndBeyond(true);\r
- ClientCommandResponse response = pz2.getSpClient().postInitDoc(initDocPath + getInitFileName()); \r
+ Pz2Bean.get().resetSearchAndRecordCommands();\r
+ Pz2Bean.get().getPzresp().getSp().resetAuthAndBeyond(true);\r
+ ClientCommandResponse response = Pz2Bean.get().getSpClient().postInitDoc(initDocPath + getInitFileName()); \r
return response;\r
}\r
\r
@Override\r
public HttpResponseWrapper postInit(byte[] initDoc, boolean includeDebug) throws UnsupportedEncodingException, IOException { \r
- pz2.resetSearchAndRecordCommands();\r
- pz2.getPzresp().getSp().resetAuthAndBeyond(true);\r
- HttpResponseWrapper response = pz2.getSpClient().postInitDoc(initDoc,includeDebug); \r
+ Pz2Bean.get().resetSearchAndRecordCommands();\r
+ Pz2Bean.get().getPzresp().getSp().resetAuthAndBeyond(true);\r
+ HttpResponseWrapper response = Pz2Bean.get().getSpClient().postInitDoc(initDoc,includeDebug); \r
return response;\r
}\r
\r
\r
public void submitInitDoc () throws IOException {\r
ClientCommandResponse response = (ClientCommandResponse) initDocUpload.submit();\r
- ResponseDataObject responseObject = ResponseParser.getParser().getDataObject(response);\r
- logger.info("Putting init response to : " + Utils.objectId(pz2.getPzresp()));\r
- pz2.getPzresp().put("init", responseObject);\r
+ ResponseDataObject responseObject = ResponseParser.getParser().getDataObject(response); \r
+ Pz2Bean.get().getPzresp().put("init", responseObject);\r
}\r
\r
public void setIncludeInitDocDebug(boolean bool) {\r
\r
public CategoriesResponse getCategories () { \r
String command="categories";\r
- if (pz2.isServiceProxyService()) {\r
- if (pz2.getPzresp().getSp().getCategories().unsupportedCommand()) {\r
+ if (Pz2Bean.get().isServiceProxyService()) {\r
+ if (Pz2Bean.get().getPzresp().getSp().getCategories().unsupportedCommand()) {\r
logger.info("Skipping seemingly unsupported command: " + command); \r
return new CategoriesResponse();\r
} else {\r
- SpResponseDataObject response = (SpResponseDataObject) pz2.doCommand(command);\r
+ SpResponseDataObject response = (SpResponseDataObject) Pz2Bean.get().getPzreq().getSp().getCategories().run();\r
if (response.unsupportedCommand()) {\r
logger.warn("Command 'categories' not supported by this Service Proxy"); \r
} else if (response.hasApplicationError()) {\r
import com.indexdata.mkjsf.pazpar2.ClientCommandResponse;\r
import com.indexdata.mkjsf.pazpar2.HttpResponseWrapper;\r
import com.indexdata.mkjsf.pazpar2.Pz2Bean;\r
+import com.indexdata.mkjsf.pazpar2.SearchClient;\r
import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommand;\r
import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject;\r
import com.indexdata.mkjsf.pazpar2.data.ResponseParser;\r
+import com.indexdata.mkjsf.pazpar2.data.Responses;\r
\r
public abstract class Pazpar2Command implements Serializable {\r
\r
protected String name = "";\r
protected Map<String,CommandParameter> parameters = new HashMap<String,CommandParameter>(); \r
\r
- public Pazpar2Command () {\r
- \r
+ public Pazpar2Command () { \r
}\r
\r
public void setCommandName(String name) {\r
}\r
\r
public ResponseDataObject run() {\r
- logger.info("Running " + getCommandName() + " using " + Pz2Bean.get().getSearchClient()); \r
- HttpResponseWrapper httpResponse = Pz2Bean.get().getSearchClient().executeCommand(this);\r
+ return run(Pz2Bean.get().getSearchClient(),\r
+ Pz2Bean.get().getPzresp());\r
+ }\r
+ \r
+ /**\r
+ * For running the command in a thread. Client and Responses must be \r
+ * provided because at this point the CDI bean cannot be retrieved \r
+ * from within a thread.\r
+ * \r
+ * @param client\r
+ * @param pzresp\r
+ * @return\r
+ */\r
+ public ResponseDataObject run(SearchClient client,Responses pzresp) {\r
+ logger.info("Running " + getCommandName() + " using " + client); \r
+ HttpResponseWrapper httpResponse = client.executeCommand(this);\r
logger.info("Parsing response for " + getCommandName());\r
ResponseDataObject responseObject = ResponseParser.getParser().getDataObject((ClientCommandResponse) httpResponse);\r
logger.info("Storing response for " + getCommandName());\r
- Pz2Bean.get().getPzresp().put(getCommandName(), responseObject);\r
- return responseObject;\r
+ pzresp.put(getCommandName(), responseObject);\r
+ return responseObject; \r
}\r
+ \r
\r
public void setParameter (CommandParameter parameter) {\r
Pazpar2Command copy = this.copy();\r
}\r
\r
public String getParameterValue(String parameterName) {\r
- return getParameter(parameterName)==null ? "" : getParameter(parameterName).getValueWithExpressions();\r
- \r
+ return getParameter(parameterName)==null ? "" : getParameter(parameterName).getValueWithExpressions(); \r
}\r
\r
public String getUrlEncodedParameterValue(String parameterName) {\r
\r
private void checkInState(Pazpar2Command command) {\r
Pz2Bean.get().getStateMgr().checkIn(command);\r
- // if (stateMgr() != null) {\r
- // stateMgr().checkIn(command);\r
- // } else {\r
- // logger.info("Command '" + command.getCommandName() + "' not affecting state (history) as no state manager was defined for this command.");\r
- // }\r
}\r
\r
public abstract ServiceProxyCommand getSp();\r
\r
@Override\r
public ResponseDataObject run() {\r
- HttpResponseWrapper commandResponse = Pz2Bean.get().getSearchClient().executeCommand(this);\r
ResponseDataObject responseObject = null;\r
- if (commandResponse.getContentType().contains("xml")) {\r
- responseObject = ResponseParser.getParser().getDataObject((ClientCommandResponse)commandResponse);\r
- if (ResponseParser.docTypes.contains(responseObject.getType())) {\r
- logger.debug("Storing " + responseObject.getType() + " in pzresp. ");\r
- } else { \r
- logger.debug("Command was 'record' but response not '<record>' - assuming raw record response.");\r
- ResponseDataObject recordResponse = new RecordResponse(); \r
- recordResponse.setType("record");\r
- recordResponse.setXml(responseObject.getXml()); \r
- recordResponse.setAttribute("activeclients", "0"); \r
- }\r
- } else if (commandResponse.isBinary()) {\r
- responseObject = new RecordResponse(); \r
- responseObject.setType(getCommandName());\r
- logger.info("Binary response");\r
- responseObject.setAttribute("activeclients", "0");\r
- responseObject.setXml("<record>binary response</record>");\r
- responseObject.setBinary(commandResponse.getBytes());\r
+ if (hasParameterValue("id")) {\r
+ HttpResponseWrapper commandResponse = Pz2Bean.get().getSearchClient().executeCommand(this);\r
\r
+ if (commandResponse.getContentType().contains("xml")) {\r
+ responseObject = ResponseParser.getParser().getDataObject((ClientCommandResponse)commandResponse);\r
+ if (ResponseParser.docTypes.contains(responseObject.getType())) {\r
+ logger.debug("Storing " + responseObject.getType() + " in pzresp. ");\r
+ } else { \r
+ logger.debug("Command was 'record' but response not '<record>' - assuming raw record response.");\r
+ ResponseDataObject recordResponse = new RecordResponse(); \r
+ recordResponse.setType("record");\r
+ recordResponse.setXml(responseObject.getXml()); \r
+ recordResponse.setAttribute("activeclients", "0"); \r
+ }\r
+ } else if (commandResponse.isBinary()) {\r
+ responseObject = new RecordResponse(); \r
+ responseObject.setType(getCommandName());\r
+ logger.info("Binary response");\r
+ responseObject.setAttribute("activeclients", "0");\r
+ responseObject.setXml("<record>binary response</record>");\r
+ responseObject.setBinary(commandResponse.getBytes());\r
+ \r
+ } else {\r
+ logger.error("Response was not found to be XML or binary. The response was not handled.");\r
+ }\r
+ Pz2Bean.get().getPzresp().put(getCommandName(), responseObject);\r
} else {\r
- logger.error("Response was not found to be XML or binary. The response was not handled.");\r
+ logger.debug("No record id parameter on this command. Ignoring request but clearing any previous record result.");\r
+ Pz2Bean.get().getPzresp().put(getCommandName(), new RecordResponse());\r
}\r
- Pz2Bean.get().getPzresp().put(getCommandName(), responseObject);\r
return responseObject;\r
}\r
\r
\r
import org.apache.log4j.Logger;\r
\r
-import com.indexdata.mkjsf.pazpar2.ClientCommandResponse;\r
-import com.indexdata.mkjsf.pazpar2.HttpResponseWrapper;\r
import com.indexdata.mkjsf.pazpar2.Pz2Bean;\r
import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommand;\r
import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject;\r
-import com.indexdata.mkjsf.pazpar2.data.ResponseParser;\r
\r
@SessionScoped @Named\r
public class SearchCommand extends Pazpar2Command implements ServiceProxyCommand {\r
\r
public ResponseDataObject run() {\r
logger.info("Running " + getCommandName());\r
- logger.info("Using client " + Pz2Bean.get().getSearchClient());\r
- logger.info("Storing responses to " + Pz2Bean.get().getPzresp());\r
+ Pz2Bean.get().getStateMgr().hasPendingStateChange("search",false);\r
+ Pz2Bean.get().getPzresp().resetSearchAndBeyond();\r
+ Pz2Bean.get().getPzreq().getRecord().removeParametersInState(); \r
+ Pz2Bean.get().getPzreq().getShow().setParameterInState(new CommandParameter("start","=",0)); \r
Pz2Bean.get().getSearchClient().setSearchCommand(this);\r
- logger.info("Executing command " + getCommandName());\r
- HttpResponseWrapper httpResponse = Pz2Bean.get().getSearchClient().executeCommand(this);\r
- ResponseDataObject responseObject = ResponseParser.getParser().getDataObject((ClientCommandResponse) httpResponse);\r
- Pz2Bean.get().getPzresp().put(getCommandName(), responseObject);\r
- return responseObject;\r
+ return super.run();\r
}\r
\r
\r
package com.indexdata.mkjsf.pazpar2.commands.sp;\r
\r
+import org.apache.log4j.Logger;\r
+\r
+import com.indexdata.mkjsf.pazpar2.ClientCommandResponse;\r
+import com.indexdata.mkjsf.pazpar2.Pz2Bean;\r
import com.indexdata.mkjsf.pazpar2.commands.CommandParameter;\r
import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command;\r
+import com.indexdata.mkjsf.pazpar2.data.ResponseParser;\r
+import com.indexdata.mkjsf.pazpar2.data.sp.SpResponseDataObject;\r
\r
public class AuthCommand extends Pazpar2Command implements ServiceProxyCommand {\r
\r
private static final long serialVersionUID = 5487611235664162578L;\r
+ private static Logger logger = Logger.getLogger(AuthCommand.class);\r
\r
public AuthCommand() {\r
super("auth");\r
}\r
\r
+ public SpResponseDataObject run() {\r
+ ClientCommandResponse response = (ClientCommandResponse) Pz2Bean.get().getSearchClient().executeCommand(this); \r
+ String renamedResponse = renameResponseElement(response.getResponseString(), "auth"); \r
+ response.setResponseToParse(renamedResponse);\r
+ SpResponseDataObject responseObject = (SpResponseDataObject) ResponseParser.getParser().getDataObject(response); \r
+ if (ResponseParser.docTypes.contains(responseObject.getType())) {\r
+ Pz2Bean.get().getPzresp().put(getCommandName(), responseObject);\r
+ }\r
+ if (responseObject.unsupportedCommand()) {\r
+ logger.error("auth command does not seem to be supported by this Service Proxy");\r
+ }\r
+ return responseObject;\r
+ }\r
+ \r
+ private String renameResponseElement(String responseString, String newName) {\r
+ responseString = responseString.replace("<response>", "<" + newName + ">");\r
+ responseString = responseString.replace("</response>", "</" + newName + ">");\r
+ return responseString;\r
+ }\r
+\r
+ \r
public void setAction (String action) {\r
setParameterInState(new CommandParameter("action","=",action));\r
} \r
locations.add((Location)element);\r
}\r
} else {\r
- logger.debug("Found no locations");\r
+ logger.trace("Found no locations");\r
}\r
return locations;\r
}\r