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:org.eclipse.orion.internal.server.servlets.xfer.SFTPTransfer.java
private void transferWithExceptions() throws ServletException, IOException, URISyntaxException, JSONException { String host, remotePath, user, passphrase; int port;/* w w w .j a va 2s. c om*/ try { JSONObject requestInfo = OrionServlet.readJSONRequest(request); host = requestInfo.getString(ProtocolConstants.KEY_HOST); remotePath = requestInfo.getString(ProtocolConstants.KEY_PATH); port = requestInfo.optInt(ProtocolConstants.KEY_PORT, 22); user = requestInfo.getString(ProtocolConstants.KEY_USER_NAME); passphrase = requestInfo.getString(ProtocolConstants.KEY_PASSPHRASE); } catch (Exception e) { handleException("Request body is not in the expected format", e, HttpServletResponse.SC_BAD_REQUEST); return; } File localFile; try { localFile = localRoot.toLocalFile(EFS.NONE, null); } catch (CoreException e) { handleException(NLS.bind("Import is not supported at this location: {0}", localRoot.toString()), e, HttpServletResponse.SC_NOT_IMPLEMENTED); return; } SFTPTransferJob job; if (TransferServlet.PREFIX_IMPORT.equals(new Path(request.getPathInfo()).segment(0))) { job = new SFTPImportJob(TaskJobHandler.getUserId(request), localFile, host, port, new Path(remotePath), user, passphrase, options); } else { job = new SFTPExportJob(TaskJobHandler.getUserId(request), localFile, host, port, new Path(remotePath), user, passphrase, options); } job.schedule(); TaskInfo task = job.getTask(); JSONObject result = task.toJSON(); //Not nice that the import service knows the location of the task servlet, but task service doesn't know this either URI requestLocation = ServletResourceHandler.getURI(request); URI taskLocation = new URI(requestLocation.getScheme(), requestLocation.getAuthority(), "/task/temp/" + task.getId(), null, null); //$NON-NLS-1$ result.put(ProtocolConstants.KEY_LOCATION, taskLocation); response.setHeader(ProtocolConstants.HEADER_LOCATION, ServletResourceHandler.resovleOrionURI(request, taskLocation).toString()); OrionServlet.writeJSONResponse(request, response, result); response.setStatus(HttpServletResponse.SC_ACCEPTED); }
From source file:com.homesnap.webserver.HouseRestAPITest.java
@Test public void test5OnStatus() { postRequestJSONObject(urn + "?param=param", "{}", HttpServletResponse.SC_NOT_IMPLEMENTED); // Test to get a specific label JSONObject house = getRequestJSONObject(urn + "?param=param"); JSONArray labels = house.getJSONArray(House.JSON_LABELS); JSONObject label = labels.getJSONObject(0); // Test label Ch1 testLabelCh1(label);//from w w w .j a v a 2 s . co m }
From source file:biz.astute.test.simulator.rest.SimulatorRestHandler.java
/** * {@inheritDoc}/*from ww w. ja va 2 s. c om*/ */ @Override public final void handle(final String pTarget, final Request pBaseRequest, final HttpServletRequest pRequest, final HttpServletResponse pResponse) throws IOException, ServletException { // Lets set the default pResponse.setContentType("text/plain"); try { DataResourceInterface dataResourceInterface = DataResourceFactory .getDataResource(new RequestContext(pRequest, pResponse)); for (String header : dataResourceInterface .getProperties(DataResourceInterface.HEADER_RESPONSE_PREFIX)) { pResponse.setHeader(header.substring(DataResourceInterface.HEADER_RESPONSE_PREFIX.length() + 1), dataResourceInterface.getPropertyValue(header)); } String status = dataResourceInterface.getPropertyValue(DataResourceInterface.RESPONSE_STATUS); if (StringUtils.isEmpty(status)) { status = Integer.toString(HttpStatus.OK_200); } pResponse.setStatus(Integer.parseInt(status)); String val = dataResourceInterface.getPropertyValue(DataResourceInterface.DATA_RESPONSE_VALUE); if (val == null) { try (InputStream inStream = dataResourceInterface .getResourceData(DataResourceInterface.DATA_RESPONSE_RESOURCE);) { if (inStream != null) { OutputStream outStream = pResponse.getOutputStream(); pResponse.setContentLength(IOUtils.copy(inStream, outStream)); outStream.flush(); } } } else { pResponse.getWriter().print(val); } } catch (DataResourceException | NoSuchAlgorithmException execp) { LOGGER.log(Level.SEVERE, "Error Processing " + pRequest.getRequestURL(), execp); pResponse.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED); pResponse.getWriter() .print("Error Processing " + pRequest.getRequestURL() + " - " + execp.getMessage()); } pResponse.flushBuffer(); pBaseRequest.setHandled(true); }
From source file:org.eclipse.orion.server.cf.servlets.AbstractRESTHandler.java
/** * Handles a GET request. Note this method is meant to be overridden in descendant classes. * @param request The GET request being handled. * @param response The response associated with the request. * @param path Path suffix required to handle the request. * @return A {@link JazzJob} which returns the requested resource on completion. *//*from w w w.j ava 2 s.co m*/ protected CFJob handleGet(T resource, final HttpServletRequest request, final HttpServletResponse response, final String path) { return new CFJob(request, false) { @Override protected IStatus performJob() { String msg = NLS.bind("Failed to handle request for {0}", path); //$NON-NLS-1$ return new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_IMPLEMENTED, msg, null); } }; }
From source file:com.homesnap.webserver.AbstractRestApi.java
protected JSONObject postRequestJSONObject(String urn, String body, int returnCodeExpected) { Client client = Client.create();/*from ww w . jav a 2 s .c o m*/ WebResource webResource = client.resource("http://" + server + ":" + port + urn); String json = null; try { ClientResponse response = webResource.accept("application/json").post(ClientResponse.class, body); Assert.assertEquals(returnCodeExpected, response.getStatus()); if (returnCodeExpected == HttpServletResponse.SC_NOT_IMPLEMENTED || returnCodeExpected == HttpServletResponse.SC_NOT_ACCEPTABLE || returnCodeExpected == HttpServletResponse.SC_BAD_REQUEST) { return null; } json = response.getEntity(String.class); return JSonTools.fromJson(json); } catch (JSONException e) { e.printStackTrace(); Assert.fail("Problem with JSON [" + json + "] :" + e.getMessage()); } Assert.fail("Problem when call [" + urn + "]."); return null; }
From source file:de.micromata.genome.gwiki.web.dav.WebDavServlet.java
protected void serveWebDav(GWikiContext ctx) throws ServletException, IOException { GWikiDAOContext daoContext = ctx.getWikiWeb().getDaoContext(); if (daoContext.isEnableWebDav() == false) { ctx.getResponse().sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "GWiki webdav not enabled"); return;//from w w w . j a va 2 s. co m } if (davServer == null) { davServer = new GWikiDavServer(); } if (davServer != null) { davServer.serve(ctx.getWikiWeb(), daoContext, ctx); } }
From source file:com.thinkberg.webdav.servlet.MoxoWebDAVServlet.java
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // String auth = request.getHeader("Authorization"); // String login = "", password = ""; ////from www . j a v a 2 s .c o m // if (auth != null) { // auth = new String(Base64.decodeBase64(auth.substring(auth.indexOf(' ') + 1).getBytes())); // login = auth.substring(0, auth.indexOf(':')); // password = auth.substring(auth.indexOf(':') + 1); // } // // AWSCredentials credentials = AWSCredentials.load(password, )) // if (user == null) { // response.setHeader("WWW-Authenticate", "Basic realm=\"Moxo\""); // response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); // return; // } // show we are doing the litmus test String litmusTest = request.getHeader("X-Litmus"); if (null == litmusTest) { litmusTest = request.getHeader("X-Litmus-Second"); } if (litmusTest != null) { LOG.info(String.format("WebDAV Litmus Test: %s", litmusTest)); } String method = request.getMethod(); LOG.debug(String.format(">> %s %s", request.getMethod(), request.getPathInfo())); if (handlers.containsKey(method)) { handlers.get(method).service(request, response); } else { response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED); } LOG.debug( String.format("<< %s (%s)", request.getMethod(), response.toString().replaceAll("[\\r\\n]+", ""))); }
From source file:com.homesnap.webserver.ControllerRestAPITest.java
@Test public void test03CreateController() { postRequestJSONObject("/house/controllers/12", createJsonController12(), HttpServletResponse.SC_NOT_IMPLEMENTED); postRequestJSONObject("/house/controllers/controller?id=12", createJsonController12(), HttpServletResponse.SC_NOT_IMPLEMENTED); postRequestJSONObject("/house/controllers/controller/12", createJsonController12(), HttpServletResponse.SC_NOT_IMPLEMENTED); }
From source file:com.flexive.war.servlet.ExportServlet.java
@Override public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException { HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; String[] params = URLDecoder .decode(request.getRequestURI().substring(request.getContextPath().length() + BASEURL.length()), "UTF-8") .split("/"); // do not check the type requests if we are dealing with a content export final List<Long> typeRequests = new ArrayList<Long>(params.length); if (!EXPORT_CONTENT.equals(params[0])) { for (int i = 1; i < params.length; i++) { typeRequests.add(Long.parseLong(params[i])); }//from w ww.j a v a 2 s. c o m } if (params.length == 1 && EXPORT_TYPE_GROOVY.equals(params[0])) { exportGroovy(request, response); return; } else if (params.length >= 2 && EXPORT_TYPE.equals(params[0])) { exportType(request, response, typeRequests); return; } else if (params.length == 2 && EXPORT_CONTENT.equals(params[0])) { exportContent(request, response, params[1]); return; } response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED); }
From source file:de.mpg.escidoc.pubman.sword.PubManServiceDocumentServlet.java
/** * Process the POST request. This will return an unimplemented response. * @param HttpServletRequest/* w w w . j a va 2 s.com*/ * @param HttpServletResponse * @throws ServletException * @throws IOException */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED); }