List of usage examples for javax.servlet.http HttpServletResponse SC_NOT_IMPLEMENTED
int SC_NOT_IMPLEMENTED
To view the source code for javax.servlet.http HttpServletResponse SC_NOT_IMPLEMENTED.
Click Source Link
From source file:com.ibm.xsp.webdav.WebDavServlet.java
/** * (non-Javadoc)//from w ww.j a v a2 s .co m * * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ @Override protected void service(HttpServletRequest req, HttpServletResponse resp) { boolean canContinue = true; // Optimistic String errorMessage = null; IDAVAddressInformation repoAddress = null; this.writeDefaultHeaderInfo(req, resp); // We need to extract the repository name from the requestURL // If that is empty we list the available repositories as directories String curPath = req.getPathInfo(); // LOGGER.info("Curr path="+curPath+"; method="+req.getMethod()); if (curPath != null) { try { curPath = URLDecoder.decode(curPath, "UTF-8"); } catch (UnsupportedEncodingException e1) { LOGGER.error(e1); curPath = req.getPathInfo(); // We take it unencoded then } } IDAVRepository repository = this.getRepository(req, curPath, servletPath); // LOGGER.info("CurrentPath="+curPath+"; servletPath="+servletPath+""); IDAVProcessable meth = this.getMethod(req, resp, repository); if (meth == null) { // LOGGER.info("Method is null"); } else { // LOGGER.info("Method is " +meth.getClass()); } // Now we could have everything, we check if we can move ahead // if ((repository == null) ||(curPath == null) || curPath.equals("/")){ if ((repository == null)) { // LOGGER.info("Not found"); resp.setStatus(HttpServletResponse.SC_NOT_FOUND); canContinue = false; errorMessage = "<HTML><HEAD><TITLE>Unable to Process Request</TITLE></HEAD><BODY><P>Http Status Code: 404</P><P>Reason: Unable to process request, resource not found</P></BODY></HTML>"; resp.setContentLength(errorMessage.length()); resp.setContentType("text/html"); try { PrintWriter out = resp.getWriter(); out.write(errorMessage); out.close(); return; } catch (IOException e) { LOGGER.error(e); } } else { // LOGGER.info("repository found "+repository.getClass()); repoAddress = (IDAVAddressInformation) repository; } // Without a method there's no point to continue if (canContinue && meth == null) { // LOGGER.info("Can continue and method is null"); resp.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED); canContinue = false; errorMessage = "<h1>Repository " + repoAddress.getName() + "</h1><h2>Sorry, but this repository doesn't support <span style=\"color : red; font-weight : bold;\">[HTTP " + req.getMethod() + "]</span></h2>"; } // Now update credentials if we have them if (repository != null) { this.updateCredentials(req, repository); } if (canContinue) { try { // LOGGER.info("Can continue...."); // We check if we can/have to reset the manager with all // repositories String reset = req.getParameter("reset"); if (reset != null) { this.reset(); } // Finally execute the method meth.process(req, resp, repository, this.getLockManager()); if (meth.getLastHttpStatus().equals(IDAVProcessable.NO_STATUS_SET) && meth.didMethodSucceed()) { resp.setStatus(HttpServletResponse.SC_OK); // Make sure we // have a status } else if (!meth.didMethodSucceed()) { canContinue = false; errorMessage = meth.getErrorMessage(); return; } } catch (IOException e) { resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); errorMessage = "<h1>Error executing " + meth.getClass().getName() + ": " + e.getMessage() + "</h1>"; canContinue = false; LOGGER.error(e); } } // We might have hit an error just above if (!canContinue) { // Write out the error Unimplemented nothingToDo = new Unimplemented(); nothingToDo.setUseStream(meth.streamUsed()); nothingToDo.setErrorMessage(errorMessage); nothingToDo.setErrNum(meth.getLastHttpStatus()); try { nothingToDo.process(req, resp, null, null); } catch (IOException e) { resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); LOGGER.error(e); } } }
From source file:org.xwiki.platform.patchservice.web.PatchServiceAction.java
protected void processKeys(XWikiRequest request, XWikiResponse response, PatchservicePlugin plugin, XWikiContext context) throws Exception { response.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED); response.getWriter().print("Not implemented yet"); }
From source file:org.xwiki.platform.patchservice.web.PatchServiceAction.java
protected void processKey(XWikiRequest request, XWikiResponse response, PatchservicePlugin plugin, XWikiContext context) throws Exception { response.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED); response.getWriter().print("Not implemented yet"); }
From source file:com.googlecode.noweco.calendar.CaldavServlet.java
public void doReport(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { Unmarshaller unMarshaller = createUnmarshaller(); Marshaller marshaller = createMarshaller(); Object xmlRequest = null;/*from w ww.java 2 s . co m*/ try { xmlRequest = unMarshaller.unmarshal(req.getReader()); } catch (JAXBException e) { throw new CalendarException("Unable to parse request", e); } if (LOGGER.isTraceEnabled()) { try { StringWriter writer = new StringWriter(); marshaller.marshal(xmlRequest, writer); LOGGER.trace("receive :\n{}", writer.toString()); } catch (JAXBException e) { // ignore } } Multistatus multistatus = new Multistatus(); if (xmlRequest instanceof CalendarMultiget) { CalendarMultiget calendarMultiget = (CalendarMultiget) xmlRequest; Prop reqProp = calendarMultiget.getProp(); int status = propFind(multistatus, reqProp, req.getHeader("Depth"), calendarMultiget.getHref()); if (status != HttpServletResponse.SC_OK) { resp.sendError(status); return; } } else if (xmlRequest instanceof SyncCollection) { SyncCollection syncCollection = (SyncCollection) xmlRequest; Prop reqProp = syncCollection.getProp(); String requestURI = req.getRequestURI(); MemoryFile locate = MemoryFileUtils.locate(ROOT, requestURI); for (MemoryFile memoryFile : locate.getChildren()) { int status = propFind(multistatus, reqProp, "0", memoryFile.getURI()); if (status != HttpServletResponse.SC_OK) { resp.sendError(status); return; } } SyncToken syncToken = new SyncToken(); syncToken.getContent().add("<string mal formee>"); multistatus.setSyncToken(syncToken); } else if (xmlRequest instanceof PrincipalSearchPropertySet) { // PrincipalSearchPropertySet principalSearchPropertySet = (PrincipalSearchPropertySet) xmlRequest; resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED); return; } else { LOGGER.error("doReport not supported request " + xmlRequest.getClass()); resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED); return; } resp.setStatus(SC_MULTI_STATUS); resp.setContentType("text/xml;charset=\"UTF-8\""); PrintWriter httpWriter = resp.getWriter(); try { Writer writer; if (LOGGER.isTraceEnabled()) { writer = new StringWriter(); } else { writer = httpWriter; } marshaller.marshal(multistatus, writer); if (LOGGER.isTraceEnabled()) { String string = writer.toString(); LOGGER.trace("send :\n{}", string); httpWriter.write(string); } } catch (JAXBException e) { throw new CalendarException("Unable to format response", e); } httpWriter.close(); }
From source file:com.kurento.kmf.repository.internal.http.RepositoryHttpServlet.java
protected void uploadContent(HttpServletRequest req, HttpServletResponse resp) throws IOException { String sessionId = extractSessionId(req); RepositoryHttpEndpointImpl elem = repoHttpManager.getHttpRepoItemElem(sessionId); if (elem == null) { resp.setStatus(HttpServletResponse.SC_NOT_FOUND); return;//from w w w . ja v a2 s . c om } elem.stopCurrentTimer(); elem.fireStartedEventIfFirstTime(); try (InputStream requestInputStream = req.getInputStream()) { try (OutputStream repoItemOutputStream = elem.getRepoItemOutputStream()) { Range range = parseContentRange(req, resp); if (range != null) { if (range.start > elem.getWrittenBytes()) { resp.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED); resp.getOutputStream().println( "The server doesn't support writing ranges " + "ahead of previously written bytes"); } else if (range.end == elem.getWrittenBytes()) { // TODO We assume that the put range is the same than // the // previous one. Do we need to check this? resp.setStatus(SC_OK); resp.getOutputStream().println("The server has detected that the submited range " + "has already submited in a previous request"); } else if (range.start < elem.getWrittenBytes() && range.end > elem.getWrittenBytes()) { Range copyRange = new Range(); copyRange.start = elem.getWrittenBytes() - range.start; copyRange.end = range.end - range.start; copyStreamsRange(requestInputStream, repoItemOutputStream, copyRange); resp.setStatus(SC_OK); } else if (range.start == elem.getWrittenBytes()) { IOUtils.copy(requestInputStream, repoItemOutputStream); resp.setStatus(SC_OK); } } else { boolean isMultipart = ServletFileUpload.isMultipartContent(req); if (isMultipart) { uploadMultipart(req, resp, repoItemOutputStream); } else { try { log.info("Start to receive bytes (estimated " + req.getContentLength() + " bytes)"); int bytes = IOUtils.copy(requestInputStream, repoItemOutputStream); resp.setStatus(SC_OK); log.info("Bytes received: " + bytes); } catch (Exception e) { log.warn("Exception when uploading content", e); elem.fireSessionErrorEvent(e); resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } } } } finally { elem.stopInTimeout(); } }
From source file:org.kurento.repository.internal.http.RepositoryHttpServlet.java
protected void uploadContent(HttpServletRequest req, HttpServletResponse resp) throws IOException { String sessionId = extractSessionId(req); RepositoryHttpEndpointImpl elem = repoHttpManager.getHttpRepoItemElem(sessionId); if (elem == null) { resp.setStatus(HttpServletResponse.SC_NOT_FOUND); return;/* ww w . j av a 2 s . c o m*/ } elem.stopCurrentTimer(); elem.fireStartedEventIfFirstTime(); try (InputStream requestInputStream = req.getInputStream()) { OutputStream repoItemOutputStream = elem.getRepoItemOutputStream(); Range range = parseContentRange(req, resp); if (range != null) { if (range.start > elem.getWrittenBytes()) { resp.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED); resp.getOutputStream().println( "The server doesn't support writing ranges " + "ahead of previously written bytes"); } else if (range.end == elem.getWrittenBytes()) { // TODO We assume that the put range is the same than // the // previous one. Do we need to check this? resp.setStatus(SC_OK); resp.getOutputStream().println("The server has detected that the submited range " + "has already submited in a previous request"); } else if (range.start < elem.getWrittenBytes() && range.end > elem.getWrittenBytes()) { Range copyRange = new Range(); copyRange.start = elem.getWrittenBytes() - range.start; copyRange.end = range.end - range.start; copyStreamsRange(requestInputStream, repoItemOutputStream, copyRange); resp.setStatus(SC_OK); } else if (range.start == elem.getWrittenBytes()) { IOUtils.copy(requestInputStream, repoItemOutputStream); resp.setStatus(SC_OK); } } else { boolean isMultipart = ServletFileUpload.isMultipartContent(req); if (isMultipart) { uploadMultipart(req, resp, repoItemOutputStream); } else { try { log.debug("Start to receive bytes (estimated " + req.getContentLength() + " bytes)"); int bytes = IOUtils.copy(requestInputStream, repoItemOutputStream); resp.setStatus(SC_OK); log.debug("Bytes received: " + bytes); } catch (Exception e) { log.warn("Exception when uploading content", e); elem.fireSessionErrorEvent(e); resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } } } finally { elem.stopInTimeout(); } }
From source file:org.eclipse.gyrex.http.application.Application.java
/** * Called by the platform to allow the application to respond to a HTTP * request./*from ww w .j a va 2 s .co m*/ * <p> * The default implementation first calls * {@link #handleSecurity(HttpServletRequest, HttpServletResponse)} to * ensure that the request is allowed to be handled. It then asks the * {@link IApplicationContext} to handle the request. * </p> * * @param request * the <code>HttpServletRequest</code> object that contains the * client's request * @param response * the <code>HttpServletResponse</code> object that contains the * servlet's response * @exception ApplicationException * if an exception occurs that interferes with the * application's normal operation * @exception IOException * if an input or output exception occurs * @see Servlet#service(javax.servlet.ServletRequest, * javax.servlet.ServletResponse) */ public void handleRequest(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ApplicationException { // check for deferred initialization if (initTimestamp.get() == 0) { deferredInit(); } // check security if (!handleSecurity(request, response)) { return; } // get the context final IApplicationContext context = getApplicationContext(); if (null == context) { // if there is no context this method should not be overridden response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED); return; } // let the application context handle the request if (context.handleRequest(request, response)) { return; } // return 404, no resource registered response.sendError(HttpServletResponse.SC_NOT_FOUND); }
From source file:org.opendaylight.iotdm.onem2m.protocols.http.Onem2mHttpProvider.java
private int mapCoreResponseToHttpResponse(HttpServletResponse httpResponse, String rscString) { httpResponse.setHeader(Onem2m.HttpHeaders.X_M2M_RSC, rscString); switch (rscString) { case Onem2m.ResponseStatusCode.OK: return HttpServletResponse.SC_OK; case Onem2m.ResponseStatusCode.CREATED: return HttpServletResponse.SC_CREATED; case Onem2m.ResponseStatusCode.CHANGED: return HttpServletResponse.SC_OK; case Onem2m.ResponseStatusCode.DELETED: return HttpServletResponse.SC_OK; case Onem2m.ResponseStatusCode.NOT_FOUND: return HttpServletResponse.SC_NOT_FOUND; case Onem2m.ResponseStatusCode.OPERATION_NOT_ALLOWED: return HttpServletResponse.SC_METHOD_NOT_ALLOWED; case Onem2m.ResponseStatusCode.CONTENTS_UNACCEPTABLE: return HttpServletResponse.SC_BAD_REQUEST; case Onem2m.ResponseStatusCode.CONFLICT: return HttpServletResponse.SC_CONFLICT; case Onem2m.ResponseStatusCode.INTERNAL_SERVER_ERROR: return HttpServletResponse.SC_INTERNAL_SERVER_ERROR; case Onem2m.ResponseStatusCode.NOT_IMPLEMENTED: return HttpServletResponse.SC_NOT_IMPLEMENTED; case Onem2m.ResponseStatusCode.TARGET_NOT_REACHABLE: return HttpServletResponse.SC_NOT_FOUND; case Onem2m.ResponseStatusCode.ALREADY_EXISTS: return HttpServletResponse.SC_FORBIDDEN; case Onem2m.ResponseStatusCode.TARGET_NOT_SUBSCRIBABLE: return HttpServletResponse.SC_FORBIDDEN; case Onem2m.ResponseStatusCode.NON_BLOCKING_REQUEST_NOT_SUPPORTED: return HttpServletResponse.SC_NOT_IMPLEMENTED; case Onem2m.ResponseStatusCode.INVALID_ARGUMENTS: return HttpServletResponse.SC_BAD_REQUEST; case Onem2m.ResponseStatusCode.INSUFFICIENT_ARGUMENTS: return HttpServletResponse.SC_BAD_REQUEST; }/*from w w w . j av a 2s .c om*/ return HttpServletResponse.SC_BAD_REQUEST; }
From source file:com.homesnap.webserver.ControllerRestAPITest.java
@Test public void test13OnStatus() { // Test to get a controller of type light! JSONObject jo = getRequestJSONObject(urn_labels + "/ch1/controller?id=12¶m=param"); testController12(jo);/*w w w.j a v a 2 s. co m*/ jo = getRequestJSONObject(urn_labels + "/ch1/12?param=param"); testController12(jo); jo = getRequestJSONObject(urn_groups + "/1/controller?id=16¶m=param"); Assert.assertNull(jo); // have been deleted jo = getRequestJSONObject(urn_groups + "/1/16?param=param"); Assert.assertNull(jo); // have been deleted jo = getRequestJSONObject("/house/controllers/12?param=param"); testController12(jo); jo = getRequestJSONObject("/house/controllers/controller?id=12¶m=param"); testController12(jo); jo = getRequestJSONObject("/house/controllers/12?param=param"); testController12(jo); // Modification putRequestJSONObject("/house/controllers/12?status=On", createJsonController12(), HttpServletResponse.SC_OK); putRequestJSONObject("/house/controllers/controller?id=12&status=Off", createJsonController12(), HttpServletResponse.SC_OK); putRequestJSONObject(urn_groups + "/1/controller?id=12¶m=param", createJsonController12(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR); putRequestJSONObject(urn_groups + "/1/12?status=Off", createJsonController12(), HttpServletResponse.SC_OK); putRequestJSONObject(urn_labels + "/ch1/controller?id=12&status=Off", createJsonController12(), HttpServletResponse.SC_OK); putRequestJSONObject(urn_labels + "/ch1/12?status=Off", createJsonController12(), HttpServletResponse.SC_OK); putRequestJSONObject("/house/controllers/12?param=param", createJsonController12(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR); putRequestJSONObject("/house/controllers/controller?id=12&status=Off", createJsonController12(), HttpServletResponse.SC_OK); putRequestJSONObject("/house/controllers/12?status=Off", createJsonController12(), HttpServletResponse.SC_OK); // creation postRequestJSONObject(urn_groups + "/1/controller?id=17&status=Off", createJsonController17(), HttpServletResponse.SC_CREATED); postRequestJSONObject(urn_groups + "/1/12?status=Off", createJsonController12(), HttpServletResponse.SC_NOT_ACCEPTABLE); postRequestJSONObject(urn_labels + "/ch1/controller?id=17&status=Off", createJsonController17(), HttpServletResponse.SC_CREATED); postRequestJSONObject(urn_labels + "/ch1/17?status=Off", createJsonController17(), HttpServletResponse.SC_NOT_ACCEPTABLE); postRequestJSONObject("/house/17?status=Off", createJsonController17(), HttpServletResponse.SC_BAD_REQUEST); postRequestJSONObject("/house/controllers/controller?id=12&status=Off", createJsonController17(), HttpServletResponse.SC_NOT_IMPLEMENTED); postRequestJSONObject("/house/controllers/12?status=Off", createJsonController17(), HttpServletResponse.SC_NOT_IMPLEMENTED); // Deletion deleteRequestJSONObject(urn_groups + "/1/controller?id=11&status=Off", HttpServletResponse.SC_NOT_ACCEPTABLE); deleteRequestJSONObject(urn_groups + "/1/11?status=Off", HttpServletResponse.SC_NOT_ACCEPTABLE); deleteRequestJSONObject(urn_labels + "/ch1/controller?id=12&status=Off", HttpServletResponse.SC_OK); deleteRequestJSONObject(urn_labels + "/ch1/12?status=Off", HttpServletResponse.SC_NOT_ACCEPTABLE); deleteRequestJSONObject("/house/controllers/12?status=Off", HttpServletResponse.SC_NOT_IMPLEMENTED); deleteRequestJSONObject("/house/controllers/controller?id=12&status=Off", HttpServletResponse.SC_NOT_IMPLEMENTED); }