Adds distinction between pz2 and sp errors
[mkjsf-moved-to-github.git] / src / main / java / com / indexdata / mkjsf / pazpar2 / data / ResponseDataObject.java
index 57c17e1..8ffd810 100644 (file)
@@ -19,6 +19,8 @@ public class ResponseDataObject implements Serializable {
   String textContent = "";\r
   CommandError error = null;\r
   String xml = null;\r
+  boolean isBinary = false;\r
+  byte[] binary = null;\r
         \r
   public void setType (String type) {\r
     this.type = type;\r
@@ -106,10 +108,15 @@ public class ResponseDataObject implements Serializable {
     return (CommandError) getOneElement("applicationerror");\r
   }\r
   \r
-  public boolean hasPazpar2Error() {\r
-    return hasApplicationError() && getApplicationError().hasPazpar2Error();\r
+  public boolean hasServiceError() {\r
+    return hasApplicationError() \r
+        && getApplicationError().isServiceError();        \r
   }\r
   \r
+  public ServiceError getServiceError() {\r
+    return (hasServiceError()? getApplicationError().getServiceError() : null);\r
+  }\r
+      \r
   public void setXml(String xml) {\r
     this.xml = xml; \r
   }\r
@@ -122,7 +129,22 @@ public class ResponseDataObject implements Serializable {
   }\r
   \r
   public boolean getHasResults () {\r
-    return (xml != null && xml.length()>0);\r
+    return (xml != null && xml.length()>0) || (getIsBinary() && binary.length>0);\r
+  }\r
+  \r
+  public boolean getIsBinary () {\r
+    return isBinary;\r
+  }\r
+    \r
+  public void setBinary(byte[] bytes) {\r
+    isBinary = true;\r
+    binary = bytes;\r
   }\r
+  \r
+  public byte[] getBinary () {\r
+    return binary;\r
+  }\r
+  \r
+  \r
         \r
 }\r