Exemplo n.º 1
0
  public static void ajaxEditDocument(Long documentId, String newTitle, String newContent) {
    Document document = Document.findById(documentId);
    document.changeSubject(newTitle);

    Config config = Config.getInstance();
    User currentUser = User.findById(config.getSingedInUserId());
    Version newVersion = new Version(currentUser, document, newContent).save();
    System.out.println("* A new version is successfully created.");

    document.addVersion(newVersion);
    document.save();
  }
Exemplo n.º 2
0
 public static void ajaxDeleteDocument(Long documentId) {
   // If it is not the root document we are going to delete
   if (documentId != 0L) {
     Document document = Document.findById(documentId);
     List<Document> children =
         Document.find("select p from Document p where p.parentId=?", document.id).fetch();
     // If target document contains children documents
     // then remove all children, don't leave scala documents
     int i = 0;
     for (i = 0; i < children.size(); i++) {
       children.get(i).delete();
     }
     document.delete();
   }
 }