Tweaks configuration, command responses, pz2/sp switching
authorNiels Erik G. Nielsen <nielserik@indexdata.com>
Thu, 9 May 2013 01:24:17 +0000 (21:24 -0400)
committerNiels Erik G. Nielsen <nielserik@indexdata.com>
Thu, 9 May 2013 01:24:17 +0000 (21:24 -0400)
Generalizes method for retrieving char separated config properties
Consolidates command responses in one common class for sp an pz2 clients
Fixes switches of service urls for pz2 url to sp url and vice versa

src/main/java/com/indexdata/mkjsf/config/Configuration.java
src/main/java/com/indexdata/mkjsf/config/Mk2ConfigReader.java
src/main/java/com/indexdata/mkjsf/pazpar2/ClientCommandResponse.java [new file with mode: 0644]
src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Bean.java
src/main/java/com/indexdata/mkjsf/pazpar2/Pz2CommandResponse.java [deleted file]
src/main/java/com/indexdata/mkjsf/pazpar2/ServiceProxyClient.java [new file with mode: 0644]
src/main/java/com/indexdata/mkjsf/pazpar2/ServiceProxyInterface.java [new file with mode: 0644]
src/main/java/com/indexdata/mkjsf/pazpar2/sp/ServiceProxyCommandResponse.java [deleted file]

index f375318..f7935fd 100644 (file)
@@ -1,8 +1,11 @@
 package com.indexdata.mkjsf.config;\r
 \r
 import java.io.Serializable;\r
+import java.util.ArrayList;\r
 import java.util.HashMap;\r
+import java.util.List;\r
 import java.util.Map;\r
+import java.util.StringTokenizer;\r
 \r
 import org.apache.log4j.Logger;\r
 \r
@@ -66,6 +69,19 @@ public class Configuration implements Serializable {
     } \r
     throw new MissingMandatoryParameterException("Missing mandatory parameter: " + key);     \r
   }\r
+  \r
+  public List<String> getMultiProperty(String key, String separator) {    \r
+    List<String> props = new ArrayList<String>();\r
+    String prop = get(key);\r
+    if (prop != null) {      \r
+      StringTokenizer tokenizer = new StringTokenizer(prop,separator);\r
+      while (tokenizer.hasMoreElements()) {\r
+        props.add(tokenizer.nextToken());\r
+      }     \r
+    }\r
+    return props;\r
+  }\r
+  \r
 \r
   public String getConfigFilePath() {
     return get("configpath","nopathgiven");\r
@@ -75,5 +91,7 @@ public class Configuration implements Serializable {
     return properties;\r
   }\r
   \r
+   \r
+  \r
 \r
 }\r
index bc57467..5cd0566 100644 (file)
@@ -59,7 +59,7 @@ public class Mk2ConfigReader implements ConfigurationReader  {
     MasterkeyConfiguration mkConfigContext;\r
     try {\r
       mkConfigContext = MasterkeyConfiguration.getInstance(servletContext,\r
-      "pazpar-application-jsf", ((HttpServletRequest) externalContext.getRequest()).getServerName());\r
+      "mkjsf", ((HttpServletRequest) externalContext.getRequest()).getServerName());\r
     } catch (IOException e) {\r
       throw new ConfigurationException(Mk2ConfigReader.class + " could not read configuration for '" + configurable.getModuleName() + "' using MasterKey configuration scheme: "+e.getMessage(),e);\r
     }        \r
diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/ClientCommandResponse.java b/src/main/java/com/indexdata/mkjsf/pazpar2/ClientCommandResponse.java
new file mode 100644 (file)
index 0000000..0375ca1
--- /dev/null
@@ -0,0 +1,67 @@
+package com.indexdata.mkjsf.pazpar2;\r
+\r
+import java.io.ByteArrayOutputStream;\r
+import java.io.UnsupportedEncodingException;\r
+\r
+import com.indexdata.masterkey.pazpar2.client.Pazpar2HttpResponse;\r
+\r
+public class ClientCommandResponse implements CommandResponse {\r
+    \r
+  private int statusCode;\r
+  private String contentType;\r
+  private byte[] content = null;\r
+  private String contentString = null;\r
+  \r
+  public ClientCommandResponse(Pazpar2HttpResponse pz2response, ByteArrayOutputStream content) {    \r
+    this.content = content.toByteArray();\r
+    this.statusCode = pz2response.getStatusCode();\r
+    this.contentType = pz2response.getContentType();\r
+  }\r
+    \r
+  public ClientCommandResponse(int statusCode, String content, String contentType) {\r
+    this.statusCode = statusCode;\r
+    this.contentString = content;\r
+    this.contentType = contentType;\r
+  }\r
+  \r
+  public ClientCommandResponse(int statusCode, byte[] content, String contentType) {\r
+    this.statusCode = statusCode;\r
+    this.content = content;\r
+    this.contentType = contentType;\r
+  }\r
+\r
+  @Override\r
+  public int getStatusCode() {    \r
+    return statusCode;\r
+  }\r
+\r
+  @Override\r
+  public String getContentType() {\r
+    return contentType;\r
+  }\r
+\r
+  @Override\r
+  public String getResponseString() {\r
+    if (content == null) {\r
+      return contentString;\r
+    } else {\r
+      try {\r
+        return new String(content,"UTF-8");\r
+      } catch (UnsupportedEncodingException e) {      \r
+        e.printStackTrace();\r
+        return "<error>unsupported encoding</error>";\r
+      }\r
+    }\r
+  }\r
+\r
+  @Override\r
+  public byte[] getBytes() {\r
+    return content;\r
+  }\r
+\r
+  @Override\r
+  public boolean isBinary() {    \r
+    return !contentType.contains("xml");\r
+  }\r
+\r
+}\r
index 490cee6..03bd096 100644 (file)
@@ -295,20 +295,30 @@ public class Pz2Bean implements Pz2Interface, StateListener, Configurable, Seria
   \r
   public void setServiceProxyUrl(String url) {\r
     searchClient = spClient;\r
+    setServiceType(SERVICE_TYPE_SP);\r
     setServiceUrl(url);\r
   }\r
   \r
   public String getServiceProxyUrl () {\r
-    return spClient.getServiceUrl();\r
+    if (isServiceProxyService()) {\r
+      return spClient.getServiceUrl();\r
+    } else {\r
+      return "";\r
+    }\r
   }\r
   \r
   public void setPazpar2Url(String url) {\r
     searchClient = pz2Client;\r
+    setServiceType(SERVICE_TYPE_PZ2);\r
     setServiceUrl(url);\r
   }\r
   \r
   public String getPazpar2Url() {\r
-    return pz2Client.getServiceUrl();\r
+    if (isPazpar2Service()) {\r
+      return pz2Client.getServiceUrl();\r
+    } else {\r
+      return "";\r
+    }\r
   }\r
 \r
   \r
diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2CommandResponse.java b/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2CommandResponse.java
deleted file mode 100644 (file)
index 27cf441..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.indexdata.mkjsf.pazpar2;\r
-\r
-import java.io.ByteArrayOutputStream;\r
-import java.io.UnsupportedEncodingException;\r
-\r
-import com.indexdata.masterkey.pazpar2.client.Pazpar2HttpResponse;\r
-\r
-public class Pz2CommandResponse implements CommandResponse {\r
-  \r
-  private Pazpar2HttpResponse pz2httpResponse = null;\r
-  private int statusCode;\r
-  private String contentType;\r
-  private byte[] content = null;\r
-  private String contentString = null;\r
-  \r
-  public Pz2CommandResponse(Pazpar2HttpResponse pz2response, ByteArrayOutputStream content) {\r
-    pz2httpResponse = pz2response;\r
-    this.content = content.toByteArray();\r
-    this.statusCode = pz2httpResponse.getStatusCode();\r
-    this.contentType = pz2httpResponse.getContentType();\r
-  }\r
-  \r
-  public Pz2CommandResponse(Pazpar2HttpResponse pz2response, String content) {\r
-    pz2httpResponse = pz2response;\r
-    this.contentString = content;\r
-  }\r
-  \r
-  public Pz2CommandResponse(int statusCode, String content, String contentType) {\r
-    this.statusCode = statusCode;\r
-    this.contentString = content;\r
-    this.contentType = contentType;\r
-  }\r
-\r
-  @Override\r
-  public int getStatusCode() {    \r
-    return statusCode;\r
-  }\r
-\r
-  @Override\r
-  public String getContentType() {\r
-    return contentType;\r
-  }\r
-\r
-  @Override\r
-  public String getResponseString() {\r
-    if (content == null) {\r
-      return contentString;\r
-    } else {\r
-      try {\r
-        return new String(content,"UTF-8");\r
-      } catch (UnsupportedEncodingException e) {      \r
-        e.printStackTrace();\r
-        return "<error>unsupported encoding</error>";\r
-      }\r
-    }\r
-  }\r
-\r
-  @Override\r
-  public byte[] getBytes() {\r
-    return content;\r
-  }\r
-\r
-  @Override\r
-  public boolean isBinary() {    \r
-    return !contentType.contains("xml");\r
-  }\r
-\r
-}\r
diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/ServiceProxyClient.java b/src/main/java/com/indexdata/mkjsf/pazpar2/ServiceProxyClient.java
new file mode 100644 (file)
index 0000000..a43432e
--- /dev/null
@@ -0,0 +1,289 @@
+package com.indexdata.mkjsf.pazpar2;\r
+\r
+import static com.indexdata.mkjsf.utils.Utils.nl;\r
+\r
+import java.io.BufferedReader;\r
+import java.io.File;\r
+import java.io.FileReader;\r
+import java.io.IOException;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.apache.http.Header;\r
+import org.apache.http.HttpEntity;\r
+import org.apache.http.HttpResponse;\r
+import org.apache.http.StatusLine;\r
+import org.apache.http.client.ClientProtocolException;\r
+import org.apache.http.client.HttpClient;\r
+import org.apache.http.client.ResponseHandler;\r
+import org.apache.http.client.methods.HttpGet;\r
+import org.apache.http.client.methods.HttpPost;\r
+import org.apache.http.conn.ClientConnectionManager;\r
+import org.apache.http.conn.scheme.PlainSocketFactory;\r
+import org.apache.http.conn.scheme.Scheme;\r
+import org.apache.http.conn.scheme.SchemeRegistry;\r
+import org.apache.http.entity.ByteArrayEntity;\r
+import org.apache.http.entity.FileEntity;\r
+import org.apache.http.impl.client.DefaultHttpClient;\r
+import org.apache.http.impl.conn.PoolingClientConnectionManager;\r
+import org.apache.http.util.EntityUtils;\r
+import org.apache.log4j.Logger;\r
+\r
+import com.indexdata.mkjsf.config.Configuration;\r
+import com.indexdata.mkjsf.config.ConfigurationReader;\r
+import com.indexdata.mkjsf.errors.ConfigurationException;\r
+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.data.CommandError;\r
+import com.indexdata.mkjsf.pazpar2.sp.auth.ServiceProxyUser;\r
+import com.indexdata.mkjsf.utils.Utils;\r
+\r
+public class ServiceProxyClient implements SearchClient {\r
+    \r
+  private static final long serialVersionUID = -4031644009579840277L;\r
+  private static Logger logger = Logger.getLogger(ServiceProxyClient.class);\r
+  public static final String MODULENAME = "proxyclient";\r
+  \r
+  public static final String SP_INIT_DOC_PATHS = "SP_INIT_DOC_PATHS";\r
+  private String selectedServiceUrl = "";\r
+  \r
+  private List<String> initDocPaths = null;\r
+  private Configuration config = null;\r
+  \r
+  ProxyPz2ResponseHandler handler = new ProxyPz2ResponseHandler();\r
+  private transient HttpClient client;  \r
+  private Pazpar2Command checkAuth = null;\r
+  private Pazpar2Command ipAuth = null;\r
+\r
+  public ServiceProxyClient () {\r
+    SchemeRegistry schemeRegistry = new SchemeRegistry();\r
+    schemeRegistry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));\r
+    ClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry);\r
+    client = new DefaultHttpClient(cm);\r
+  }\r
+    \r
+  @Override\r
+  public void configure (ConfigurationReader configReader) {\r
+    logger.info(Utils.objectId(this) + " is configuring using the provided " + Utils.objectId(configReader));\r
+    try {\r
+      config = configReader.getConfiguration(this);      \r
+      selectedServiceUrl = config.get("SERVICE_PROXY_URL");\r
+      this.initDocPaths = config.getMultiProperty(SP_INIT_DOC_PATHS,",");\r
+      checkAuth = new AuthCommand(null);\r
+      checkAuth.setParameterInState(new CommandParameter("action","=","check"));\r
+      ipAuth = new AuthCommand(null);\r
+      ipAuth.setParameterInState(new CommandParameter("action","=","ipauth"));\r
+    } catch (ConfigurationException c) {\r
+      // TODO: \r
+      c.printStackTrace();\r
+    }    \r
+  }\r
+  \r
+  \r
+  public boolean authenticate (ServiceProxyUser user) {\r
+    logger.info("Authenticating [" + user.getProperty("name") + "]");            \r
+    Pazpar2Command auth = new AuthCommand(null);\r
+    auth.setParametersInState(new CommandParameter("action","=","login"), \r
+                              new CommandParameter("username","=",user.getProperty("name")), \r
+                              new CommandParameter("password","=",user.getProperty("password")));                                \r
+    ClientCommandResponse commandResponse = send(auth);\r
+    String responseStr = commandResponse.getResponseString();\r
+    logger.info(responseStr);      \r
+    if (responseStr.contains("FAIL")) {\r
+      user.credentialsAuthenticationSucceeded(false);\r
+      return false;\r
+    } else {\r
+      user.credentialsAuthenticationSucceeded(true);\r
+      return true;\r
+    }      \r
+  }\r
+  \r
+  public boolean checkAuthentication (ServiceProxyUser user) {    \r
+    ClientCommandResponse commandResponse = send(checkAuth);      \r
+    String responseStr = commandResponse.getResponseString();    \r
+    logger.info(responseStr);\r
+    if (responseStr.contains("FAIL")) {  \r
+      user.authenticationCheckFailed();\r
+      return false;\r
+    } else {                \r
+      return true;\r
+    }      \r
+  }\r
+  \r
+  public boolean ipAuthenticate (ServiceProxyUser user) {\r
+    ClientCommandResponse commandResponse = send(ipAuth);      \r
+    String responseStr = commandResponse.getResponseString();\r
+    logger.info(responseStr);\r
+    if (responseStr.contains("FAIL")) {\r
+      user.ipAuthenticationSucceeded(false);        \r
+      return false;\r
+    } else {\r
+      user.ipAuthenticationSucceeded(true);\r
+      return true;\r
+    }          \r
+  }\r
+  \r
+  public boolean isAuthenticatingClient () {\r
+    return true;\r
+  }\r
+  \r
+  public boolean isAuthenticated (ServiceProxyUser user) {\r
+    if (user.getProperty("name") != null && user.getProperty("password") != null) {\r
+      return checkAuthentication(user);\r
+    } else {\r
+      return false;\r
+    }\r
+  }\r
+  \r
+  /**\r
+   * Makes the request\r
+   * @param request\r
+   * @return HTTP response as a String\r
+   * @throws ClientProtocolException\r
+   * @throws IOException\r
+   */\r
+  private ClientCommandResponse send(Pazpar2Command command) {\r
+    ClientCommandResponse commandResponse = null;\r
+    String url = selectedServiceUrl + "?" + command.getEncodedQueryString(); \r
+    logger.info("Sending request "+url);    \r
+    HttpGet httpget = new HttpGet(url);     \r
+    byte[] response = null;\r
+    try {\r
+      response = client.execute(httpget, 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(command.getCommandName(), "Service Proxy error occurred", new String(response,"UTF-8")),"text/xml");                       \r
+      }       \r
+    } catch (Exception e) {\r
+      e.printStackTrace();\r
+      commandResponse = new ClientCommandResponse(-1,CommandError.createErrorXml(command.getCommandName(), e.getClass().getSimpleName(), (e.getMessage()!= null ? e.getMessage() : "") + (e.getCause()!=null ? e.getCause().getMessage() : "")),"text/xml");\r
+    }\r
+    return commandResponse; \r
+  }\r
+  \r
+  public class ProxyPz2ResponseHandler implements ResponseHandler<byte[]> {\r
+    private StatusLine statusLine = null;\r
+    private Header contentType = null;\r
+    public byte[] handleResponse(HttpResponse response) throws ClientProtocolException, IOException {\r
+      byte[] resp = null;\r
+      HttpEntity entity = response.getEntity();      \r
+      statusLine = response.getStatusLine();\r
+      if (entity != null) {        \r
+        resp = EntityUtils.toByteArray(entity);        \r
+        contentType = response.getEntity().getContentType();        \r
+      }       \r
+      EntityUtils.consume(entity);      \r
+      return resp;\r
+    }\r
+    public int getStatusCode() {\r
+      return statusLine.getStatusCode();\r
+    }    \r
+    public String getReasonPhrase() {\r
+      return statusLine.getReasonPhrase();\r
+    }\r
+    public String getContentType () {\r
+      return (contentType != null ? contentType.getValue() : "Content-Type not known"); \r
+    }\r
+  }\r
+\r
+  public int getStatusCode () {\r
+    return handler.getStatusCode();\r
+  }\r
+  \r
+  public String getReasonPhrase() {\r
+    return handler.getReasonPhrase();\r
+  }\r
+\r
+  @Override\r
+  public void setSearchCommand(Pazpar2Command command) {\r
+    // Do nothing, Service Proxy is handling this    \r
+  }\r
+\r
+  @Override\r
+  public CommandResponse executeCommand(Pazpar2Command command) {\r
+    return send(command);\r
+  }\r
+\r
+  public ServiceProxyClient cloneMe() {\r
+    logger.debug("Cloning Pz2Client");\r
+    ServiceProxyClient clone = new ServiceProxyClient();\r
+    clone.client = this.client;\r
+    clone.selectedServiceUrl = this.selectedServiceUrl;\r
+    clone.initDocPaths = this.initDocPaths;\r
+    return clone;\r
+  }\r
+\r
+  @Override\r
+  public Map<String, String> getDefaults() {    \r
+    return new HashMap<String,String>();\r
+  }\r
+\r
+  @Override\r
+  public String getModuleName() {\r
+    return MODULENAME;\r
+  }\r
+  \r
+  @Override\r
+  public List<String> documentConfiguration () {\r
+    List<String> doc = new ArrayList<String>();\r
+    doc.add(nl+ MODULENAME + " was configured to access the Pazpar2 service proxy at: " + (selectedServiceUrl.length()>0 ? selectedServiceUrl : "[not defined yet]"));\r
+    return null;\r
+  }\r
+  \r
+  public ClientCommandResponse postInitDoc (String filePath) throws IOException {\r
+    logger.info("Looking to post the file in : [" + filePath +"]");\r
+    HttpPost post = new HttpPost(selectedServiceUrl+"?command=init&includeDebug=yes");\r
+    File initDoc = new File(filePath);\r
+    logger.info("Posting to SP: ");\r
+    if (logger.isDebugEnabled()) {\r
+      BufferedReader reader = new BufferedReader(new FileReader(initDoc));\r
+      String line;\r
+      while ( (line = reader.readLine()) != null) {\r
+        System.out.println(line);\r
+      }\r
+      reader.close();\r
+    }\r
+    post.setEntity(new FileEntity(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
+  }\r
+  \r
+  public List<String> getInitDocPaths () {\r
+    logger.debug("Get init doc paths ");\r
+    logger.debug("length: " + initDocPaths.size());\r
+    return initDocPaths;\r
+  }\r
+  \r
+  public ClientCommandResponse postInitDoc(byte[] initDoc, boolean includeDebug) throws IOException {\r
+    HttpPost post = new HttpPost(selectedServiceUrl+"?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
+  }\r
+  \r
+  public void setServiceUrl (String url) {    \r
+    selectedServiceUrl = url;\r
+  }\r
+          \r
+  public Configuration getConfiguration () {\r
+    return config;\r
+  }\r
+\r
+  @Override\r
+  public String getServiceUrl() {    \r
+    return selectedServiceUrl;\r
+  }\r
+\r
+  @Override\r
+  public boolean hasServiceUrl() {\r
+    return selectedServiceUrl != null && selectedServiceUrl.length()>0;\r
+  }\r
+  \r
+}\r
diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/ServiceProxyInterface.java b/src/main/java/com/indexdata/mkjsf/pazpar2/ServiceProxyInterface.java
new file mode 100644 (file)
index 0000000..8c31abe
--- /dev/null
@@ -0,0 +1,14 @@
+package com.indexdata.mkjsf.pazpar2;\r
+\r
+import java.io.IOException;\r
+import java.io.UnsupportedEncodingException;\r
+\r
+\r
+public interface ServiceProxyInterface  {  \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 String getInitResponse();\r
+}\r
diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/sp/ServiceProxyCommandResponse.java b/src/main/java/com/indexdata/mkjsf/pazpar2/sp/ServiceProxyCommandResponse.java
deleted file mode 100644 (file)
index 90d4f2e..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-package com.indexdata.mkjsf.pazpar2.sp;\r
-\r
-import java.io.UnsupportedEncodingException;\r
-\r
-import com.indexdata.mkjsf.pazpar2.CommandResponse;\r
-\r
-public class ServiceProxyCommandResponse implements CommandResponse {\r
-\r
-  private int statusCode = 0;\r
-  private byte[] content = null;\r
-  private String responseString = null;\r
-  private String contentType = "";\r
-  \r
-  public ServiceProxyCommandResponse(int statusCode, byte[] content, String contentType) {\r
-    this.statusCode = statusCode;\r
-    this.content = content;\r
-    this.contentType = contentType;\r
-  }\r
-  \r
-  public ServiceProxyCommandResponse(int statusCode, String contentString, String contentType) {\r
-    this.statusCode = statusCode;\r
-    this.contentType = contentType;\r
-    this.responseString = contentString;\r
-  }\r
-    \r
-  @Override\r
-  public int getStatusCode() {\r
-    return statusCode;\r
-  }\r
-\r
-  @Override\r
-  public String getContentType() {\r
-    return contentType;    \r
-  }\r
-\r
-  @Override\r
-  public String getResponseString() {\r
-    if (content == null) {\r
-      return responseString;\r
-    } else {\r
-      try {\r
-        return new String(content,"UTF-8");\r
-      } catch (UnsupportedEncodingException e) {      \r
-        e.printStackTrace();\r
-        return "<applicationerror><error>unsupported encoding</error></applicationerror>";\r
-      }\r
-    }\r
-  }\r
-\r
-  @Override\r
-  public byte[] getBytes() {    \r
-    return content;\r
-  }\r
-\r
-  @Override\r
-  public boolean isBinary() {\r
-    // TODO Auto-generated method stub\r
-    return false;\r
-  }\r
-\r
-}\r