Example usage for javax.servlet.http HttpServletResponse SC_SERVICE_UNAVAILABLE

List of usage examples for javax.servlet.http HttpServletResponse SC_SERVICE_UNAVAILABLE

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletResponse SC_SERVICE_UNAVAILABLE.

Prototype

int SC_SERVICE_UNAVAILABLE

To view the source code for javax.servlet.http HttpServletResponse SC_SERVICE_UNAVAILABLE.

Click Source Link

Document

Status code (503) indicating that the HTTP server is temporarily overloaded, and unable to handle the request.

Usage

From source file:org.opencastproject.capture.admin.endpoint.CaptureAgentStateRestService.java

@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("agents/{name}.{format:xml|json}")
@RestQuery(name = "getAgent", description = "Return the state of a given capture agent", pathParameters = {
        @RestParameter(name = "name", description = "The name of a given capture agent", isRequired = true, type = RestParameter.Type.STRING),
        @RestParameter(name = "format", description = "The output format (json or xml) of the response body.", isRequired = true, type = RestParameter.Type.STRING) }, restParameters = {}, reponses = {
                @RestResponse(description = "{agentState}", responseCode = HttpServletResponse.SC_OK),
                @RestResponse(description = "The agent {agentName} does not exist", responseCode = HttpServletResponse.SC_NOT_FOUND),
                @RestResponse(description = "If the {format} is not xml or json", responseCode = HttpServletResponse.SC_METHOD_NOT_ALLOWED),
                @RestResponse(description = "If no capture agent state service is available", responseCode = HttpServletResponse.SC_SERVICE_UNAVAILABLE) }, returnDescription = "")
public Response getAgentState(@PathParam("name") String agentName, @PathParam("format") String format)
        throws NotFoundException {
    if (service == null)
        return Response.serverError().status(Response.Status.SERVICE_UNAVAILABLE).build();

    Agent ret = service.getAgent(agentName);
    logger.debug("Returning agent state for {}", agentName);
    if ("json".equals(format)) {
        return Response.ok(new AgentStateUpdate(ret)).type(MediaType.APPLICATION_JSON).build();
    } else {// ww  w .  j a v a  2 s  . com
        return Response.ok(new AgentStateUpdate(ret)).type(MediaType.APPLICATION_XML).build();
    }
}

From source file:org.pentaho.test.platform.web.GetResourceIT.java

@Test
public void testParentPath() throws ServletException, IOException {
    when(request.getParameter(RESOURCE_PARAM)).thenReturn("../some_file.jar");

    servlet.service(request, response);/* w w  w  .  java  2  s. c  o m*/

    verify(response).setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
    verify(servlet).error(matches(".*ERROR_0001.*"));
}

From source file:org.projectforge.business.teamcal.servlet.CalendarAboServlet.java

