String userId = (String) getRequest().getAttributes().get("userId");
if(userId == null) {
throw new ActivitiException("No userId provided");
}
Picture picture = ActivitiUtil.getIdentityService().getUserPicture(userId);
String contentType = picture.getMimeType();
MediaType mediatType = MediaType.IMAGE_PNG;
if(contentType != null) {
if(contentType.contains(";")) {
contentType = contentType.substring(0, contentType.indexOf(";"));
}
mediatType = MediaType.valueOf(contentType);
}
InputRepresentation output = new InputRepresentation(picture.getInputStream(), mediatType);
getResponse().getCacheDirectives().add(CacheDirective.maxAge(28800));
return output;
}