import com.indexdata.mkjsf.pazpar2.commands.CommandParameter;\r
import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command;\r
import com.indexdata.mkjsf.pazpar2.commands.sp.AuthCommand;\r
+import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommand;\r
import com.indexdata.mkjsf.pazpar2.data.CommandError;\r
import com.indexdata.mkjsf.utils.Utils;\r
\r
return initDocPaths;\r
}\r
\r
- public HttpResponseWrapper postInitDoc(byte[] initDoc, boolean includeDebug) {\r
- HttpPost post = new HttpPost(serviceUrl+"?command=init" + (includeDebug? "&includeDebug=yes" : ""));\r
+ public HttpResponseWrapper postInitDoc(byte[] initDoc, Pazpar2Command command) {\r
+ String requestParameters = command.getEncodedQueryString();\r
+ logger.info("Initiating session with init doc and [" + requestParameters +"]");\r
+ HttpPost post = new HttpPost(serviceUrl+"?" + requestParameters);\r
post.setEntity(new ByteArrayEntity(initDoc));\r
ClientCommandResponse commandResponse = null;\r
byte[] response;\r
import com.indexdata.mkjsf.pazpar2.Pz2Service;\r
import com.indexdata.mkjsf.pazpar2.commands.CommandParameter;\r
import com.indexdata.mkjsf.pazpar2.commands.InitCommand;\r
+import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command;\r
import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject;\r
import com.indexdata.mkjsf.pazpar2.data.ResponseParser;\r
import com.indexdata.mkjsf.pazpar2.data.sp.SpResponseDataObject;\r
private static Logger logger = Logger.getLogger(InitCommandSp.class);\r
private InitCommand command = null;\r
\r
- private InitDocUpload initDocUpload;\r
+ private InitDocUpload initDocUpload = null;\r
\r
public InitCommandSp(InitCommand initCommand) {\r
this.command=initCommand;\r
public SpResponseDataObject run() {\r
Pz2Service.get().resetSearchAndRecordCommands();\r
Pz2Service.get().getPzresp().getSp().resetAuthAndBeyond(true); \r
- try {\r
- byte[] bytes = getUploadedInitDoc().getBytes();\r
- HttpResponseWrapper response = Pz2Service.get().getSpClient().postInitDoc(bytes,getIncludeDebug().equals("yes")); \r
- ResponseDataObject responseObject = ResponseParser.getParser().getDataObject((ClientCommandResponse)response); \r
- Pz2Service.get().getPzresp().put("init", responseObject);\r
- } catch (IOException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
+ if (initDocUpload.hasUploadedFile()) {\r
+ try {\r
+ byte[] bytes = getUploadedInitDoc().getBytes();\r
+ HttpResponseWrapper response = Pz2Service.get().getSpClient().postInitDoc(bytes,command); \r
+ ResponseDataObject responseObject = ResponseParser.getParser().getDataObject((ClientCommandResponse)response); \r
+ Pz2Service.get().getPzresp().put("init", responseObject);\r
+ } catch (IOException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ } else {\r
+ Pz2Service.get().getSpClient().executeCommand(this.command);\r
}\r
return null;\r
}\r
+ \r
+ /**\r
+ * Sets the <code>windowid</code> parameter. See Service Proxy documentation for details.\r
+ */ \r
+ public void setWindowid (String windowid) {\r
+ command.setParameterInState(new CommandParameter("windowid","=",windowid));\r
+ }\r
+ \r
+ /** \r
+ * Returns the <code>windowid</code> parameter value.\r
+ */\r
+ public String getWindowid () {\r
+ return command.getParameterValue("windowid");\r
+ }\r
\r
@Override\r
public boolean spOnly() {\r
return true;\r
- }\r
- \r
- \r
+ } \r
\r
}\r