@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp)
        throws ServletException, IOException {
    if (ProjectForgeApp.getInstance().isUpAndRunning() == false) {
        log.error(//from  www .  j  a v  a  2s .c  o m
                "System isn't up and running, CalendarFeed call denied. The system is may-be in start-up phase or in maintenance mode.");
        resp.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
        return;
    }
    PFUserDO user = null;
    String logMessage = null;
    try {
        MDC.put("ip", (Object) req.getRemoteAddr());
        MDC.put("session", (Object) req.getSession().getId());
        if (StringUtils.isBlank(req.getParameter("user")) || StringUtils.isBlank(req.getParameter("q"))) {
            resp.sendError(HttpStatus.SC_BAD_REQUEST);
            log.error("Bad request, parameters user and q not given. Query string is: " + req.getQueryString());
            return;
        }
        final String encryptedParams = req.getParameter("q");
        final Integer userId = NumberHelper.parseInteger(req.getParameter("user"));
        if (userId == null) {
            log.error("Bad request, parameter user is not an integer: " + req.getQueryString());
            return;
        }
        user = TenantRegistryMap.getInstance().getTenantRegistry().getUserGroupCache().getUser(userId);
        if (user == null) {
            log.error("Bad request, user not found: " + req.getQueryString());
            return;
        }
        ThreadLocalUserContext.setUser(getUserGroupCache(), user);
        MDC.put("user", (Object) user.getUsername());
        final String decryptedParams = userService.decrypt(userId, encryptedParams);
        if (decryptedParams == null) {
            log.error(
                    "Bad request, can't decrypt parameter q (may-be the user's authentication token was changed): "
                            + req.getQueryString());
            return;
        }
        final Map<String, String> params = StringHelper.getKeyValues(decryptedParams, "&");
        final Calendar calendar = createCal(params, userId, params.get("token"),
                params.get(CalendarFeedConst.PARAM_NAME_TIMESHEET_USER));
        final StringBuffer buf = new StringBuffer();
        boolean first = true;
        for (final Map.Entry<String, String> entry : params.entrySet()) {
            if ("token".equals(entry.getKey()) == true) {
                continue;
            }
            first = StringHelper.append(buf, first, entry.getKey(), ", ");
            buf.append("=").append(entry.getValue());
        }
        logMessage = buf.toString();
        log.info("Getting calendar entries for: " + logMessage);

        if (calendar == null) {
            resp.sendError(HttpStatus.SC_BAD_REQUEST);
            log.error("Bad request, can't find calendar.");
            return;
        }

        resp.setContentType("text/calendar");
        final CalendarOutputter output = new CalendarOutputter(false);
        try {
            output.output(calendar, resp.getOutputStream());
        } catch (final ValidationException ex) {
            ex.printStackTrace();
        }
    } finally {
        log.info("Finished request: " + logMessage);
        ThreadLocalUserContext.setUser(getUserGroupCache(), null);
        MDC.remove("ip");
        MDC.remove("session");
        if (user != null) {
            MDC.remove("user");
        }
    }
}

From source file:org.rhq.enterprise.gui.startup.StartupServlet.java

/**
 * This merely returns an HTTP status code to indicate the status of the startup.
 * Under normal conditions, this will always return a 200 status code.
 *///from www  .  j av  a 2 s.  com
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    resp.setHeader("Cache-Control", "no-cache, no-store");
    resp.setHeader("Expires", "-1");
    resp.setHeader("Pragma", "no-cache");
    resp.setStatus(initialized ? HttpServletResponse.SC_OK : HttpServletResponse.SC_SERVICE_UNAVAILABLE);
}

From source file:org.pentaho.test.platform.web.GetResourceIT.java

@Test
public void testFileNotExist() throws ServletException, IOException {
    when(request.getParameter(RESOURCE_PARAM)).thenReturn("not_exist.xsl");

    servlet.service(request, response);/*from   ww  w. ja va  2s .  co  m*/

    verify(response).setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
    verify(servlet).error(matches(".*ERROR_0003.*"));
}

