package org.datacite.mds.web.api;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;

import org.apache.log4j.Logger;

/**
 * This is a wrapper around HttpServletResponse. By default the sendError
 * methods result in a html page generated by tomcat. This wrapper prints only
 * the error message to the response body (and sets the given response code)
 */
public class ApiResponseWrapper extends HttpServletResponseWrapper {

    Logger log = Logger.getLogger(ApiResponseWrapper.class);

    public ApiResponseWrapper(HttpServletResponse response) {
        super(response);
    }

    @Override
    public void sendError(int sc, String msg) throws IOException {
        log.debug("sendError " + sc + ": " + msg);
        setStatus(sc);
        getWriter().println(msg);
    }

    @Override
    public void sendError(int sc) throws IOException {
        log.debug("sendError " + sc);
        sendError(sc, "");
    }

}

@@ -159,16 +159,60 @@
 apper;%0A%0A
+import org.apache.commons.lang.StringUtils;%0A
 import o
@@ -235,16 +235,16 @@
 Logger;%0A
-
 %0A/**%0A * 
@@ -542,16 +542,94 @@
 rapper %7B
+%0A    %0A    static final String NEW_LINE = System.getProperty(%22line.separator%22);
 %0A%0A    Lo
@@ -784,32 +784,32 @@
 %0A%0A    @Override%0A
-
     public void 
@@ -851,32 +851,89 @@
 s IOException %7B%0A
+        msg = StringUtils.replace(msg, NEW_LINE, %22 - %22);%0A
         log.debu

remove line breaks in response messages (closes #105)