protected ResponseEntity<?> createSuccessfulRedirectToResponse(ShortURL l) {
   HttpHeaders h = new HttpHeaders();
   if (!l.getAdvert()) {
     h.setLocation(URI.create(l.getTarget()));
     return new ResponseEntity<>(h, HttpStatus.valueOf(l.getMode()));
   } else {
     h.setLocation(URI.create(l.getSponsor() + "?hash=" + l.getHash()));
     return new ResponseEntity<>(h, HttpStatus.valueOf(l.getMode()));
   }
 }
 @ExceptionHandler(NotificationAlreadyUpdatedException.class)
 public ResponseEntity<ResponseWrapper> handleException() {
   ResponseWrapper responseWrapper =
       new ResponseWrapperImpl(
           HttpStatus.CONFLICT, RestMessage.ALREADY_UPDATED, RestStatus.FAILURE);
   return new ResponseEntity<>(responseWrapper, HttpStatus.valueOf(responseWrapper.getCode()));
 }
  /**
   * Create a new user
   *
   * @param message containing the new user
   * @return userCreatedMessage with the appropiate data or an error otherwise
   */
  @RequestMapping(
      value = "/approve/{membershipId}",
      method = RequestMethod.PUT,
      consumes = "application/json")
  @ResponseBody
  public ResponseEntity<Object> approveMembership(
      @RequestHeader("Authorization") String token,
      @RequestHeader("If-Unmodified-Since") String since,
      @PathVariable(value = "membershipId") String uid,
      UriComponentsBuilder builder,
      HttpServletRequest req) {

    HttpHeaders headers = new HttpHeaders();
    Collection<String> cred = new LinkedList<String>();
    cred.add(token);
    try {
      // This method just authenticates... it doesn't do access control
      Collection<IPrincipal> principals = authenticator.authenticatePrincipals(LOG, cred);
      MembershipResponseMessage res =
          (MembershipResponseMessage)
              membershipService.updateEntity(new ApproveMembershipEvent(uid, principals, since));

      return new ResponseEntity<Object>(res, headers, HttpStatus.OK);
    } catch (IdManagementException idm) {
      // since the creation of the exception generated the log entries for the stacktrace, we don't
      // do it again here
      return new ResponseEntity<Object>(
          idm.getErrorAsMap(), headers, HttpStatus.valueOf(idm.getHTTPErrorCode()));
    } catch (Exception e) {
      String s = IdManagementException.getStackTrace(e);
      LOG.error(s);
      return new ResponseEntity<Object>(null, headers, HttpStatus.INTERNAL_SERVER_ERROR);
    }
  }
  @Override
  protected void doFilterInternal(
      HttpServletRequest request, HttpServletResponse response, FilterChain chain)
      throws ServletException, IOException {

    long start = System.currentTimeMillis();
    try {
      log.info(
          "Request: {} {}",
          request.getMethod(),
          request.getQueryString() == null
              ? request.getRequestURI()
              : request.getRequestURI() + "?" + request.getQueryString());
      log.info("Remote host: {} {}", request.getRemoteAddr(), request.getHeader("X-Forwarded-For"));
      log.info("User-Agent: {}", request.getHeader("User-Agent"));

      chain.doFilter(request, response);

    } finally {
      HttpStatus status = HttpStatus.valueOf(response.getStatus());
      log.info(
          "{} {}, in {}ms",
          status.value(),
          status.getReasonPhrase(),
          System.currentTimeMillis() - start);
    }
  }
 public String getStatusText() throws IOException {
   try {
     return this.connection.getResponseMessage();
   } catch (IOException ex) {
     return HttpStatus.valueOf(handleIOException(ex)).getReasonPhrase();
   }
 }
 private boolean is4xxClientError(int status) {
   try {
     return HttpStatus.valueOf(status).is4xxClientError();
   } catch (Exception ex) {
     return false;
   }
 }
 @Override
 protected void doFilterInternal(
     HttpServletRequest request, HttpServletResponse response, FilterChain chain)
     throws ServletException, IOException {
   UrlPathHelper helper = new UrlPathHelper();
   String suffix = helper.getPathWithinApplication(request);
   StopWatch stopWatch = new StopWatch();
   stopWatch.start();
   try {
     chain.doFilter(request, response);
   } finally {
     stopWatch.stop();
     int status = getStatus(response);
     Object bestMatchingPattern =
         request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
     HttpStatus httpStatus = HttpStatus.OK;
     try {
       httpStatus = HttpStatus.valueOf(status);
     } catch (Exception ex) {
       // not convertible
     }
     if (bestMatchingPattern != null) {
       suffix = bestMatchingPattern.toString().replaceAll("[{}]", "-");
     } else if (httpStatus.is4xxClientError()) {
       suffix = UNKNOWN_PATH_SUFFIX;
     }
     String gaugeKey = getKey("response" + suffix);
     MetricFilterAutoConfiguration.this.gaugeService.submit(
         gaugeKey, stopWatch.getTotalTimeMillis());
     String counterKey = getKey("status." + status + suffix);
     MetricFilterAutoConfiguration.this.counterService.increment(counterKey);
   }
 }
  @RequestMapping(value = "/{membershipId}", method = RequestMethod.DELETE)
  @ResponseStatus(HttpStatus.OK)
  @ResponseBody
  public ResponseEntity<Object> DeteMembership(
      @RequestHeader("Authorization") String token,
      @RequestHeader("If-Unmodified-Since") long lastKnownUpdate,
      @PathVariable(value = "membershipId") String uid) {

    HttpHeaders headers = new HttpHeaders();
    Collection<String> cred = new LinkedList<String>();
    cred.add(token);
    try {

      Collection<IPrincipal> principals = authenticator.authenticatePrincipals(LOG, cred);
      membershipService.deleteEntity(
          new DeleteUserMembershipEvent(uid, principals, lastKnownUpdate));
      return new ResponseEntity<Object>(null, headers, HttpStatus.OK);

    } catch (IdManagementException idm) {
      // since the creation of the exception generated the log entries for the stacktrace, we don't
      // do it again here
      return new ResponseEntity<Object>(
          idm.getErrorAsMap(), headers, HttpStatus.valueOf(idm.getHTTPErrorCode()));
    } catch (Exception e) {
      String s = IdManagementException.getStackTrace(e);
      LOG.error(s);
      return new ResponseEntity<Object>(null, headers, HttpStatus.INTERNAL_SERVER_ERROR);
    }
  }
 protected void checkResponse(TumblrResponse tumblrResponse) {
   HttpStatus httpStatus = HttpStatus.valueOf(tumblrResponse.getStatus());
   if (httpStatus.series() == HttpStatus.Series.CLIENT_ERROR) {
     throw new HttpClientErrorException(httpStatus, tumblrResponse.getMessage());
   } else if (httpStatus.series() == HttpStatus.Series.SERVER_ERROR) {
     throw new HttpServerErrorException(httpStatus, tumblrResponse.getMessage());
   }
 }
 private ResponseEntity toJsonErrorResponse(
     int httpCode, String eMessage) { // todo move to JsonRestUtils
   HttpHeaders headers = new HttpHeaders();
   MediaType mediaType = new MediaType("application", "json", Charset.forName("UTF-8"));
   headers.setContentType(mediaType);
   headers.set("Reason", eMessage);
   return new ResponseEntity<>(headers, HttpStatus.valueOf(httpCode));
 }
