List of usage examples for javax.servlet.http HttpServletResponse SC_NO_CONTENT
int SC_NO_CONTENT
To view the source code for javax.servlet.http HttpServletResponse SC_NO_CONTENT.
Click Source Link
From source file:com.thinkberg.moxo.dav.UnlockHandler.java
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { FileObject object = getResourceManager().getFileObject(request.getPathInfo()); String lockTokenHeader = request.getHeader("Lock-Token"); String lockToken = lockTokenHeader.substring(1, lockTokenHeader.length() - 1); log("UNLOCK(" + lockToken + ")"); if (LockManager.getInstance().releaseLock(object, lockToken)) { response.setStatus(HttpServletResponse.SC_NO_CONTENT); } else {/*from w w w .j a v a 2s . c o m*/ response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); } }
From source file:bluevia.ReceiveSMS.java
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { //Dump Http Info Util.dumpHttpInfo(req);//from w ww . j av a2s. co m resp.setStatus(HttpServletResponse.SC_NO_CONTENT); /*String contentType = req.getContentType(); String oauth_consumer_key=""; String htmlAuthHeader=req.getHeader("Authorization"); if (htmlAuthHeader!=null){ StringTokenizer htmlHeader = new StringTokenizer(htmlAuthHeader," "); String szAux = htmlHeader.nextToken(); if (szAux.compareTo("OAuth")==0){ szAux = htmlHeader.nextToken(","); szAux=szAux.trim(); while(szAux!=null){ StringTokenizer headerParam = new StringTokenizer(szAux,"='"); String param = headerParam.nextToken(); if (param.compareTo("oauth_consumer_key")==0){ szAux=headerParam.nextToken(); szAux = szAux.replace('"', ' '); oauth_consumer_key=szAux.trim(); break; }else{ szAux = htmlHeader.nextToken(","); szAux = szAux.replace('"', ' '); szAux=szAux.trim(); } } } if (oauth_consumer_key.compareTo(Util.BlueViaOAuth.consumer_key)==0){ if (contentType.compareTo("application/json")==0){ try{ StringBuffer doc = new StringBuffer(); BufferedReader br = new BufferedReader(new InputStreamReader(req.getInputStream())); String line = br.readLine(); while (line != null) { doc.append(line); line = br.readLine(); } JSONObject receivedSMSAsync = new JSONObject(doc.toString()); JSONObject smsInfo = receivedSMSAsync.getJSONObject("receivedSMSAsync").getJSONObject("message"); String szMessage = smsInfo.getString("message"); String szOrigin = smsInfo.getJSONObject("originAddress").getString("phoneNumber"); Date now= new Date(); StringTokenizer msgParser = new StringTokenizer(szMessage); // Removing app id msgParser.nextToken(); String userAlias = msgParser.nextToken(); String msg = ""; while (msgParser.hasMoreTokens()) msg += " "+ msgParser.nextToken(); String userEmail = (String)Util.getUserWithAlias(userAlias).getProperty("mail"); if (userEmail!=null){ Util.addUserMessage(userEmail, szOrigin, msg, Long.toString(now.getTime())); SendSMS.setTwitterStatus(userEmail,msg); SendSMS.setFacebookWallPost(userEmail,msg); resp.setStatus(HttpServletResponse.SC_NO_CONTENT); }else resp.sendError(HttpServletResponse.SC_BAD_REQUEST,"Error processing receivedSMSAsync: invalid user/alias"); } catch (Exception e) { log.severe(e.getMessage()); resp.sendError(HttpServletResponse.SC_BAD_REQUEST,"Error processing receivedSMSAsync: invalid json data structure\n"+e.getMessage()); } }else resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED,"This version of the server only accepts applicaciont/json"); }else resp.sendError(HttpServletResponse.SC_UNAUTHORIZED); }else resp.sendError(HttpServletResponse.SC_UNAUTHORIZED);*/ }
From source file:com.thinkberg.webdav.UnlockHandler.java
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { FileObject object = VFSBackend.resolveFile(request.getPathInfo()); String lockTokenHeader = request.getHeader("Lock-Token"); String lockToken = lockTokenHeader.substring(1, lockTokenHeader.length() - 1); LOG.debug("UNLOCK(" + lockToken + ")"); if (LockManager.getInstance().releaseLock(object, lockToken)) { response.setStatus(HttpServletResponse.SC_NO_CONTENT); } else {//from w w w . j av a 2 s . c o m response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); } }
From source file:com.erudika.para.security.SimpleAuthenticationEntryPoint.java
@Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { if (isPreflight(request)) { response.setStatus(HttpServletResponse.SC_NO_CONTENT); } else if (isRestRequest(request)) { RestUtils.returnStatusResponse(response, HttpServletResponse.SC_UNAUTHORIZED, authException.getMessage()); } else {/*from w ww . jav a 2 s . c o m*/ super.commence(request, response, authException); } }
From source file:org.efaps.webdav4vfs.handler.UnlockHandler.java
@Override public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { FileObject object = VFSBackend.resolveFile(request.getPathInfo()); String lockTokenHeader = request.getHeader("Lock-Token"); String lockToken = lockTokenHeader.substring(1, lockTokenHeader.length() - 1); LOG.debug("UNLOCK(" + lockToken + ")"); if (LockManager.getInstance().releaseLock(object, lockToken)) { response.setStatus(HttpServletResponse.SC_NO_CONTENT); } else {/* w w w . j av a 2 s .c o m*/ response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); } }
From source file:es.logongas.encuestas.presentacion.controller.BorrarDatosController.java
@RequestMapping(value = { "/Encuesta" }, method = RequestMethod.DELETE) public void delete(HttpServletRequest httpRequest, HttpServletResponse httpServletResponse) { try {/*from w w w. ja v a2s.c om*/ EncuestaDAO encuestaDAO = (EncuestaDAO) daoFactory.getDAO(Encuesta.class); encuestaDAO.deleteAllData(); noCache(httpServletResponse); httpServletResponse.setStatus(HttpServletResponse.SC_NO_CONTENT); } catch (Exception ex) { httpServletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); httpServletResponse.setContentType("text/plain"); try { ex.printStackTrace(httpServletResponse.getWriter()); } catch (Exception ex2) { log.error("Fall al imprimir la traza", ex2); } } }
From source file:pt.webdetails.cpk.elements.impl.kettleoutputs.ResultFilesKettleOutput.java
@Override public void processResult(KettleResult result) { logger.debug("Process Result Files"); List<FileObject> files = new ArrayList<FileObject>(); for (ResultFile resultFile : result.getFiles()) { files.add(resultFile.getFile()); }//from www . jav a 2 s. c om if (files.isEmpty()) { logger.warn("Processing result files but no files found"); this.getResponse().setStatus(HttpServletResponse.SC_NO_CONTENT); return; } String defaultAttachmentName = this.getConfiguration().getAttachmentName(); try { if (files.size() == 1 && files.get(0).getType() == FileType.FILE) { // Singe file FileObject file = files.get(0); InputStream fileInputStream = KettleVFS.getInputStream(file); FileName fileName = file.getName(); String defaultMimeType = this.getConfiguration().getMimeType(); String mimeType = defaultMimeType != null ? defaultMimeType : MimeTypes.getMimeType(fileName.getBaseName()); String attachmentName = defaultAttachmentName != null ? defaultAttachmentName : fileName.getBaseName(); CpkUtils.send(this.getResponse(), fileInputStream, mimeType, attachmentName, this.getConfiguration().getSendResultAsAttachment()); } else { // More than one file, or folder // Build a zip / tar and ship it over! ZipUtil zip = new ZipUtil(); zip.buildZipFromFileObjectList(files); String attachmentName = defaultAttachmentName != null ? defaultAttachmentName : zip.getZipNameToDownload(); CpkUtils.send(this.getResponse(), zip.getZipInputStream(), MimeTypes.ZIP, attachmentName, true); } } catch (FileSystemException ex) { logger.error("Failed sending files from kettle result.", ex); } }
From source file:com.homesnap.webserver.HouseRestAPITest.java
@Test public void test1DeleteHouse() { // Test impossible to create a house JSONObject jo = deleteRequestJSONObject(urn, HttpServletResponse.SC_NO_CONTENT); Assert.assertNull(jo);/* w w w . jav a 2 s .c om*/ // Test to get a house with some group and label jo = getRequestJSONObject(urn); // Test labels JSONArray labels = jo.getJSONArray(House.JSON_LABELS); Assert.assertEquals(0, labels.length()); JSONArray groups = jo.getJSONArray(House.JSON_GROUPS); Assert.assertEquals(0, groups.length()); }
From source file:de.sainth.recipe.backend.rest.controller.LogoutController.java
@RequestMapping() @ResponseStatus(HttpStatus.NO_CONTENT)// ww w . j av a 2 s .c o m void logout(HttpServletRequest request, HttpServletResponse response) { if ("/logout".equals(request.getServletPath())) { Optional<Cookie> cookie = Arrays.stream(request.getCookies()) .filter(c -> "recipe_bearer".equals(c.getName())).findFirst(); if (cookie.isPresent()) { Cookie c = cookie.get(); c.setValue(""); c.setPath("/"); c.setMaxAge(0); response.addCookie(c); } response.setStatus(HttpServletResponse.SC_NO_CONTENT); } }