PageRenderTime 131ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/resteasy-2.3.2.Final/resteasy-spring/src/main/java/org/jboss/resteasy/springmvc/ResteasyRequestWrapper.java

#
Java | 99 lines | 68 code | 18 blank | 13 comment | 0 complexity | acf9fdd59f61689f6abb6540a0a9641e MD5 | raw file
  1. package org.jboss.resteasy.springmvc;
  2. import org.jboss.resteasy.core.ResourceInvoker;
  3. import org.jboss.resteasy.plugins.server.servlet.HttpServletInputMessage;
  4. import org.jboss.resteasy.plugins.server.servlet.ServletUtil;
  5. import org.jboss.resteasy.spi.HttpRequest;
  6. import javax.servlet.ServletException;
  7. import javax.servlet.http.HttpServletRequest;
  8. import javax.ws.rs.core.HttpHeaders;
  9. import javax.ws.rs.core.UriInfo;
  10. import java.io.IOException;
  11. /**
  12. * @author <a href="mailto:sduskis@gmail.com">Solomn Duskis</a>
  13. * @version $Revision: 1 $
  14. */
  15. public class ResteasyRequestWrapper
  16. {
  17. private HttpRequest httpRequest = null;
  18. private HttpServletRequest httpServletRequest;
  19. private ResourceInvoker invoker;
  20. private Integer errorCode = null;
  21. private String errorMessage;
  22. public ResteasyRequestWrapper(HttpServletRequest request) throws ServletException, IOException
  23. {
  24. this(request, request.getMethod(), "");
  25. }
  26. public ResteasyRequestWrapper(HttpServletRequest request, String httpMethod, String prefix)
  27. throws ServletException, IOException
  28. {
  29. this.httpServletRequest = request;
  30. HttpHeaders headers = ServletUtil.extractHttpHeaders(request);
  31. UriInfo uriInfo = ServletUtil.extractUriInfo(request, prefix);
  32. // TODO: how are we supposed to get the response to create the
  33. // wrapper!!!!? The null response will only make it so that the
  34. // Asynchronous invocations won't work
  35. // HttpServletResponseWrapper theResponse = new
  36. // HttpServletResponseWrapper(httpServletResponse, dispatcher
  37. // TODO: the two nulls are the response and the dispatcher. Those
  38. // are not needed here... They are only needed for asynchronous
  39. // invocations. Suggest Core RESTEasy refactoring to change the
  40. // async invocation
  41. httpRequest = new HttpServletInputMessage(request, null, headers, uriInfo, httpMethod
  42. .toUpperCase(), null);
  43. }
  44. public HttpServletRequest getHttpServletRequest()
  45. {
  46. return httpServletRequest;
  47. }
  48. public HttpRequest getHttpRequest()
  49. {
  50. return httpRequest;
  51. }
  52. public ResourceInvoker getInvoker()
  53. {
  54. return invoker;
  55. }
  56. public void setInvoker(ResourceInvoker invoker)
  57. {
  58. this.invoker = invoker;
  59. }
  60. public Integer getErrorCode()
  61. {
  62. return errorCode;
  63. }
  64. public void setErrorCode(Integer errorCode)
  65. {
  66. this.errorCode = errorCode;
  67. }
  68. public String getErrorMessage()
  69. {
  70. return errorMessage;
  71. }
  72. public void setErrorMessage(String errorMessage)
  73. {
  74. this.errorMessage = errorMessage;
  75. }
  76. public void setError(Integer errorCode, String errorMessage)
  77. {
  78. setErrorCode(errorCode);
  79. setErrorMessage(errorMessage);
  80. }
  81. }