Renames project from pz2utils4jsf to mkjsf
[mkjsf-moved-to-github.git] / src / main / java / com / indexdata / pz2utils4jsf / pazpar2 / data / CommandError.java
index 2b5fae2..64080e3 100644 (file)
@@ -4,6 +4,7 @@ import static com.indexdata.pz2utils4jsf.utils.Utils.nl;
 \r
 import java.util.ArrayList;\r
 import java.util.List;\r
+import java.util.regex.Pattern;\r
 \r
 import com.indexdata.pz2utils4jsf.errors.ErrorInterface;\r
 import com.indexdata.pz2utils4jsf.errors.ErrorHelper;\r
@@ -27,6 +28,7 @@ import com.indexdata.utils.XmlUtils;
 public class CommandError extends Pazpar2ResponseData implements ErrorInterface {\r
 \r
   private static final long serialVersionUID = 8878776025779714122L;\r
+  private static Pattern xmlDeclaration = Pattern.compile("<\\?xml.*\\?>");\r
   private ErrorCode applicationErrorCode;\r
   private ErrorHelper errorHelper = null;\r
   \r
@@ -88,8 +90,8 @@ public class CommandError extends Pazpar2ResponseData implements ErrorInterface
    * \r
    * @param commandName The name of the command during which's execution the error was encountered\r
    * @param exceptionName The (possibly loosely defined) name of the exception that was thrown\r
-   * @param pazpar2ErrorXml The error document as created by Pazpar2 -- or, for some errors, by the \r
-   *                        Pazpar2 client. \r
+   * @param pazpar2ErrorXml The error document as created by Pazpar2, or the Service Proxy or \r
+   *                        by the Pazpar2 client itself. \r
    * @return\r
    */\r
   public static String insertPazpar2ErrorXml (String commandName, String exceptionName, String pazpar2ErrorXml) {\r
@@ -98,7 +100,7 @@ public class CommandError extends Pazpar2ResponseData implements ErrorInterface
     errorXml.append(" <applicationerror>"+nl);\r
     errorXml.append("  <commandname>" + commandName + "</commandname>"+nl);\r
     errorXml.append("  <exception>" + XmlUtils.escape(exceptionName) + "</exception>"+nl);    \r
-    errorXml.append(pazpar2ErrorXml+nl);    \r
+    errorXml.append(xmlDeclaration.matcher(pazpar2ErrorXml).replaceAll("")+nl);    \r
     errorXml.append(" </applicationerror>"+nl);\r
     errorXml.append("</" + commandName + ">"+nl);\r
     return errorXml.toString(); \r