Exemple #11
0
  // 스케줄러 상태
  // http://localhost:8080/sda/sch/status
  @RequestMapping(value = "/status", method = RequestMethod.GET)
  public @ResponseBody ResponseEntity<ResponseMessage> statusSchList() {
    ResponseMessage resultMsg = new ResponseMessage();
    ResponseEntity<ResponseMessage> entity = null;
    HttpHeaders responseHeaders = new HttpHeaders();
    Gson gson = new Gson();
    String msg = "";

    log.info("status sch begin================>");
    try {
      checkScheduerMainService();
      thm.statusSchList();
      msg = thm.getStatusList();

      resultMsg.setCode(Utils.OK_CODE);
      resultMsg.setMessage(Utils.OK_MSG);
      resultMsg.setContent(gson.toJson(msg));
      entity = new ResponseEntity<ResponseMessage>(resultMsg, responseHeaders, HttpStatus.OK);
    } catch (PersistenceException e) {
      msg = "db connection error...";
      resultMsg = Utils.makeResponseBody(e);
      resultMsg.setContent(gson.toJson(msg));
      entity =
          new ResponseEntity<ResponseMessage>(
              resultMsg, responseHeaders, HttpStatus.valueOf(resultMsg.getCode()));
    } catch (NullPointerException e) {
      msg = "scheduler is not initiated....";
      resultMsg = Utils.makeResponseBody(e);
      resultMsg.setContent(gson.toJson(msg));
      entity =
          new ResponseEntity<ResponseMessage>(
              resultMsg, responseHeaders, HttpStatus.valueOf(resultMsg.getCode()));
    } catch (Exception e) {
      e.printStackTrace();
      resultMsg = Utils.makeResponseBody(e);
      responseHeaders.add("ExceptionCause", e.getMessage());
      responseHeaders.add("ExceptionClass", e.getClass().getName());
      entity =
          new ResponseEntity<ResponseMessage>(
              resultMsg, responseHeaders, HttpStatus.valueOf(resultMsg.getCode()));
    }
    log.info("status sch end ================>");
    return entity;
  }
 private HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOException {
   HttpStatus statusCode;
   try {
     statusCode = response.getStatusCode();
   } catch (IllegalArgumentException ex) {
     throw new HttpServerErrorException(
         HttpStatus.valueOf(response.getRawStatusCode()), response.getStatusText());
   }
   return statusCode;
 }
  private <T> ResponseEntity<T> createResponse(Class<T> clazz, Object instance, Response response) {

    MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
    for (String key : response.headers().keySet()) {
      headers.put(key, new LinkedList<>(response.headers().get(key)));
    }

    return new ResponseEntity<T>(
        clazz.cast(instance), headers, HttpStatus.valueOf(response.status()));
  }
 private HttpStatus getStatus(HttpServletRequest request) {
   Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code");
   if (statusCode != null) {
     try {
       return HttpStatus.valueOf(statusCode);
     } catch (Exception ex) {
     }
   }
   return HttpStatus.INTERNAL_SERVER_ERROR;
 }
 @RequestMapping
 public ResponseEntity<ApiError> handleErrorPage(
     @RequestParam("errorCode") String errorCode, WebRequest request) {
   HttpStatus httpStatus =
       HttpStatus.valueOf(
           (Integer)
               request.getAttribute(
                   RequestDispatcher.ERROR_STATUS_CODE, RequestAttributes.SCOPE_REQUEST));
   ApiError apiError =
       apiErrorCreator.createApiError(request, errorCode, httpStatus.getReasonPhrase());
   return new ResponseEntity<>(apiError, httpStatus);
 }
 private String getExceptionMessage(Throwable throwable, Integer statusCode) {
   if (throwable != null) {
     return Throwables.getRootCause(throwable).getMessage();
   }
   logger.info("statusCode : " + statusCode);
   if (statusCode != null) {
     HttpStatus httpStatus = HttpStatus.valueOf(statusCode);
     return httpStatus.getReasonPhrase();
   } else {
     return "";
   }
 }
