/** * Generates a 200 OK chunked result. */ public static Status ok(InputStream content) { return ok(content, defaultChunkSize); }
/** * Generates a 400 BAD_REQUEST chunked result. */ public static Status badRequest(InputStream content) { return badRequest(content, defaultChunkSize); }
/** * Generates a 500 INTERNAL_SERVER_ERROR chunked result. */ public static Status internalServerError(InputStream content) { return internalServerError(content, defaultChunkSize); }
@Override public Result adapt(final int code, final PlayWebContext context) { logger.debug("requires HTTP action: {}", code); if (code == HttpConstants.UNAUTHORIZED) { return unauthorized("authentication required"); } else if (code == HttpConstants.FORBIDDEN) { return forbidden("forbidden"); } else if (code == HttpConstants.TEMP_REDIRECT) { return redirect(context.getLocation()); } else if (code == HttpConstants.BAD_REQUEST) { return badRequest("bad request"); } else if (code == HttpConstants.OK) { final String content = context.getResponseContent(); logger.debug("render: {}", content); return ok(content).as(HttpConstants.HTML_CONTENT_TYPE); } else if (code == HttpConstants.NO_CONTENT) { return noContent(); } final String message = "Unsupported HTTP action: " + code; logger.error(message); throw new TechnicalException(message); } }
@Override public Object adapt(final int code, final WebContext context) { final PlayWebContext webContext = (PlayWebContext) context; logger.debug("requires HTTP action: {}", code); if (code == HttpConstants.UNAUTHORIZED) { return unauthorized("authentication required"); } else if (code == HttpConstants.FORBIDDEN) { return forbidden("forbidden"); } else if (code == HttpConstants.TEMP_REDIRECT) { return redirect(webContext.getResponseLocation()); } else if (code == HttpConstants.OK) { final String content = webContext.getResponseContent(); logger.debug("render: {}", content); return ok(content).as(HttpConstants.HTML_CONTENT_TYPE); } final String message = "Unsupported HTTP action: " + code; logger.error(message); throw new TechnicalException(message); } }
private Result setSession(String newSessionID) { if (knownSessionIDs.containsKey(newSessionID)) { currentSessionID = newSessionID; currentWorkerIdx = 0; return ok(); } else { return Results.badRequest("Unknown session ID: " + newSessionID); } }
/** * Generates a 403 FORBIDDEN chunked result. */ public static Status forbidden(InputStream content) { return forbidden(content, defaultChunkSize); }
/** * Generates a 401 UNAUTHORIZED chunked result. */ public static Status unauthorized(InputStream content) { return unauthorized(content, defaultChunkSize); }
/** * Generates a 404 NOT_FOUND chunked result. */ public static Status notFound(InputStream content) { return notFound(content, defaultChunkSize); }
@Override public List<Route> getRoutes() { //TODO // Route r = new Route("/", HttpMethod.GET, FunctionType.Supplier, () -> ok(org.deeplearning4j.ui.views.html.defaultPage.DefaultPage.apply())); Route r = new Route("/", HttpMethod.GET, FunctionType.Supplier, () -> redirect("/train/overview")); return Collections.singletonList(r); }
/** * Generates a 200 OK result. * * @param content HTTP response body, encoded as a UTF-8 string * @return the result */ public static Result ok(String content) { return status(OK, content); }
@Override public Result adapt(final int code, final PlayWebContext context) { logger.debug("requires HTTP action: {}", code); if (code == HttpConstants.UNAUTHORIZED) { return unauthorized("authentication required"); } else if (code == HttpConstants.FORBIDDEN) { return forbidden("forbidden"); } else if (code == HttpConstants.TEMP_REDIRECT) { return redirect(context.getLocation()); } else if (code == HttpConstants.BAD_REQUEST) { return badRequest("bad request"); } else if (code == HttpConstants.OK) { final String content = context.getResponseContent(); logger.debug("render: {}", content); return ok(content).as(HttpConstants.HTML_CONTENT_TYPE); } else if (code == HttpConstants.NO_CONTENT) { return noContent(); } final String message = "Unsupported HTTP action: " + code; logger.error(message); throw new TechnicalException(message); } }
private Result setSession(String newSessionID) { if (knownSessionIDs.containsKey(newSessionID)) { currentSessionID = newSessionID; currentWorkerIdx = 0; return ok(); } else { return Results.badRequest("Unknown session ID: " + newSessionID); } }
/** * Generates a 403 Forbidden result. * * @param content The file to send. * @param filename The name to send the file as. * @return the result */ public static Result forbidden(File content, String filename) { return forbidden(content, filename, StaticFileMimeTypes.fileMimeTypes()); }
/** * Generates a 401 Unauthorized result. * * @param content The file to send. * @return the result */ public static Result unauthorized(File content) { return unauthorized(content, StaticFileMimeTypes.fileMimeTypes()); }
/** * Generates a 404 Not Found result. * * @param content The file to send. * @param inline Whether the file should be sent inline, or as an attachment. * @return the result */ public static Result notFound(File content, boolean inline) { return notFound(content, inline, StaticFileMimeTypes.fileMimeTypes()); }
@Override public List<Route> getRoutes() { //TODO // Route r = new Route("/", HttpMethod.GET, FunctionType.Supplier, () -> ok(org.deeplearning4j.ui.views.html.defaultPage.DefaultPage.apply())); Route r = new Route("/", HttpMethod.GET, FunctionType.Supplier, () -> redirect("/train/overview")); return Collections.singletonList(r); }
/** * Generates a 200 OK result. * * @param content the input stream containing data to chunk over * @param contentLength the length of the provided content in bytes. * @return the result */ public static Result ok(InputStream content, long contentLength) { return status(OK, content, contentLength); }
/** * Generates a 200 OK result. * * @param content The file to send. * @param filename The name to send the file as. * @return the result */ public static Result ok(File content, String filename) { return ok(content, filename, StaticFileMimeTypes.fileMimeTypes()); }
/** * Generates a 400 Bad Request result. * * @param content The file to send. * @param inline Whether the file should be sent inline, or as an attachment. * @return the result */ public static Result badRequest(File content, boolean inline) { return badRequest(content, inline, StaticFileMimeTypes.fileMimeTypes()); }