*/
@POST
@Path("createDocument")
public Object createDocument(@Context HttpServletRequest request)
throws Exception {
CoreSession session = ctx.getCoreSession();
FormData formData = new FormData(request);
String type = formData.getDocumentType();
String title = formData.getDocumentTitle();
DocumentRef docRef = getDocumentRef(formData.getString("docRef"));
DocumentModel parent = session.getDocument(docRef);
DocumentModel newDoc = session.createDocumentModel(
parent.getPathAsString(), title, type);
formData.fillDocument(newDoc);
newDoc = session.createDocument(newDoc);
session.save();
if (newDoc.isFolder()) {
return buildDocumentList(newDoc.getId(), 0, 0, null);
} else {
return buildDocumentList(parent.getId(), 0, 0, null);
}