String graphVertexId = UrlUtils.urlDecode(getAttributeString(request, "graphVertexId"));
String widthStr = getOptionalParameter(request, "width");
int[] boundaryDims = new int[]{200, 200};
Vertex artifactVertex = graph.getVertex(graphVertexId, authorizations);
if (artifactVertex == null) {
respondWithNotFound(response);
return;
}
if (widthStr != null) {
boundaryDims[0] = boundaryDims[1] = Integer.parseInt(widthStr);
response.setContentType("image/jpeg");
response.addHeader("Content-Disposition", "inline; filename=thumbnail" + boundaryDims[0] + ".jpg");
setMaxAge(response, EXPIRES_1_HOUR);
byte[] thumbnailData = artifactThumbnailRepository.getThumbnailData(artifactVertex.getId(), "poster-frame", boundaryDims[0], boundaryDims[1], user);
if (thumbnailData != null) {
LOGGER.debug("Cache hit for: %s (poster-frame) %d x %d", graphVertexId, boundaryDims[0], boundaryDims[1]);
ServletOutputStream out = response.getOutputStream();
out.write(thumbnailData);
out.close();
return;
}
}
StreamingPropertyValue rawPosterFrameValue = RAW_POSTER_FRAME.getPropertyValue(artifactVertex);
if (rawPosterFrameValue == null) {
LOGGER.warn("Could not find raw poster from for artifact: %s", artifactVertex.getId());
respondWithNotFound(response);
return;
}
InputStream in = rawPosterFrameValue.getInputStream();