private Result getSummaryResults(){ StatsStorage ss = knownSessionIDs.get(currentSessionID); if(ss == null){ log.warn("getSummaryResults(): Session ID is unknown: {}", currentSessionID); return ok(); } List<Persistable> allModelInfoTemp = new ArrayList<>(ss.getLatestUpdateAllWorkers(currentSessionID, ARBITER_UI_TYPE_ID)); List<String[]> table = new ArrayList<>(); for(Persistable per : allModelInfoTemp){ ModelInfoPersistable mip = (ModelInfoPersistable)per; String score = (mip.getScore() == null ? "" : mip.getScore().toString()); table.add(new String[]{mip.getModelIdx().toString(), score, mip.getStatus().toString()}); } return ok(asJson(table)).as(JSON); }
private Result getImage() { if (lastTimeStamp > 0 && lastStorage != null) { Persistable p = lastStorage.getStaticInfo(lastSessionID, TYPE_ID, lastWorkerID); if (p instanceof ConvolutionListenerPersistable) { ConvolutionListenerPersistable clp = (ConvolutionListenerPersistable) p; BufferedImage bi = clp.getImg(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ImageIO.write(bi, "jpg", baos); } catch (IOException e) { log.warn("Error displaying image", e); } return ok(baos.toByteArray()).as("image/jpg"); } else { return ok(new byte[0]).as("image/jpeg"); } } else { return ok(new byte[0]).as("image/jpeg"); } } }
private Result getImage() { if (lastTimeStamp > 0 && lastStorage != null) { Persistable p = lastStorage.getStaticInfo(lastSessionID, TYPE_ID, lastWorkerID); if (p instanceof ConvolutionListenerPersistable) { ConvolutionListenerPersistable clp = (ConvolutionListenerPersistable) p; BufferedImage bi = clp.getImg(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ImageIO.write(bi, "jpg", baos); } catch (IOException e) { log.warn("Error displaying image", e); } return ok(baos.toByteArray()).as("image/jpg"); } else { return ok(new byte[0]).as("image/jpeg"); } } else { return ok(new byte[0]).as("image/jpeg"); } } }
return ok(asJson(cd)).as(JSON);
return ok(asJson(cd)).as(JSON);
@Transactional public static Result getCorrelationLinks(final Long issueId) { if (!isInDevMode()) { Logger.warn("Tried to access to get Correlation links while not in DEV mode"); return badRequest(); } List<IssueCommentWithHerculesArticle> articles = IssueCommentWithHerculesArticle.findByIssueId(issueId); if (CollectionUtils.isEmpty(articles)) { return noContent(); } final ArrayList<CorrelationLinksResultRepresentation> results = Lists.newArrayList(transform(articles, new Function<IssueCommentWithHerculesArticle, CorrelationLinksResultRepresentation>() { @Nullable @Override public CorrelationLinksResultRepresentation apply(IssueCommentWithHerculesArticle input) { return CorrelationLinksResultRepresentation.toResultRepresentation(input); } })); return ok(Json.toJson(results)).as("application/json"); }
@Override public Result apply(String s) { String fullPath = assetsRootDirectory + s; InputStream inputStream; try { inputStream = new ClassPathResource(fullPath).getInputStream(); } catch (Exception e) { log.debug("Could not find asset: {}", s); return ok(); } catch (Throwable t) { return ok(); } String fileName = FilenameUtils.getName(fullPath); response().setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + fileName + "\""); scala.Option<String> contentType = MimeTypes.forFileName(fileName); String ct; if (contentType.isDefined()) { ct = contentType.get(); } else { ct = "application/octet-stream"; } return ok(inputStream).as(ct); } }
@Override public Result apply(String s) { String fullPath = assetsRootDirectory + s; InputStream inputStream; try { inputStream = new ClassPathResource(fullPath).getInputStream(); } catch (Exception e) { log.debug("Could not find asset: {}", s); return ok(); } catch (Throwable t) { return ok(); } String fileName = FilenameUtils.getName(fullPath); response().setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + fileName + "\""); scala.Option<String> contentType = MimeTypes.forFileName(fileName); String ct; if (contentType.isDefined()) { ct = contentType.get(); } else { ct = "application/octet-stream"; } return ok(inputStream).as(ct); } }
@Override public Result apply(String s) { String fullPath = assetsRootDirectory + s; InputStream inputStream; try { inputStream = new ClassPathResource(fullPath).getInputStream(); } catch (Exception e) { log.debug("Could not find asset: {}", s); return ok(); } catch (Throwable t) { return ok(); } String fileName = FilenameUtils.getName(fullPath); response().setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + fileName + "\""); scala.Option<String> contentType = MimeTypes.forFileName(fileName); String ct; if (contentType.isDefined()) { ct = contentType.get(); } else { ct = "application/octet-stream"; } return ok(inputStream).as(ct); } }
private Result getImage() { if (lastTimeStamp > 0 && lastStorage != null) { Persistable p = lastStorage.getStaticInfo(lastSessionID, TYPE_ID, lastWorkerID); if (p instanceof ConvolutionListenerPersistable) { ConvolutionListenerPersistable clp = (ConvolutionListenerPersistable) p; BufferedImage bi = clp.getImg(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ImageIO.write(bi, "jpg", baos); } catch (IOException e) { log.warn("Error displaying image", e); } return ok(baos.toByteArray()).as("image/jpg"); } else { return ok(new byte[0]).as("image/jpeg"); } } else { return ok(new byte[0]).as("image/jpeg"); } } }
@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 currentSession() { String sid = currentSessionID == null ? "" : currentSessionID; return ok(asJson(sid)).as(JSON); }
@BasicAuth public Result getIssueResults(Long issueId) { final ArrayList<ResultRepresentation> results = Lists.newArrayList(transform(reportService.getResultsPerIssue(issueId), new Function<Pattern, ResultRepresentation>() { @Nullable @Override public ResultRepresentation apply(Pattern input) { return ResultRepresentation.toResultRepresentation(input); } })); return ok(Json.toJson(results)).as("application/json"); }
private Result listSessions() { return Results.ok(asJson(knownSessionIDs.keySet())).as(JSON); }