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:au.org.ala.biocache.web.AdminController.java
/** * Optimises the SOLR index. Use this API to optimise the index so that the biocache-service * can enter read only mode during this process. * @param request/*from w ww. j a va 2 s.c om*/ * @param response * @throws Exception */ @RequestMapping(value = "/admin/index/optimise", method = RequestMethod.POST) public void optimiseIndex(HttpServletRequest request, HttpServletResponse response) throws Exception { String apiKey = request.getParameter("apiKey"); if (shouldPerformOperation(apiKey, response)) { String message = Store.optimiseIndex(); response.setStatus(HttpServletResponse.SC_OK); response.getWriter().write(message); } }
From source file:mecha.http.servlets.ProcServlet.java
private void writeError(HttpServletResponse response, String errorMsg) throws Exception { response.setContentType("text/html"); response.setStatus(HttpServletResponse.SC_OK); response.getWriter().println("<h1>" + errorMsg + "</h1>"); }
From source file:com.mirantis.cachemod.filter.CacheFilter.java
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException { if (request.getAttribute(conf.getAlreadyFilteredKey()) != null || !isCacheable(request)) { /*//from w ww . ja va 2s . c o m * This request is not Cacheable */ chain.doFilter(request, response); } else { request.setAttribute(conf.getAlreadyFilteredKey(), Boolean.TRUE); HttpServletRequest httpRequest = (HttpServletRequest) request; boolean fragmentRequest = isFragment(httpRequest); String key = conf.getCacheKeyProvider().createKey(httpRequest); CacheEntry cacheEntry = conf.getCacheProvider().getEntry(key); if (cacheEntry != null) { if (!fragmentRequest) { /* * -1 of no in header */ long clientLastModified = httpRequest.getDateHeader("If-Modified-Since"); /* * Reply with SC_NOT_MODIFIED for client that has newest page */ if ((clientLastModified != -1) && (clientLastModified >= cacheEntry.getLastModified())) { ((HttpServletResponse) response).setStatus(HttpServletResponse.SC_NOT_MODIFIED); return; } } writeCacheToResponse(cacheEntry, response, fragmentRequest); } else { cacheEntry = conf.getCacheProvider().instantiateEntry(); CacheHttpServletResponse cacheResponse = new CacheHttpServletResponse( (HttpServletResponse) response, cacheEntry, conf, fragmentRequest); chain.doFilter(request, cacheResponse); if (cacheResponse.getStatus() == HttpServletResponse.SC_OK) { cacheResponse.commit(); if (conf.getUserDataProvider() != null) { cacheEntry.setUserData(conf.getUserDataProvider().createUserData(httpRequest)); } conf.getCacheProvider().putEntry(key, cacheEntry); } } } }
From source file:com.pymegest.applicationserver.api.SessionController.java
@RequestMapping(value = { "/Session" }, method = RequestMethod.GET) public void read(HttpServletRequest httpServletRequest, HttpServletResponse response) { try {/*from w ww . j av a 2 s . c o m*/ Integer idUsuario = (Integer) httpServletRequest.getSession(true).getAttribute("idUduario"); Usuario usuario = usuarioDAO.read(idUsuario); response.setStatus(HttpServletResponse.SC_OK); response.setContentType("application/json; chaset=UTF-8"); ObjectMapper objectMapper = new ObjectMapper(); String json = objectMapper.writeValueAsString(usuario); response.getWriter().println(json); } catch (Exception ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.setContentType("text/plain; charset=UTF-8;"); try { ex.printStackTrace(response.getWriter()); } catch (IOException ex1) { } } }
From source file:cz.zcu.kiv.eegdatabase.logic.controller.semantic.SemanticMultiController.java
/** * Generates an ontology document from POJO objects. * This method transforms the Jena's output using Owl-Api. * * @param request/*from w w w . j av a 2s . co m*/ * @param response * @return * @throws Exception */ public ModelAndView getOntologyOwlApi(HttpServletRequest request, HttpServletResponse response) throws Exception { log.debug("Controller for transforming POJO object to resources of semantic web"); String syntax; OutputStream out = null; InputStream is = null; int headerBufferSize = 8096; 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 OWL"); is = semanticFactory.getOntologyOwlApi(syntax); copy(is, out); out.flush(); out.close(); return null; }
From source file:com.carolinarollergirls.scoreboard.jetty.XmlScoreBoardServlet.java
protected void setDebug(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String get = request.getParameter("get"); String set = request.getParameter("set"); if (null != get) { if (get.equals("1") || get.equalsIgnoreCase("true")) debugGet = true;//from ww w .java2s. c o m else if (get.equals("0") || get.equalsIgnoreCase("false")) debugGet = false; } if (null != set) { if (set.equals("1") || set.equalsIgnoreCase("true")) debugSet = true; else if (set.equals("0") || set.equalsIgnoreCase("false")) debugSet = false; } response.setContentType("text/plain"); response.getWriter().println("Debug /get : " + debugGet); response.getWriter().println("Debug /set : " + debugSet); response.setStatus(HttpServletResponse.SC_OK); }
From source file:hr.diskobolos.controller.SportController.java
/** * REST service responsible for creating sport data * * @param sportDto//from ww w.j a va2 s . c o m * @param request * @param response * @return * @throws JSONException */ @RequestMapping(value = "/create", method = RequestMethod.POST) @ResponseBody @PreAuthorize("hasAnyRole('ROLE_USER','ROLE_ADMIN')") public String createSportData(@RequestBody SportDto sportDto, HttpServletRequest request, HttpServletResponse response) throws JSONException { try { Sport sport = mapSportDtoToSportModelObject(sportDto); sportService.persist(sport); response.setStatus(HttpServletResponse.SC_OK); return new JSONObject().put("result", 200).toString(); } catch (Exception e) { logger.error("Error during creation of sport data: ", e.getMessage()); return ErrorHandlerUtils.handleAjaxError(request, response); } }
From source file:org.eclipse.virgo.samples.rest.RestController.java
@RequestMapping(value = "/users/{userId}/{name}/{invention}", method = RequestMethod.PUT) public void putUser(@PathVariable("userId") String userId, @PathVariable("name") String name, @PathVariable("invention") String invention, HttpServletResponse httpServletResponse) { this.model.put(userId, new Info(name, invention)); httpServletResponse.setStatus(HttpServletResponse.SC_OK); }
From source file:org.magnum.dataup.VideoUpController.java
@RequestMapping(value = VideoSvcApi.VIDEO_DATA_PATH, method = RequestMethod.GET) public void getData(@PathVariable(VideoSvcApi.ID_PARAMETER) long id, HttpServletResponse resp) { if (videos.containsKey(id)) { try {/*from www . j a v a 2s . co m*/ serveVideo(videos.get(id), resp); resp.setStatus(HttpServletResponse.SC_OK); resp.setHeader("Content-Type", "video/mpeg"); } catch (IOException e) { resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } else { resp.setStatus(HttpServletResponse.SC_NOT_FOUND); } }
From source file:org.osmsurround.ae.osmrequest.OsmSignedRequestTemplate.java
private int openChangeset(String comment) throws JAXBException, HttpException, IOException { DefaultHttpClient httpClient = createHttpClient(); HttpEntityEnclosingRequestBase request = new HttpPut(osmApiBaseUrl + "/api/0.6/changeset/create"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); OsmRoot root = osmConvertService.createOsmRoot(); osmEditorService.addChangeset(root, comment); schemaService.createOsmMarshaller().marshal(osmConvertService.toJaxbElement(root), baos); request.setEntity(new ByteArrayEntity(baos.toByteArray())); oAuthService.signRequest(request);/*from ww w. j a v a 2 s.c om*/ HttpResponse httpResponse = httpClient.execute(request); log.info("Create result: " + httpResponse.getStatusLine().getStatusCode()); if (httpResponse.getStatusLine().getStatusCode() == HttpServletResponse.SC_OK) { BufferedReader reader = new BufferedReader( new InputStreamReader(httpResponse.getEntity().getContent())); return Integer.parseInt(reader.readLine()); } else { throw RequestUtils.createExceptionFromHttpResponse(httpResponse); } }