class StubResponseGenerator {

    public byte[] generateResponse(final HttpServletRequest req, final HttpServletResponse resp) {
        String wilmaLoggerId = req.getHeader(WilmaHttpRequest.WILMA_LOGGER_ID);
        byte[] result = null;
        if (wilmaLoggerId != null) {
            ResponseDescriptorDTO responseDescriptorDTO = mapBasedResponseDescriptorAccess.getResponseDescriptor(wilmaLoggerId);
            Set<ResponseFormatterDescriptor> responseFormatterDescriptors = responseDescriptorDTO.getResponseDescriptor().getResponseFormatters();
            //generate pure WilmaHttpRequest
            WilmaHttpRequest wilmaRequest = httpServletRequestTransformer.transformToWilmaHttpRequest(wilmaLoggerId, req, responseDescriptorDTO);
            //add wilma information to response header
            stubResponseHeaderConfigurer.addWilmaInfoToResponseHeader(req, resp, responseDescriptorDTO.getDialogDescriptorName());
            //set headers generate response body
            result = generate(resp, responseDescriptorDTO, responseFormatterDescriptors, wilmaRequest);
        }
        return result;
    }

}