entry.addLink(entry.getId().toString(), "self");
feed.getRoot().insertEntry(entry);
response.setStatus(HttpServletResponse.SC_CREATED);
response.setHeader("Location", entry.getId().toString());
response.setHeader("Content-Location", entry.getId().toString());
WriterOptions woptions = entry.getDefaultWriterOptions();
woptions.setCharset("UTF-8");
entry.writeTo(response.getOutputStream(),woptions);
return;
}
}
if (MimeTypeHelper.isMatch(request.getContentType(), "text/plain")) {
int n = feed.getRoot().getEntries().size();
String media = read(request.getInputStream());
Entry entry = getFactory().newEntry();
String newID = AppTest.INSTANCE.getBase() + "/collections/entries/" + n;
String slug = request.getHeader("Slug");
entry.setId(newID);
entry.setTitle(slug);
entry.setUpdated(new Date());
entry.setSummary(slug);
entry.addLink(entry.getId().toString(), "edit");
entry.addLink(AppTest.INSTANCE.getBase() + "/collections/media/" + n, "edit-media").setMimeType("text/plain");
entry.addLink(entry.getId().toString(), "self");
entry.setContent(new IRI(AppTest.INSTANCE.getBase() + "/collections/media/" + n), "text/plain");
feed.getRoot().insertEntry(entry);
this.media.put(entry.getId().toString(), media);
response.setStatus(HttpServletResponse.SC_CREATED);
response.setHeader("Location", entry.getId().toString());
response.setHeader("Content-Location", entry.getId().toString());
WriterOptions woptions = entry.getDefaultWriterOptions();
woptions.setCharset("UTF-8");
entry.writeTo(response.getOutputStream(),woptions);
return;
}
response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
} catch (Exception e) {}