From 4e4ec6c08e54b7872b22495a54a7c2fb6439c4fd Mon Sep 17 00:00:00 2001 From: "Niels Erik G. Nielsen" Date: Tue, 30 Apr 2013 11:44:14 -0400 Subject: [PATCH] Makes init doc debug response optional --- src/main/java/com/indexdata/mkjsf/pazpar2/Pz2ProxyBean.java | 10 ++++++---- .../com/indexdata/mkjsf/pazpar2/sp/ServiceProxyClient.java | 4 ++-- .../indexdata/mkjsf/pazpar2/sp/ServiceProxyInterface.java | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2ProxyBean.java b/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2ProxyBean.java index 989cc06..09e500a 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2ProxyBean.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2ProxyBean.java @@ -70,7 +70,10 @@ public class Pz2ProxyBean extends Pz2Bean implements ServiceProxyInterface { } public void ipAuthenticate (ServiceProxyUser user) { - if (!user.isAuthenticated()) { + if (!user.isIpAuthenticated()) { + if (user.isAuthenticated()) { + user.clear(); + } ((ServiceProxyClient)searchClient).ipAuthenticate(user); } } @@ -125,14 +128,13 @@ public class Pz2ProxyBean extends Pz2Bean implements ServiceProxyInterface { } @Override - public String postInit(byte[] initDoc) throws UnsupportedEncodingException, IOException { + public String postInit(byte[] initDoc, boolean includeDebug) throws UnsupportedEncodingException, IOException { pzresp.reset(); - byte[] response = ((ServiceProxyClient)searchClient).postInitDoc(initDoc); + byte[] response = ((ServiceProxyClient)searchClient).postInitDoc(initDoc,includeDebug); initDocResponse = new String(response,"UTF-8"); return initDocResponse; } - @Override public String getInitResponse() { return initDocResponse; diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/sp/ServiceProxyClient.java b/src/main/java/com/indexdata/mkjsf/pazpar2/sp/ServiceProxyClient.java index 14bec03..fb3c867 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/sp/ServiceProxyClient.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/sp/ServiceProxyClient.java @@ -293,8 +293,8 @@ public class ServiceProxyClient implements SearchClient { return initDocPaths; } - public byte[] postInitDoc(byte[] initDoc) throws IOException { - HttpPost post = new HttpPost(selectedServiceUrl+"?command=init&includeDebug=yes"); + public byte[] postInitDoc(byte[] initDoc, boolean includeDebug) throws IOException { + HttpPost post = new HttpPost(selectedServiceUrl+"?command=init" + (includeDebug? "&includeDebug=yes" : "")); post.setEntity(new ByteArrayEntity(initDoc)); byte[] response = client.execute(post, handler); logger.debug("Response on POST was: " + new String(response,"UTF-8")); diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/sp/ServiceProxyInterface.java b/src/main/java/com/indexdata/mkjsf/pazpar2/sp/ServiceProxyInterface.java index 46d4e77..abbb1ec 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/sp/ServiceProxyInterface.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/sp/ServiceProxyInterface.java @@ -10,7 +10,7 @@ public interface ServiceProxyInterface extends Pz2Interface { public void setInitFileName (String fileName); public String getInitFileName(); public String postInit() throws UnsupportedEncodingException, IOException; - public String postInit(byte[] initDoc) throws UnsupportedEncodingException, IOException; + public String postInit(byte[] initDoc, boolean includeDebug) throws UnsupportedEncodingException, IOException; public String getInitResponse(); public void setServiceProxyUrl(String url); public String getServiceProxyUrl(); -- 1.7.10.4