Content content, Session session)
throws ResponseContextException, RepositoryException {
if (title == null) {
EmptyResponseContext ctx = new EmptyResponseContext(500);
ctx.setStatusText("Entry title cannot be empty.");
throw new ResponseContextException(ctx);
}
entry.setProperty(TITLE, title);
if (summary != null) {
entry.setProperty(SUMMARY, summary);
}
Calendar upCal = Calendar.getInstance();
upCal.setTime(updated);
entry.setProperty(UPDATED, upCal);
if (authors != null) {
for (Person p : authors) {
Node addNode = entry.addNode(AUTHOR);
addNode.setProperty(AUTHOR_EMAIL, p.getEmail());
addNode.setProperty(AUTHOR_LANGUAGE, p.getLanguage());
addNode.setProperty(AUTHOR_NAME, p.getName());
}
}
if (content != null) {
switch(content.getContentType()) {
case TEXT:
entry.setProperty(CONTENT, content.getText());
entry.setProperty(CONTENT_TYPE, Type.TEXT.toString());
break;
case XHTML:
entry.setProperty(CONTENT, asString(content));
entry.setProperty(CONTENT_TYPE, Type.XHTML.toString());
break;
default:
throw new ResponseContextException("Invalid content element type.", 500);
}
}
if (summary != null) {
entry.setProperty(SUMMARY, summary);