List of usage examples for javax.servlet.http HttpServletResponse SC_OK
int SC_OK
To view the source code for javax.servlet.http HttpServletResponse SC_OK.
Click Source Link
From source file:com.sun.faban.harness.webclient.Uploader.java
/** * Checks the existence of the runs on the repository. * @param request/* w w w . j a v a 2s.c o m*/ * @param response * @return String * @throws java.io.IOException * @throws javax.servlet.ServletException */ public String checkRuns(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { HashSet<String> duplicateSet = new HashSet<String>(); String host = request.getParameter("host"); String[] runIds = request.getParameterValues("runId"); String[] ts = request.getParameterValues("ts"); for (int r = 0; r < runIds.length; r++) { String runId = runIds[r]; if (checkIfArchived(host + "." + runId)) { //check for runId timestamp String reposTs = getRunIdTimestamp(host + "." + runId, Config.OUT_DIR); if (ts[r].equals(reposTs)) { duplicateSet.add(runId); } } response.setStatus(HttpServletResponse.SC_OK); } request.setAttribute("duplicates", duplicateSet); return "/duplicates.jsp"; }
From source file:nl.dtls.fairdatapoint.api.controller.MetadataControllerTest.java
/** * The default content type is text/turtle, when the accept header is not * set the default content type is served. This test is excepted to pass. * /* ww w. j a v a 2 s.c o m*/ * @throws Exception */ @Test public void noAcceptHeader() throws Exception { MockHttpServletRequest request; MockHttpServletResponse response; Object handler; request = new MockHttpServletRequest(); response = new MockHttpServletResponse(); request.setMethod("GET"); request.setRequestURI("/textmining"); handler = handlerMapping.getHandler(request).getHandler(); handlerAdapter.handle(request, response, handler); assertEquals(HttpServletResponse.SC_OK, response.getStatus()); }
From source file:cz.zcu.kiv.eegdatabase.logic.controller.semantic.SemanticMultiController.java
/** * Generates an ontology document from POJO objects. * This method gives the Jena's output./*from www .ja v a 2 s.com*/ * * @param request * @param response * @return * @throws Exception */ public ModelAndView getOntology(HttpServletRequest request, HttpServletResponse response) throws Exception { log.debug("Controller for transforming POJO object to resources of semantic web"); OutputStream out = null; InputStream is = null; int headerBufferSize = 8096; String syntax = request.getParameter("type"); response.setHeader("Content-Type", "application/rdf+xml"); response.setContentType("application/rdf+xml"); response.setHeader("Content-Disposition", "attachment;filename=eegdatabase.owl"); log.debug("Creating output stream"); response.setStatus(HttpServletResponse.SC_OK); response.setBufferSize(headerBufferSize); out = response.getOutputStream(); log.debug("Generating RDF"); is = semanticFactory.getOntology(syntax); copy(is, out); out.flush(); out.close(); return null; }
From source file:com.ayovel.nian.servlet.UserBaseServlet.java
/** * ??//from w ww .j a va 2 s . c om */ @Override protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String action = request.getParameter(RestConstants.ACTION_PARAM); String userid = request.getParameter(RestConstants.USER_ID); JSONObject json; if (action.equals(RestConstants.USER_LOGIN)) { json = userLogin(request, response); userid = (String) json.get("userid"); response.sendRedirect("mainpage");//? if (StringUtils.isNotEmpty(userid)) { response.sendRedirect("mainpage");//? } } else if (action.equals(RestConstants.USER_REG)) { json = getUserReg(request, response); userid = (String) json.get("userid"); if (StringUtils.isNotEmpty(userid)) { response.sendRedirect("mainpage");//? } } else {//userid? if (StringUtils.isEmpty(userid)) { response.sendRedirect("userlogin");//? } } if (action.equals(RestConstants.USER_HOME)) { json = getUserHome(request, response); } else if (action.equals(RestConstants.USER_INFO)) { json = getUserInfo(request, response); } else { throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0303, RestConstants.ACTION_PARAM, action); } if (json != null) { sendJsonResponse(response, HttpServletResponse.SC_OK, json); } else { response.setStatus(HttpServletResponse.SC_OK); } }
From source file:nl.dtls.fairdatapoint.api.controller.DataAccessorControllerTest.java
/** * The default content type is text/turtle, when the accept header is not * set the default content type is served. This test is excepted to pass. * /*from w w w . j a v a 2s . c o m*/ * @throws Exception */ @Test public void noAcceptHeader() throws Exception { MockHttpServletRequest request; MockHttpServletResponse response; Object handler; request = new MockHttpServletRequest(); response = new MockHttpServletResponse(); request.setMethod("GET"); request.setRequestURI("/textmining/gene-disease-association_lumc/sparql"); handler = handlerMapping.getHandler(request).getHandler(); handlerAdapter.handle(request, response, handler); assertEquals(HttpServletResponse.SC_OK, response.getStatus()); }
From source file:com.google.gwt.benchmark.dashboard.server.servlets.AddBenchmarkResultServlet.java
@Override protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String auth = req.getHeader("auth"); if (!authController.validateAuth(auth)) { resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED); return;/*from w ww. j av a 2 s.c o m*/ } BenchmarkRunJson benchmarkRunJSON = null; String json = null; try { json = IOUtils.toString(req.getInputStream(), "UTF-8"); AutoBean<BenchmarkRunJson> bean = AutoBeanCodex.decode(JsonFactory.get(), BenchmarkRunJson.class, json); benchmarkRunJSON = bean.as(); } catch (Exception e) { logger.log(Level.WARNING, "Can not deserialize JSON", e); if (json != null) { logger.warning(json); } resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); resp.getWriter().write("Can't parse JSON, see App Engine log for details."); return; } try { benchmarkController.addBenchmarkResult(benchmarkRunJSON); resp.setStatus(HttpServletResponse.SC_OK); } catch (Exception e) { logger.log(Level.WARNING, "Can not add benchmark results", e); resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }
From source file:org.dasein.cloud.azure.tests.compute.AzureAffinityGroupSupportTests.java
@Test public void createShouldPostWithCorrectRequest() throws InternalException, CloudException { AffinityGroup expectedResult = AffinityGroup.getInstance(AFFINITY_GROUP_ID, AFFINITY_GROUP_ID, AFFINITY_GROUP_ID, REGION, null); final CloseableHttpResponse responseMock = getHttpResponseMock(getStatusLineMock(HttpServletResponse.SC_OK), null, new Header[] {}); new MockUp<CloseableHttpClient>() { @Mock(invocations = 1)//from www. j av a2s .c o m public CloseableHttpResponse execute(HttpUriRequest request) { assertPost(request, String.format(RESOURCE_AFFINITYGROUPS, ENDPOINT, ACCOUNT_NO)); return responseMock; } }; AffinityGroupCreateOptions options = AffinityGroupCreateOptions.getInstance(AFFINITY_GROUP_ID, AFFINITY_GROUP_ID, REGION); AffinityGroup actualResult = new AzureAffinityGroupSupport(azureMock).create(options); assertReflectionEquals("match fields for affinity group failed", expectedResult, actualResult); }
From source file:de.liedtke.presentation.WebCommand.java
protected void handleSuccess(final String message, final String result) { resp.setStatus(HttpServletResponse.SC_OK); this.result.addSuccess(message); if (result != null) this.result.addResult(result); }
From source file:org.energyos.espi.thirdparty.web.NotificationController.java
@RequestMapping(value = Routes.THIRD_PARTY_NOTIFICATION, method = RequestMethod.POST) public void notification(HttpServletResponse response, InputStream inputStream) throws IOException { BatchList batchList = (BatchList) marshaller.unmarshal(new StreamSource(inputStream)); batchListService.persist(batchList); for (String resourceUri : batchList.getResources()) { doImportAsynchronously(resourceUri); }/*from w w w .ja v a 2 s . co m*/ response.setStatus(HttpServletResponse.SC_OK); }
From source file:net.sf.ehcache.constructs.web.filter.GzipFilter.java
/** * Performs the filtering for a request. *//*from w w w . j a v a 2 s . c o m*/ protected void doFilter(final HttpServletRequest request, final HttpServletResponse response, final FilterChain chain) throws Exception { if (!isIncluded(request) && acceptsEncoding(request, "gzip")) { // Client accepts zipped content if (LOG.isDebugEnabled()) { LOG.debug(request.getRequestURL() + ". Writing with gzip compression"); } // Create a gzip stream final ByteArrayOutputStream compressed = new ByteArrayOutputStream(); final GZIPOutputStream gzout = new GZIPOutputStream(compressed); // Handle the request final GenericResponseWrapper wrapper = new GenericResponseWrapper(response, gzout); chain.doFilter(request, wrapper); wrapper.flush(); gzout.close(); //return on error or redirect code, because response is already committed int statusCode = wrapper.getStatus(); if (statusCode != HttpServletResponse.SC_OK) { return; } //Saneness checks byte[] compressedBytes = compressed.toByteArray(); boolean shouldGzippedBodyBeZero = ResponseUtil.shouldGzippedBodyBeZero(compressedBytes, request); boolean shouldBodyBeZero = ResponseUtil.shouldBodyBeZero(request, wrapper.getStatus()); if (shouldGzippedBodyBeZero || shouldBodyBeZero) { compressedBytes = new byte[0]; } // Write the zipped body ResponseUtil.addGzipHeader(response); response.setContentLength(compressedBytes.length); response.getOutputStream().write(compressedBytes); } else { // Client does not accept zipped content - don't bother zipping if (LOG.isDebugEnabled()) { LOG.debug(request.getRequestURL() + ". Writing without gzip compression because the request does not accept gzip."); } chain.doFilter(request, response); } }