Exemple #17
0
  // 스케쥴러 기동
  // http://localhost:8080/sda/sch/init
  @RequestMapping(value = "/init", method = RequestMethod.GET)
  public @ResponseBody ResponseEntity<ResponseMessage> inittSch() {
    ResponseMessage resultMsg = new ResponseMessage();
    ResponseEntity<ResponseMessage> entity = null;
    HttpHeaders responseHeaders = new HttpHeaders();
    Gson gson = new Gson();
    String msg = "";

    log.info("init sch begin================>");
    try {
      // init
      thm = new SchedulerMainService();
      thm.JobInit();
      msg = thm.getStatusList();

      resultMsg.setCode(Utils.OK_CODE);
      resultMsg.setMessage(Utils.OK_MSG);
      resultMsg.setContent(gson.toJson(msg));
      entity = new ResponseEntity<ResponseMessage>(resultMsg, responseHeaders, HttpStatus.OK);
    } catch (ObjectAlreadyExistsException e) {
      msg = "scheduler is already initiated...";
      resultMsg = Utils.makeResponseBody(e);
      resultMsg.setContent(gson.toJson(msg));
      entity =
          new ResponseEntity<ResponseMessage>(
              resultMsg, responseHeaders, HttpStatus.valueOf(resultMsg.getCode()));
    } catch (Exception e) {
      e.printStackTrace();
      resultMsg = Utils.makeResponseBody(e);
      responseHeaders.add("ExceptionCause", e.getMessage());
      responseHeaders.add("ExceptionClass", e.getClass().getName());
      entity =
          new ResponseEntity<ResponseMessage>(
              resultMsg, responseHeaders, HttpStatus.valueOf(resultMsg.getCode()));
    }
    log.info("init sch end================>");
    return entity;
  }
  public OAuth2AccessToken getToken(String username, String password, String clientId) {
    OAuth2ProtectedResourceDetails resource = getResourceDetails(username, password, clientId);
    AccessTokenRequest request = createAccessTokenRequest(username, password);

    ResourceOwnerPasswordAccessTokenProvider provider =
        createResourceOwnerPasswordAccessTokenProvider();
    try {
      return provider.obtainAccessToken(resource, request);
    } catch (OAuth2AccessDeniedException oauthEx) {
      HttpStatus status = HttpStatus.valueOf(oauthEx.getHttpErrorCode());
      CloudFoundryException cfEx = new CloudFoundryException(status, oauthEx.getMessage());
      cfEx.setDescription(oauthEx.getSummary());
      throw cfEx;
    }
  }
 @RequestMapping(value = "/{cid}", consumes = "application/json", method = RequestMethod.DELETE)
 @Override
 public HttpEntity<ResponseBean> delete(@PathVariable("cid") String entity) throws Exception {
   questionrepo.delete(entity);
   AppAlarm appAlarm = Log.getAlarm("ABSUM128990200");
   ResponseBean responseBean = new ResponseBean(appAlarm);
   responseBean.add("message", String.format(appAlarm.getMessage(), "Question"));
   Log.out.println(
       appAlarm.getAlarmID(),
       runtimeLogInfoHelper.getRequestHeaderBean(),
       "QuestionServiceImpl",
       "delete",
       "Question");
   return new org.springframework.http.ResponseEntity<ResponseBean>(
       responseBean, HttpStatus.valueOf(appAlarm.getAlarmStatus()));
 }
 @RequestMapping(consumes = "application/json", method = RequestMethod.POST)
 @Override
 public HttpEntity<ResponseBean> save(@RequestBody Question entity) throws Exception {
   questionrepo.save(entity);
   AppAlarm appAlarm = Log.getAlarm("ABSUM122990200");
   ResponseBean responseBean = new ResponseBean(appAlarm);
   responseBean.add("message", String.format(appAlarm.getMessage(), "Question"));
   responseBean.add("data", entity);
   Log.out.println(
       appAlarm.getAlarmID(),
       runtimeLogInfoHelper.getRequestHeaderBean(),
       "QuestionServiceImpl",
       "save",
       "Question");
   return new org.springframework.http.ResponseEntity<ResponseBean>(
       responseBean, HttpStatus.valueOf(appAlarm.getAlarmStatus()));
 }
 @RequestMapping(consumes = "application/json", method = RequestMethod.PUT)
 @Override
 public HttpEntity<ResponseBean> update(@RequestBody UserAccessDomain entity) throws Exception {
   userAccessDomainrepo.update(entity);
   AppAlarm appAlarm = Log.getAlarm("null");
   ResponseBean responseBean = new ResponseBean(appAlarm);
   responseBean.add("message", String.format(appAlarm.getMessage(), "UserAccessDomain"));
   responseBean.add("data", entity._getPrimarykey());
   Log.out.println(
       appAlarm.getAlarmID(),
       runtimeLogInfoHelper.getRequestHeaderBean(),
       "UserAccessDomainServiceImpl",
       "update",
       "UserAccessDomain");
   return new org.springframework.http.ResponseEntity<ResponseBean>(
       responseBean, HttpStatus.valueOf(appAlarm.getAlarmStatus()));
 }
 @RequestMapping(value = "/findAll", consumes = "application/json", method = RequestMethod.GET)
 @Override
 public HttpEntity<ResponseBean> findAll() throws Exception {
   java.util.List<com.app.shared.appinsight.health.TestB> lsttestb = testBrepo.findAll();
   AppAlarm appAlarm = Log.getAlarm("AISHI124100200");
   ResponseBean responseBean = new ResponseBean(appAlarm);
   responseBean.add("message", String.format(appAlarm.getMessage(), "TestB"));
   responseBean.add("data", lsttestb);
   Log.out.println(
       appAlarm.getAlarmID(),
       runtimeLogInfoHelper.getRequestHeaderBean(),
       "TestBServiceImpl",
       "findAll",
       "TestB");
   return new org.springframework.http.ResponseEntity<ResponseBean>(
       responseBean, HttpStatus.valueOf(appAlarm.getAlarmStatus()));
 }
 @RequestMapping(value = "/findAll", consumes = "application/json", method = RequestMethod.GET)
 @Override
 public HttpEntity<ResponseBean> findAll() throws Exception {
   java.util.List<com.app.shared.appbasicsetup.usermanagement.Question> lstquestion =
       questionrepo.findAll();
   AppAlarm appAlarm = Log.getAlarm("ABSUM124990200");
   ResponseBean responseBean = new ResponseBean(appAlarm);
   responseBean.add("message", String.format(appAlarm.getMessage(), "Question"));
   responseBean.add("data", lstquestion);
   Log.out.println(
       appAlarm.getAlarmID(),
       runtimeLogInfoHelper.getRequestHeaderBean(),
       "QuestionServiceImpl",
       "findAll",
       "Question");
   return new org.springframework.http.ResponseEntity<ResponseBean>(
       responseBean, HttpStatus.valueOf(appAlarm.getAlarmStatus()));
 }
 @RequestMapping(value = "/findAll", consumes = "application/json", method = RequestMethod.GET)
 @Override
 public HttpEntity<ResponseBean> findAll() throws Exception {
   java.util.List<com.basehr.app.shared.aaaboundedcontext.authentication.UserAccessDomain>
       lstuseraccessdomain = userAccessDomainrepo.findAll();
   AppAlarm appAlarm = Log.getAlarm("null");
   ResponseBean responseBean = new ResponseBean(appAlarm);
   responseBean.add("message", String.format(appAlarm.getMessage(), "UserAccessDomain"));
   responseBean.add("data", lstuseraccessdomain);
   Log.out.println(
       appAlarm.getAlarmID(),
       runtimeLogInfoHelper.getRequestHeaderBean(),
       "UserAccessDomainServiceImpl",
       "findAll",
       "UserAccessDomain");
   return new org.springframework.http.ResponseEntity<ResponseBean>(
       responseBean, HttpStatus.valueOf(appAlarm.getAlarmStatus()));
 }
 @RequestMapping(value = "/findById", method = RequestMethod.POST)
 @Override
 public HttpEntity<ResponseBean> findById(@RequestBody FindByBean findByBean) throws Exception {
   org.springframework.http.HttpStatus httpStatus = org.springframework.http.HttpStatus.OK;
   com.app.shared.appbasicsetup.usermanagement.Question lstquestion =
       questionrepo.findById((java.lang.String) findByBean.getFindKey());
   AppAlarm appAlarm = Log.getAlarm("ABSUM124990200");
   com.athena.server.pluggable.utils.bean.ResponseBean responseBean = new ResponseBean(appAlarm);
   responseBean.add("message", String.format(appAlarm.getMessage(), "Question"));
   responseBean.add("data", lstquestion);
   Log.out.println(
       "ABSUM124990200",
       runtimeLogInfoHelper.getRequestHeaderBean(),
       "QuestionServiceImpl",
       "save",
       "Question");
   return new org.springframework.http.ResponseEntity<ResponseBean>(
       responseBean, HttpStatus.valueOf(appAlarm.getAlarmStatus()));
 }
 @RequestMapping(value = "/findById", method = RequestMethod.POST)
 @Override
 public HttpEntity<ResponseBean> findById(@RequestBody FindByBean findByBean) throws Exception {
   org.springframework.http.HttpStatus httpStatus = org.springframework.http.HttpStatus.OK;
   com.basehr.app.shared.aaaboundedcontext.authentication.UserAccessDomain lstuseraccessdomain =
       userAccessDomainrepo.findById((java.lang.String) findByBean.getFindKey());
   AppAlarm appAlarm = Log.getAlarm("null");
   com.athena.framework.server.bean.ResponseBean responseBean = new ResponseBean(appAlarm);
   responseBean.add("message", String.format(appAlarm.getMessage(), "UserAccessDomain"));
   responseBean.add("data", lstuseraccessdomain);
   Log.out.println(
       "null",
       runtimeLogInfoHelper.getRequestHeaderBean(),
       "UserAccessDomainServiceImpl",
       "save",
       "UserAccessDomain");
   return new org.springframework.http.ResponseEntity<ResponseBean>(
       responseBean, HttpStatus.valueOf(appAlarm.getAlarmStatus()));
 }
 @RequestMapping(
     consumes = "application/json",
     headers = {"isArray"},
     method = RequestMethod.POST)
 @Override
 public HttpEntity<ResponseBean> save(
     @RequestBody List<TestB> entity, @RequestHeader("isArray") boolean request) throws Exception {
   testBrepo.save(entity);
   AppAlarm appAlarm = Log.getAlarm("AISHI122100201");
   ResponseBean responseBean = new ResponseBean(appAlarm);
   responseBean.add("message", String.format(appAlarm.getMessage(), "TestB"));
   Log.out.println(
       appAlarm.getAlarmID(),
       runtimeLogInfoHelper.getRequestHeaderBean(),
       "TestBServiceImpl",
       "save",
       "TestB");
   return new org.springframework.http.ResponseEntity<ResponseBean>(
       responseBean, HttpStatus.valueOf(appAlarm.getAlarmStatus()));
 }
  @RequestMapping(value = ERROR_PATH)
  public ResponseEntity<Map<String, Object>> error(HttpServletRequest request, Locale locale) {
    RequestAttributes requestAttributes = new ServletRequestAttributes(request);
    Map<String, Object> body = errorAttributes.getErrorAttributes(requestAttributes, true);

    HttpStatus status = HttpStatus.INTERNAL_SERVER_ERROR;
    if (Objects.nonNull(body.get("status"))) {
      try {
        status = HttpStatus.valueOf((Integer) body.get("status"));
      } catch (Exception ignore) {
      }
    }

    String message =
        messageSource.getMessage("error." + status, null, ERROR_DEFAULT_MESSAGE, locale);
    if (StringUtils.hasText(message)) {
      body.put("message", message);
    }

    return ResponseEntity.status(status).body(body);
  }
 @RequestMapping(
     consumes = "application/json",
     headers = {"isArray"},
     method = RequestMethod.PUT)
 @Override
 public HttpEntity<ResponseBean> update(
     @RequestBody List<Question> entity, @RequestHeader("isArray") boolean request)
     throws Exception {
   questionrepo.update(entity);
   AppAlarm appAlarm = Log.getAlarm("ABSUM323952200");
   ResponseBean responseBean = new ResponseBean(appAlarm);
   responseBean.add("message", String.format(appAlarm.getMessage(), "Question"));
   Log.out.println(
       appAlarm.getAlarmID(),
       runtimeLogInfoHelper.getRequestHeaderBean(),
       "QuestionServiceImpl",
       "update",
       "Question");
   return new org.springframework.http.ResponseEntity<ResponseBean>(
       responseBean, HttpStatus.valueOf(appAlarm.getAlarmStatus()));
 }
  /**
   * Generates the Http response message from given Spring Integration message.
   *
   * @param responseMessage message received from the message handler
   * @return an HTTP entity as response
   */
  private ResponseEntity<String> generateResponse(Message<?> responseMessage) {
    if (responseMessage == null) {
      return new ResponseEntity<String>(HttpStatus.OK);
    }

    HttpHeaders httpHeaders = new HttpHeaders();
    headerMapper.fromHeaders(responseMessage.getHeaders(), httpHeaders);

    Map<String, ?> messageHeaders = responseMessage.getHeaders();
    for (Entry<String, ?> header : messageHeaders.entrySet()) {
      if (!header.getKey().startsWith(CitrusMessageHeaders.PREFIX)
          && !MessageUtils.isSpringInternalHeader(header.getKey())
          && !httpHeaders.containsKey(header.getKey())) {
        httpHeaders.add(header.getKey(), header.getValue().toString());
      }
    }

    if (httpHeaders.getContentType() == null) {
      httpHeaders.setContentType(
          MediaType.parseMediaType(
              contentType.contains("charset") ? contentType : contentType + ";charset=" + charset));
    }

    HttpStatus status = HttpStatus.OK;
    if (responseMessage.getHeaders().containsKey(CitrusHttpMessageHeaders.HTTP_STATUS_CODE)) {
      status =
          HttpStatus.valueOf(
              Integer.valueOf(
                  responseMessage
                      .getHeaders()
                      .get(CitrusHttpMessageHeaders.HTTP_STATUS_CODE)
                      .toString()));
    }

    responseCache =
        new ResponseEntity<String>(responseMessage.getPayload().toString(), httpHeaders, status);

    return responseCache;
  }