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.homesnap.webserver.GroupRestAPITest.java
@Test public void test2PutGroupList() { // Test impossible to create grouplist putRequestJSONObject(urn_groups, "{}", HttpServletResponse.SC_NOT_IMPLEMENTED); }
From source file:com.homesnap.webserver.HouseRestAPITest.java
@Test public void test3PutHouse() { // Test impossible to create a house putRequestJSONObject(urn, "{}", HttpServletResponse.SC_NOT_IMPLEMENTED); }
From source file:com.homesnap.webserver.LabelRestAPITest.java
@Test public void test5ModifyLabelList() { // Test impossible to modify label list putRequestJSONObject(urn_labels, "{}", HttpServletResponse.SC_NOT_IMPLEMENTED); }
From source file:org.sprintapi.api.http.HttpServlet.java
protected void doService(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws ErrorException, IOException { final RequestHolder<Object> request = new RequestHolder<Object>(getUri(httpRequest)); request.setContext(httpRequest.getContextPath()); // Resolve incoming URL and get resource descriptor final ResourceDescriptor resourceDsc = resolve(request.getUri()); // Does the requested resource exist? if (resourceDsc == null) { throw new ErrorException(request.getUri(), HttpServletResponse.SC_NOT_FOUND); }//from w ww. ja va 2 s . co m // Is requested method supported? if (httpRequest.getMethod() == null) { throw new ErrorException(request.getUri(), HttpServletResponse.SC_BAD_REQUEST); } try { request.setMethod(Method.valueOf(httpRequest.getMethod().toUpperCase(Locale.US))); } catch (IllegalArgumentException ex) { throw new ErrorException(request.getUri(), HttpServletResponse.SC_NOT_IMPLEMENTED); } if (request.getMethod() == null) { throw new ErrorException(request.getUri(), HttpServletResponse.SC_NOT_IMPLEMENTED); } // Get supported methods for requested resource Map<Method, MethodDescriptor<?, ?>> methods = resourceDsc.methods(); // Get requested method descriptors for the resource MethodDescriptor<?, ?> methodDsc = (methods != null) ? methods.get(request.getMethod()) : null; // Is requested method supported? if ((methodDsc == null)) { throw new ErrorException(request.getUri(), HttpServletResponse.SC_METHOD_NOT_ALLOWED); } ContentAdapter<InputStream, ?> inputContentAdapter = null; // Is request body expected? if (request.getMethod().isRequestBody()) { String requestContentType = httpRequest.getContentType(); inputContentAdapter = (methodDsc.consumes() != null) ? methodDsc.consumes().get(requestContentType) : null; if (inputContentAdapter == null) { throw new ErrorException(request.getUri(), HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); } } else if (httpRequest.getContentLength() > 0) { // Unexpected request body throw new ErrorException(request.getUri(), HttpServletResponse.SC_BAD_REQUEST); } ContentAdapter<?, InputStream> outputContentAdapter = null; String responseContentType = null; // Is response body expected? if (request.getMethod().isResponseBody()) { // Check Accept header HttpAcceptHeader acceptHeader = HttpAcceptHeader .read(httpRequest.getHeader(ContentDescriptor.META_ACCEPT)); if (acceptHeader != null) { Map<String, ?> produces = methodDsc.produces(); // Response content negotiation if (produces != null) { int weight = 0; for (String ct : produces.keySet()) { int tw = acceptHeader.accept(ct); if (tw > weight) { weight = tw; responseContentType = ct; outputContentAdapter = (ContentAdapter<?, InputStream>) produces.get(ct); } } } if (outputContentAdapter == null) { throw new ErrorException(request.getUri(), HttpServletResponse.SC_NOT_ACCEPTABLE); } } } if (inputContentAdapter != null) { ContentHolder<Object> lc = new ContentHolder<Object>(); lc.setBody(inputContentAdapter.transform(request.getUri(), httpRequest.getInputStream())); request.setContent(lc); } // Invoke resource method Response response = methodDsc.invoke((Request) request); if (response == null) { throw new ErrorException(request.getUri(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } // Write response status int responseStatus = (response.getStatus() > 0) ? response.getStatus() : HttpServletResponse.SC_OK; httpResponse.setStatus(responseStatus); if (response.getContent() == null) { return; } // Write response headers if (response.getContent().getMetaNames() != null) { for (String metaName : response.getContent().getMetaNames()) { Object metaValue = response.getContent().getMeta(metaName); if (metaValue != null) { if (metaValue instanceof Date) { httpResponse.setHeader(metaName, HttpDate.RFC1123_FORMAT.format(((Date) metaValue))); } else { httpResponse.setHeader(metaName, metaValue.toString()); } } } } if ((HttpServletResponse.SC_CREATED == responseStatus)) { httpResponse.setHeader(ContentDescriptor.META_LOCATION, response.getContext() + response.getUri()); } if ((response.getContent().getBody() == null) || (HttpServletResponse.SC_NOT_MODIFIED == responseStatus)) { return; } // Write response body if (outputContentAdapter != null) { httpResponse.setHeader(ContentDescriptor.META_CONTENT_TYPE, responseContentType); InputStream is = ((ContentAdapter<Object, InputStream>) outputContentAdapter) .transform(request.getUri(), response.getContent().getBody()); if (is != null) { CopyUtils.copy(is, httpResponse.getOutputStream()); } } }
From source file:org.apache.shindig.social.sample.service.SampleContainerHandler.java
/** * Handles /samplecontainer/setstate and /samplecontainer/setevilness/{doevil}. TODO(doll): These * urls aren't very resty. Consider changing the samplecontainer.html calls post. *///from w w w . j av a 2 s . c om @Operation(httpMethods = "POST", bodyParam = "data") public Future<?> create(RequestItem request) throws ProtocolException { String type = request.getParameter("type"); if (type.equals("setstate")) { try { @SuppressWarnings("unchecked") Map<String, String> bodyparams = request.getTypedParameter("data", Map.class); String stateFile = bodyparams.get("fileurl"); service.setDb(new JSONObject(fetchStateDocument(stateFile))); } catch (JSONException e) { throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "The json state file was not valid json", e); } } else if (type.equals("setevilness")) { throw new ProtocolException(HttpServletResponse.SC_NOT_IMPLEMENTED, "evil data has not been implemented yet"); } return ImmediateFuture.newInstance(null); }
From source file:org.apache.shindig.social.opensocial.hibernate.services.AppDataServiceImpl.java
public Future<Void> deletePersonData(UserId userId, GroupId groupId, String appId, Set<String> fields, SecurityToken token) throws ProtocolException { if (appId == null) { appId = token.getAppId();//from w w w. j ava2 s. c o m } Type type = groupId.getType(); if (type.equals(Type.self)) { if (userId.getUserId(token).equals(token.getViewerId())) { if (fields.contains("*") || fields.isEmpty()) { deleteAppData(userId.getUserId(token), null, appId); } else { for (String key : fields) { deleteAppData(userId.getUserId(token), key, appId); } } return ImmediateFuture.newInstance(null); } else { throw new ProtocolException(HttpServletResponse.SC_FORBIDDEN, "The data of the user who is not VIEWER cannot be removed. "); } } else { throw new ProtocolException(HttpServletResponse.SC_NOT_IMPLEMENTED, "We don't support updating data in batches yet."); } }
From source file:org.openmrs.module.restmodule.web.HL7MessageResource.java
/** * Handle all requests to this HL7Message resource *//*from w ww. j a v a 2 s.com*/ public void handleRequest(Operation operation, OutputType outputType, String restRequest, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String message = request.getParameter(MESSAGE); String source = request.getParameter(SOURCE); switch (operation) { case POST: if (message == null || message.equals("")) { log.error("Missing a 'message' parameter"); response.sendError(HttpServletResponse.SC_BAD_REQUEST); return; } if (source == null || source.equals("")) { log.error("Missing a 'source' parameter"); response.sendError(HttpServletResponse.SC_BAD_REQUEST); return; } try { HL7Service hl7Service = Context.getHL7Service(); HL7InQueue hl7Queue = new HL7InQueue(); HL7Source hl7Source = hl7Service.getHL7SourceByName(source); if (hl7Source == null) { log.error("HL7Source object not found with a name of: '" + source + "'"); response.sendError(HttpServletResponse.SC_BAD_REQUEST); return; } hl7Queue.setHL7Source(hl7Source); hl7Queue.setHL7Data(message); hl7Service.saveHL7InQueue(hl7Queue); } catch (Exception e) { log.error("Error occurred while saving hl7 in queue", e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } break; case GET: case PUT: case DELETE: response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED); return; } }
From source file:org.apache.shindig.sample.container.SampleContainerHandler.java
/** * Handles /samplecontainer/setstate and /samplecontainer/setevilness/{doevil}. TODO(doll): These * urls aren't very resty. Consider changing the samplecontainer.html calls post. *///w ww . j ava2s.c o m @Operation(httpMethods = "POST", bodyParam = "data") public Future<?> create(RequestItem request) throws ProtocolException { String type = request.getParameter("type"); if ("setstate".equals(type)) { try { @SuppressWarnings("unchecked") Map<String, String> bodyparams = request.getTypedParameter("data", Map.class); String stateFile = bodyparams.get("fileurl"); service.setDb(new JSONObject(fetchStateDocument(stateFile))); } catch (JSONException e) { throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "The json state file was not valid json", e); } } else if ("setevilness".equals(type)) { throw new ProtocolException(HttpServletResponse.SC_NOT_IMPLEMENTED, "evil data has not been implemented yet"); } return ImmediateFuture.newInstance(null); }
From source file:de.mpg.escidoc.pubman.sword.PubManDepositServlet.java
/** * Process the GET request. This will return an unimplemented response. *//*from w ww . ja v a 2s . c om*/ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED); }
From source file:edu.cornell.mannlib.vitro.webapp.controller.SparqlQueryBuilderServlet.java
private void doNoModelInContext(HttpServletRequest request, HttpServletResponse res) { try {//from w w w.j a v a 2s . c o m res.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED); ServletOutputStream sos = res.getOutputStream(); sos.println("<html><body>this service is not supporeted by the current " + "webapp configuration. A jena model is required in the servlet context.</body></html>"); } catch (IOException e) { log.error("Could not write to ServletOutputStream"); } }