return initDocPaths;\r
}\r
\r
- public ClientCommandResponse postInitDoc(byte[] initDoc, boolean includeDebug) throws IOException {\r
+ public HttpResponseWrapper postInitDoc(byte[] initDoc, boolean includeDebug) {\r
HttpPost post = new HttpPost(serviceUrl+"?command=init" + (includeDebug? "&includeDebug=yes" : ""));\r
post.setEntity(new ByteArrayEntity(initDoc));\r
- byte[] response = client.execute(post, handler);\r
- logger.debug("Response on POST was: " + new String(response,"UTF-8")); \r
- return new ClientCommandResponse(handler.getStatusCode(),response,handler.getContentType()); \r
+ ClientCommandResponse commandResponse = null;\r
+ byte[] response;\r
+ try {\r
+ response = client.execute(post, handler);\r
+ if (handler.getStatusCode()==200) {\r
+ commandResponse = new ClientCommandResponse(handler.getStatusCode(),response,handler.getContentType());\r
+ } else {\r
+ logger.error("Service Proxy status code: " + handler.getStatusCode());\r
+ commandResponse = new ClientCommandResponse(handler.getStatusCode(),CommandError.insertPazpar2ErrorXml("init", "Service Proxy error occurred", new String(response,"UTF-8")),"text/xml"); \r
+ }\r
+ } catch (ClientProtocolException e) {\r
+ logger.error(e.getMessage());\r
+ e.printStackTrace();\r
+ commandResponse = new ClientCommandResponse(-1,CommandError.createErrorXml("init", "client protocol exception", e.getMessage()),"text/xml"); \r
+ } catch (IOException e) {\r
+ logger.error(e.getMessage());\r
+ e.printStackTrace();\r
+ commandResponse = new ClientCommandResponse(-1,CommandError.createErrorXml("init", "IO", e.getMessage()),"text/xml"); \r
+ }\r
+ return commandResponse; \r
}\r
\r
public void setServiceUrl (String url) { \r
}\r
\r
@Override\r
- public ClientCommandResponse postInit(byte[] initDoc, boolean includeDebug) throws UnsupportedEncodingException, IOException { \r
+ public HttpResponseWrapper postInit(byte[] initDoc, boolean includeDebug) throws UnsupportedEncodingException, IOException { \r
pz2.resetSearchAndRecordCommands();\r
pzresp.resetAllSessionData();\r
- ClientCommandResponse response = pz2.getSpClient().postInitDoc(initDoc,includeDebug); \r
+ HttpResponseWrapper response = pz2.getSpClient().postInitDoc(initDoc,includeDebug); \r
return response;\r
}\r
\r
public String login(String navigateTo); \r
public void setInitFileName (String fileName); \r
public String getInitFileName();\r
- public ClientCommandResponse postInit() throws UnsupportedEncodingException, IOException;\r
- public ClientCommandResponse postInit(byte[] initDoc, boolean includeDebug) throws UnsupportedEncodingException, IOException;\r
+ public HttpResponseWrapper postInit() throws UnsupportedEncodingException, IOException;\r
+ public HttpResponseWrapper postInit(byte[] initDoc, boolean includeDebug) throws UnsupportedEncodingException, IOException;\r
public String getInitResponse();\r
}\r