@Override
public Node postMedia(MimeType mimeType, String slug, InputStream inputStream, RequestContext request)
throws ResponseContextException {
if (slug == null) {
throw new ResponseContextException("A slug header must be supplied.", 500);
}
Node n = postEntry(slug, null, null, new Date(), null, null, request);
try {
n.setProperty(MEDIA, inputStream);
n.setProperty(CONTENT_TYPE, mimeType.toString());
String summary = postSummaryForEntry(n);
if (summary != null) {
n.setProperty(SUMMARY, summary);
}
getSession(request).save();
return n;
} catch (RepositoryException e) {
try {
getSession(request).refresh(false);
} catch (Throwable t) {
log.warn(t);
}
throw new ResponseContextException(500, e);
}
}