package de.terrestris.shogun2.web;

import java.io.IOException;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import de.terrestris.shogun2.service.GeoServerInterceptorService;
import de.terrestris.shogun2.util.data.ResultSet;
import de.terrestris.shogun2.util.model.Response;

/**
 *
 * @author Daniel Koch
 * @author Kai Volland
 * @author terrestris GmbH & Co. KG
 *
 * @param <S>
 */
@Controller
public class GeoServerInterceptorController<S extends GeoServerInterceptorService> {

	/**
	 * The Logger.
	 */
	private static final Logger LOG = Logger.getLogger(
			GeoServerInterceptorController.class);

	/**
	 *
	 */
	protected S service;

	/**
	 *
	 */
	private static final String ERROR_MESSAGE = "Error while requesting a " +
			"GeoServer resource: ";

	/**
	 *
	 * @param request
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/geoserver.action", method = {
			RequestMethod.GET, RequestMethod.POST })
	public ResponseEntity<?> interceptGeoServerRequest(HttpServletRequest request) {

		HttpHeaders responseHeaders = new HttpHeaders();
		HttpStatus responseStatus = HttpStatus.OK;
		byte[] responseBody = null;
		Response httpResponse = null;

		try {

			httpResponse = this.service.interceptGeoServerRequest(request);

			responseStatus = httpResponse.getStatusCode();
			responseBody = httpResponse.getBody();
			responseHeaders = httpResponse.getHeaders();

			return new ResponseEntity<byte[]>(responseBody,
					responseHeaders, responseStatus);

		} catch (Exception e) {
			LOG.error(ERROR_MESSAGE + e.getMessage());

			responseHeaders.setContentType(MediaType.APPLICATION_JSON);

			Map<String, Object> responseMsg = ResultSet.error(
					ERROR_MESSAGE + e.getMessage());

			return new ResponseEntity<Map<String, Object>>(responseMsg,
					responseHeaders, responseStatus);
		}

	}

	/**
	 * @param service the service to set
	 */
	@Autowired
	public void setService(S service) {
		this.service = service;
	}
}

package de.terrestris.shogun2.web;

import java.io.IOException;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import de.terrestris.shogun2.service.GeoServerInterceptorService;
import de.terrestris.shogun2.util.data.ResultSet;
import de.terrestris.shogun2.util.model.Response;

/**
 *
 * @author Daniel Koch
 * @author Kai Volland
 * @author terrestris GmbH & Co. KG
 *
 * @param <S>
 */
@Controller
public class GeoServerInterceptorController<S extends GeoServerInterceptorService> {

	/**
	 * The Logger.
	 */
	private static final Logger LOG = Logger.getLogger(
			GeoServerInterceptorController.class);

	/**
	 *
	 */
	protected S service;

	/**
	 *
	 */
	private static final String ERROR_MESSAGE = "Error while requesting a " +
			"GeoServer resource: ";

	/**
	 *
	 * @param request
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "/geoserver.action", method = {
			RequestMethod.GET, RequestMethod.POST })
	public ResponseEntity<?> interceptGeoServerRequest(HttpServletRequest request) {

		HttpHeaders responseHeaders = new HttpHeaders();
		HttpStatus responseStatus = HttpStatus.OK;
		byte[] responseBody = null;
		Response httpResponse = null;

		try {

			LOG.debug("Trying to intercept a GeoServer resource.");

			httpResponse = this.service.interceptGeoServerRequest(request);

			responseStatus = httpResponse.getStatusCode();
			responseBody = httpResponse.getBody();
			responseHeaders = httpResponse.getHeaders();

			LOG.debug("Successfully intercepted a GeoServer resource.");

			return new ResponseEntity<byte[]>(responseBody,
					responseHeaders, responseStatus);

		} catch (Exception e) {
			LOG.error(ERROR_MESSAGE + e.getMessage());

			responseHeaders.setContentType(MediaType.APPLICATION_JSON);

			Map<String, Object> responseMsg = ResultSet.error(
					ERROR_MESSAGE + e.getMessage());

			return new ResponseEntity<Map<String, Object>>(responseMsg,
					responseHeaders, responseStatus);
		}

	}

	/**
	 * @param service the service to set
	 */
	@Autowired
	public void setService(S service) {
		this.service = service;
	}
}

Add unspectacular logger