From source file:nl.surfnet.mujina.spring.RealAuthenticationFailureHandler.java

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authenticationException) throws IOException, ServletException {
    logger.debug("commencing RealAuthenticationFailureHandler because of {}",
            authenticationException.getClass());

    AuthnRequestInfo authnRequestInfo = (AuthnRequestInfo) request.getSession()
            .getAttribute(AuthnRequestInfo.class.getName());

    if (authnRequestInfo == null) {
        logger.warn(//from  w w w. ja v  a2 s .c  o  m
                "Could not find AuthnRequestInfo on the request.  Delegating to nonSSOAuthnFailureHandler.");
        nonSSOAuthnFailureHandler.onAuthenticationFailure(request, response, authenticationException);
        return;
    }

    logger.debug("AuthnRequestInfo is {}", authnRequestInfo);

    request.getSession().setAttribute(WebAttributes.AUTHENTICATION_EXCEPTION, authenticationException);

    CriteriaSet criteriaSet = new CriteriaSet();
    criteriaSet.add(new EntityIDCriteria(idpConfiguration.getEntityID()));
    criteriaSet.add(new UsageCriteria(UsageType.SIGNING));

    Credential signingCredential = null;
    try {
        signingCredential = credentialResolver.resolveSingle(criteriaSet);
    } catch (org.opensaml.xml.security.SecurityException e) {
        logger.warn("Unable to resolve signing credential for entityId", e);
        return;
    }
    Validate.notNull(signingCredential);

    AuthnResponseGenerator authnResponseGenerator = new AuthnResponseGenerator(signingCredential,
            idpConfiguration.getEntityID(), timeService, idService, idpConfiguration);
    EndpointGenerator endpointGenerator = new EndpointGenerator();

    String acsEndpointURL = authnRequestInfo.getAssertionConsumerURL();
    if (idpConfiguration.getAcsEndpoint() != null) {
        acsEndpointURL = idpConfiguration.getAcsEndpoint().getUrl();
    }

    Response authResponse = authnResponseGenerator.generateAuthnResponseFailure(acsEndpointURL,
            authnRequestInfo.getAuthnRequestID(), authenticationException);
    Endpoint endpoint = endpointGenerator.generateEndpoint(AssertionConsumerService.DEFAULT_ELEMENT_NAME,
            acsEndpointURL, null);

    request.getSession().removeAttribute(AuthnRequestInfo.class.getName());

    String relayState = request.getParameter("RelayState");
    try {
        bindingAdapter.sendSAMLMessage(authResponse, endpoint, response, relayState, signingCredential);
    } catch (MessageEncodingException mee) {
        logger.error("Exception encoding SAML message", mee);
        response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
    }
}

From source file:com.alfaariss.oa.OAServlet.java

