X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fcom%2Findexdata%2Fmkjsf%2Fpazpar2%2Fcommands%2Fsp%2FAuthCommand.java;h=75d46aa1db12b494ccfce4d2f2edfa0c6537f408;hb=48ef3e8a3cd32eda3979082a7736cafd1862ae73;hp=723bc6a9726926e3f7f617bbafbcfdb94d81c593;hpb=95b6d2c90bde9b9946b79479f42233f6d7645f77;p=mkjsf-moved-to-github.git
diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/AuthCommand.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/AuthCommand.java
index 723bc6a..75d46aa 100644
--- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/AuthCommand.java
+++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/AuthCommand.java
@@ -3,12 +3,20 @@ package com.indexdata.mkjsf.pazpar2.commands.sp;
import org.apache.log4j.Logger;
import com.indexdata.mkjsf.pazpar2.ClientCommandResponse;
-import com.indexdata.mkjsf.pazpar2.Pz2Bean;
+import com.indexdata.mkjsf.pazpar2.Pz2Service;
import com.indexdata.mkjsf.pazpar2.commands.CommandParameter;
import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command;
import com.indexdata.mkjsf.pazpar2.data.ResponseParser;
import com.indexdata.mkjsf.pazpar2.data.sp.SpResponseDataObject;
+/**
+ * Represents a Service Proxy auth
command, can be accessed by pzreq.sp.auth
+ *
+ *
Authenticates a user against a Pazpar2 Service Proxy
+ * + * @author Niels Erik + * + */ public class AuthCommand extends Pazpar2Command implements ServiceProxyCommand { private static final long serialVersionUID = 5487611235664162578L; @@ -19,14 +27,14 @@ public class AuthCommand extends Pazpar2Command implements ServiceProxyCommand { } public SpResponseDataObject run() { - Pz2Bean.get().resetSearchAndRecordCommands(); - Pz2Bean.get().getPzresp().getSp().resetAuthAndBeyond(true); - ClientCommandResponse response = (ClientCommandResponse) Pz2Bean.get().getSearchClient().executeCommand(this); + Pz2Service.get().resetSearchAndRecordCommands(); + Pz2Service.get().getPzresp().getSp().resetAuthAndBeyond(true); + ClientCommandResponse response = (ClientCommandResponse) Pz2Service.get().getSearchClient().executeCommand(this); String renamedResponse = renameResponseElement(response.getResponseString(), "auth"); response.setResponseToParse(renamedResponse); SpResponseDataObject responseObject = (SpResponseDataObject) ResponseParser.getParser().getDataObject(response); if (ResponseParser.docTypes.contains(responseObject.getType())) { - Pz2Bean.get().getPzresp().put(getCommandName(), responseObject); + Pz2Service.get().getPzresp().put(getCommandName(), responseObject); } if (responseObject.unsupportedCommand()) { logger.error("auth command does not seem to be supported by this Service Proxy"); @@ -34,33 +42,59 @@ public class AuthCommand extends Pazpar2Command implements ServiceProxyCommand { return responseObject; } + /** + * Normalizes the response XML for the benefit of the SAX parser that creates data objects. + *The parser expects responses to have document element names corresponding to the names of + * the commands that created the responses.
+ * + * @param responseString + * @param newName + * @return + */ private String renameResponseElement(String responseString, String newName) { responseString = responseString.replace("action
. See Service Proxy documentation for details.
+ */
public void setAction (String action) {
setParameterInState(new CommandParameter("action","=",action));
}
+ /**
+ * Gets parameter value for action
+ */
public String getAction () {
return getParameterValue("action");
}
+ /**
+ * Sets Service Proxy command parameter username
. See Service Proxy documentation for details.
+ */
public void setUsername(String username) {
setParameterInState(new CommandParameter("username","=",username));
}
+ /**
+ * Gets parameter value for username
+ */
public String getUsername () {
return getParameterValue("username");
}
-
+
+ /**
+ * Sets Service Proxy command parameter password
. See Service Proxy documentation for details.
+ */
public void setPassword (String password) {
setParameterInState(new CommandParameter("password","=",password));
}
+ /**
+ * Gets parameter value for password
+ */
public String getPassword () {
return getParameterValue("password");
}