List of usage examples for javax.servlet.http HttpServletResponse equals
public boolean equals(Object obj)
From source file:org.openmrs.module.rheashradapter.web.controller.RHEApatientController.java
@RequestMapping(value = "/identifier", method = RequestMethod.PUT) @ResponseBody// ww w. j ava 2s . co m public ResponseEntity<String> mergePatients(@RequestBody String mergeMessage, HttpServletRequest request, HttpServletResponse response) { Map<String, String> postUpdateIdentifiers = null; Map<String, String> preUpdateIdentifiers = null; HttpSession httpSession = request.getSession(); if (Context.isAuthenticated()) { NodeList node = identifyMessageType(mergeMessage); String typeName = node.item(0).getTextContent(); postUpdateIdentifiers = identifyPostUpdateIdentifiers(mergeMessage); preUpdateIdentifiers = identifyPreUpdateIdentifiers(mergeMessage); if (typeName.equals("JOIN")) { Object httpResponse = mergePatient(postUpdateIdentifiers, preUpdateIdentifiers); response.setStatus((Integer) httpResponse); if (response.equals(HttpServletResponse.SC_OK)) { httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "Patient.merged"); validatePostidentifiers(postUpdateIdentifiers); return new ResponseEntity<String>(HttpStatus.OK); } else { return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); } } else if (typeName.equals("LEAVE")) { Object httpResponse = restorePatient(postUpdateIdentifiers, preUpdateIdentifiers); response.setStatus((Integer) httpResponse); if (response.equals(HttpServletResponse.SC_OK)) { httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "Patient.restored"); validatePostidentifiers(postUpdateIdentifiers); return new ResponseEntity<String>(HttpStatus.OK); } else { return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR); } } } return new ResponseEntity<String>(HttpStatus.FORBIDDEN); }
From source file:org.eclipse.equinox.http.servlet.tests.ServletTest.java
public void basicFilterTest22(String servlet1Pattern, String servlet2Pattern, String filterPattern, String expected, String[] dispatchers) throws Exception { final AtomicReference<HttpServletRequestWrapper> httpServletRequestWrapper = new AtomicReference<HttpServletRequestWrapper>(); final AtomicReference<HttpServletResponseWrapper> httpServletResponseWrapper = new AtomicReference<HttpServletResponseWrapper>(); Servlet servlet1 = new BaseServlet() { private static final long serialVersionUID = 1L; @Override/*from w ww. ja va2s . c o m*/ protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.getRequestDispatcher("index.jsp").forward(request, response); } }; Servlet servlet2 = new BaseServlet("a") { private static final long serialVersionUID = 1L; @Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if ((httpServletRequestWrapper.get() != null) && !request.equals(httpServletRequestWrapper.get())) { throw new ServletException("not the same request"); } if ((httpServletResponseWrapper.get() != null) && !response.equals(httpServletResponseWrapper.get())) { throw new ServletException("not the same response"); } response.getWriter().print(content); } }; Filter filter = new TestFilter() { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { response.getWriter().write('b'); httpServletRequestWrapper.set(new HttpServletRequestWrapper((HttpServletRequest) request)); httpServletResponseWrapper.set(new HttpServletResponseWrapper((HttpServletResponse) response)); chain.doFilter(httpServletRequestWrapper.get(), httpServletResponseWrapper.get()); response.getWriter().write('b'); } }; Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, servlet1Pattern); registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props)); props = new Hashtable<String, Object>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, servlet2Pattern); registrations.add(getBundleContext().registerService(Servlet.class, servlet2, props)); props = new Hashtable<String, Object>(); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_NAME, "F22"); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER, dispatchers); props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, filterPattern); registrations.add(getBundleContext().registerService(Filter.class, filter, props)); String response = requestAdvisor.request("f22/a"); Assert.assertEquals(expected, response); }