/**
 * Process HTTP requests./*  w  w  w .  j a va 2  s .  co  m*/
 * 
 * Retrieve an enabled requestor profile or helper for the given request 
 * and delegate the request using the following algorithm:
 * 
 * <dl>
 *  <dt>type (helper or profile)</dt>
 *  <dd>{@link HttpServletRequest#getRequestURI()} from 
 *      {@link HttpServletRequest#getContextPath()} till '/' minus slashes</dd>
 *  <dt>id of helper or profile</dt>
 *  <dd>{@link HttpServletRequest#getRequestURI()} 
 *      first '/' till second '/' minus slashes</dd>
 * </dl>
 * 
 * @see javax.servlet.http.HttpServlet#service(
 *  javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
public void service(HttpServletRequest oRequest, HttpServletResponse oResponse)
        throws ServletException, IOException {
    try {
        String sRequestURI = oRequest.getRequestURI();

        //Check if profiles are available
        if (_profiles.isEmpty() && _helpers.isEmpty())
            oResponse.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, sRequestURI);

        //Retrieve profile
        String sContextPath = oRequest.getContextPath();
        String sServletPath = oRequest.getServletPath();

        //type = uri  - context
        String sType = sRequestURI.substring(sContextPath.length());
        if (sType.length() <= 1) {
            //No profile or helper requested
            oResponse.sendError(HttpServletResponse.SC_BAD_REQUEST);
        } else {
            //type minus slashes 
            sType = sType.substring(1, sType.length());
            int index = sType.indexOf('/');
            if (index <= 1) {
                _logger.debug("Bad request: no id in path: " + sServletPath);
                //No id requested
                oResponse.sendError(HttpServletResponse.SC_BAD_REQUEST);
            } else {

                String sId = sType.substring(index + 1, sType.length()); //id minus slashes 
                sType = sType.substring(0, index);
                if (_logger.isDebugEnabled())
                    _logger.debug("Processing: " + sType + " request");

                //sId = sId.substring(1, sId.length());
                index = sId.indexOf('/');
                if (index > 0) {
                    //remove suffix
                    sId = sId.substring(0, index);
                }

                try {
                    ServiceTypes type = ServiceTypes.valueOf(sType);
                    switch (type) {
                    case helpers: {
                        IHelper helper = _helpers.get(sId);
                        if (helper == null || !(helper instanceof IService))
                            oResponse.sendError(HttpServletResponse.SC_NOT_FOUND, sRequestURI);
                        else if (!helper.isEnabled())
                            oResponse.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, sRequestURI);
                        else
                            ((IService) helper).service(oRequest, oResponse);
                        break;
                    }
                    case profiles: {
                        IRequestorProfile profile = _profiles.get(sId);
                        if (profile == null || !(profile instanceof IService))
                            oResponse.sendError(HttpServletResponse.SC_NOT_FOUND, sRequestURI);
                        else
                            ((IService) profile).service(oRequest, oResponse);
                        break;
                    }
                    }
                } catch (IllegalArgumentException e) {
                    _logger.debug("Bad request", e);
                    //Invalid type requested
                    oResponse.sendError(HttpServletResponse.SC_BAD_REQUEST);
                } catch (NullPointerException e) {
                    _logger.debug("Bad request", e);
                    //No type requested
                    oResponse.sendError(HttpServletResponse.SC_BAD_REQUEST);
                }
            }
        }

        //send okay if no response is sent yet
        if (!oResponse.isCommitted())
            oResponse.sendError(HttpServletResponse.SC_OK);
    } catch (OAException e) {
        _logger.error("Could not process request", e);
        if (!oResponse.isCommitted())
            oResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } catch (Exception e) {
        _logger.fatal("Could not process request due to internal error", e);
        if (!oResponse.isCommitted())
            oResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
}

From source file:org.openrepose.filters.authz.RequestAuthorizationHandler.java

@Override
public FilterDirector handleRequest(HttpServletRequest request, ReadableHttpServletResponse response) {
    final FilterDirector myDirector = new FilterDirectorImpl();
    myDirector.setFilterAction(FilterAction.RETURN);
    myDirector.setResponseStatusCode(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    String message = "Failure in authorization component";

    final String tracingHeader = request.getHeader(CommonHttpHeader.TRACE_GUID.toString());
    final String authenticationToken = request.getHeader(CommonHttpHeader.AUTH_TOKEN.toString());

    try {/*from w  ww  .ja v a2  s  .c o  m*/
        if (StringUtilities.isBlank(authenticationToken)) {
            // Reject if no token
            message = "Authentication token not found in X-Auth-Token header. Rejecting request.";
            LOG.debug(message);
            myDirector.setResponseStatusCode(HttpServletResponse.SC_UNAUTHORIZED);
        } else if (adminRoleMatchIgnoringCase(request.getHeaders(OpenStackServiceHeader.ROLES.toString()))
                || isEndpointAuthorizedForToken(authenticationToken, tracingHeader)) {
            myDirector.setFilterAction(FilterAction.PASS);
        } else {
            message = "User token: " + authenticationToken
                    + ": The user's service catalog does not contain an endpoint that matches "
                    + "the endpoint configured in openstack-authorization.cfg.xml: \""
                    + configuredEndpoint.getHref() + "\".  User not authorized to access service.";
            LOG.info(message);
            myDirector.setResponseStatusCode(HttpServletResponse.SC_FORBIDDEN);
        }
    } catch (AuthServiceOverLimitException ex) {
        LOG.error(message);
        LOG.trace("", ex);
        myDirector.setResponseStatusCode(HttpServletResponse.SC_SERVICE_UNAVAILABLE); // (503)
        String retry = ex.getRetryAfter();
        if (retry == null) {
            Calendar retryCalendar = new GregorianCalendar();
            retryCalendar.add(Calendar.SECOND, 5);
            retry = new HttpDate(retryCalendar.getTime()).toRFC1123();
        }
        myDirector.responseHeaderManager().appendHeader(HttpHeaders.RETRY_AFTER, retry);
    } catch (AuthServiceException ex) {
        LOG.error(message);
        LOG.trace("", ex);
        if (ex.getCause() instanceof AkkaServiceClientException
                && ex.getCause().getCause() instanceof TimeoutException) {
            myDirector.setResponseStatusCode(HttpServletResponse.SC_GATEWAY_TIMEOUT);
        } else {
            myDirector.setResponseStatusCode(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        }
    } catch (Exception ex) {
        LOG.error(message);
        LOG.trace("", ex);
        myDirector.setResponseStatusCode(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }

    if (delegating != null && myDirector.getFilterAction() != FilterAction.PASS) {
        myDirector.setFilterAction(FilterAction.PASS);
        for (Map.Entry<String, List<String>> mapHeaders : JavaDelegationManagerProxy
                .buildDelegationHeaders(myDirector.getResponseStatusCode(), CLIENT_AUTHORIZATION, message,
                        delegating.getQuality())
                .entrySet()) {
            List<String> value = mapHeaders.getValue();
            myDirector.requestHeaderManager().appendHeader(mapHeaders.getKey(),
                    value.toArray(new String[value.size()]));
        }
    }
    return myDirector;
}

From source file:org.daxplore.presenter.server.servlets.AdminUploadServlet.java

@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) {
    try {//from   w ww .j a va 2  s  .c  o  m
        long time = System.nanoTime();
        int statusCode = HttpServletResponse.SC_OK;
        response.setContentType("text/html; charset=UTF-8");

        ServletFileUpload upload = new ServletFileUpload();
        PersistenceManager pm = null;
        String prefix = null;
        try {
            FileItemIterator fileIterator = upload.getItemIterator(request);
            String fileName = "";
            byte[] fileData = null;
            while (fileIterator.hasNext()) {
                FileItemStream item = fileIterator.next();
                try (InputStream stream = item.openStream()) {
                    if (item.isFormField()) {
                        if (item.getFieldName().equals("prefix")) {
                            prefix = Streams.asString(stream);
                        } else {
                            throw new BadRequestException("Form contains extra fields");
                        }
                    } else {
                        fileName = item.getName();
                        fileData = IOUtils.toByteArray(stream);
                    }
                }
            }
            if (SharedResourceTools.isSyntacticallyValidPrefix(prefix)) {
                if (fileData != null && !fileName.equals("")) {
                    pm = PMF.get().getPersistenceManager();
                    unzipAll(pm, prefix, fileData);
                } else {
                    throw new BadRequestException("No file uploaded");
                }
            } else {
                throw new BadRequestException("Request made with invalid prefix: '" + prefix + "'");
            }
            logger.log(Level.INFO, "Unpacked new data for prefix '" + prefix + "' in "
                    + ((System.nanoTime() - time) / 1000000000.0) + " seconds");
        } catch (FileUploadException | IOException | BadRequestException e) {
            logger.log(Level.WARNING, e.getMessage(), e);
            statusCode = HttpServletResponse.SC_BAD_REQUEST;
        } catch (InternalServerException e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
            statusCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
        } catch (DeadlineExceededException e) {
            logger.log(Level.SEVERE, "Timeout when uploading new data for prefix '" + prefix + "'", e);
            // the server is currently unavailable because it is overloaded (hopefully)
            statusCode = HttpServletResponse.SC_SERVICE_UNAVAILABLE;
        } finally {
            if (pm != null) {
                pm.close();
            }
        }

        response.setStatus(statusCode);
        try (PrintWriter resWriter = response.getWriter()) {
            if (resWriter != null) {
                resWriter.write(Integer.toString(statusCode));
                resWriter.close();
            }
        }
    } catch (IOException | RuntimeException e) {
        logger.log(Level.SEVERE, "Unexpected exception: " + e.getMessage(), e);
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
}

From source file:org.apache.servicemix.http.processors.ConsumerProcessor.java

public void process(HttpServletRequest request, HttpServletResponse response) throws Exception {
    if (log.isDebugEnabled()) {
        log.debug("Receiving HTTP request: " + request);
    }/* www .ja  v a  2 s  . c  om*/
    if ("GET".equals(request.getMethod())) {
        processGetRequest(request, response);
        return;
    }
    if (!started) {
        response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "Endpoint is stopped");
        return;
    }
    if (!"POST".equals(request.getMethod())) {
        response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, request.getMethod() + " not supported");
        return;
    }
    // Not giving a specific mutex will synchronize on the contination itself
    Continuation cont = ContinuationSupport.getContinuation(request, null);
    MessageExchange exchange;
    // If the continuation is not a retry
    if (!cont.isPending()) {
        try {
            Context ctx = createContext(request);
            request.setAttribute(Context.class.getName(), ctx);
            exchange = soapHelper.onReceive(ctx);
            exchanges.put(exchange.getExchangeId(), exchange);
            NormalizedMessage inMessage = exchange.getMessage("in");

            Map<String, String> protocolHeaders = new HashMap();
            if (getConfiguration().isWantHeadersFromHttpIntoExchange()) {
                protocolHeaders.putAll(getHeaders(request));
            }
            protocolHeaders.put(AbstractProcessor.HEADER_X_REMOTE_HOST, getClientIp(request));
            inMessage.setProperty(JbiConstants.PROTOCOL_HEADERS, protocolHeaders);
            if (request.getHeader(HEADER_X_CORRELATION_ID) != null) {
                response.addHeader(HEADER_X_CORRELATION_ID, request.getHeader(HEADER_X_CORRELATION_ID));
            }
            String smxInstanceName = System.getProperty(SMX_INSTANCE_NAME_PROPERTY);
            if (smxInstanceName != null) {
                response.addHeader(HEADER_X_POWERED_BY, smxInstanceName);
            } else {
                log.warn(SMX_INSTANCE_NAME_PROPERTY + " property was not set in servicemix.xml file");
            }

            locks.put(exchange.getExchangeId(), cont);
            request.setAttribute(MessageExchange.class.getName(), exchange.getExchangeId());
            synchronized (cont) {
                channel.send(exchange);
                if (log.isDebugEnabled()) {
                    log.debug("Suspending continuation for exchange: " + exchange.getExchangeId());
                }
                boolean result = cont.suspend(suspentionTime);
                exchange = exchanges.remove(exchange.getExchangeId());
                request.removeAttribute(MessageExchange.class.getName());
                if (!result) {
                    locks.remove(exchange.getExchangeId());
                    throw new Exception("Exchange timed out");
                }
            }
        } catch (RetryRequest retry) {
            throw retry;
        } catch (SoapFault fault) {
            sendFault(fault, request, response);
            return;
        } catch (Exception e) {
            sendFault(new SoapFault(e), request, response);
            return;
        }
    } else {
        synchronized (cont) {
            String id = (String) request.getAttribute(MessageExchange.class.getName());
            locks.remove(id);
            exchange = exchanges.remove(id);
            request.removeAttribute(MessageExchange.class.getName());
            // Check if this is a timeout
            if (exchange == null) {
                throw new IllegalStateException("Exchange not found");
            }
            if (log.isDebugEnabled() && request.getHeader(HEADER_X_CORRELATION_ID) != null) {
                String externalCorrelationId = request.getHeader(HEADER_X_CORRELATION_ID);
                String exchangeCorrelationId = (String) exchange.getProperty(JbiConstants.CORRELATION_ID);
                log.debug("Message exchange with correlationId='" + exchangeCorrelationId
                        + "' is correlated with external message exchange with correlationId='"
                        + externalCorrelationId + "'");
            }
            if (!cont.isResumed()) {
                Exception e = new Exception("Exchange timed out: " + exchange.getExchangeId());
                sendFault(new SoapFault(e), request, response);
                return;
            }
        }
    }
    if (exchange.getStatus() == ExchangeStatus.ERROR) {
        if (exchange.getError() != null) {
            throw new Exception(exchange.getError());
        } else {
            throw new Exception("Unknown Error");
        }
    } else if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
        try {
            if (exchange.getFault() != null) {
                processFault(exchange, request, response);
            } else {
                processResponse(exchange, request, response);
            }
        } finally {
            exchange.setStatus(ExchangeStatus.DONE);
            channel.send(exchange);
        }
    } else if (exchange.getStatus() == ExchangeStatus.DONE) {
        // This happens when there is no response to send back
        response.setStatus(HttpServletResponse.SC_ACCEPTED);
    }
}