Package com.apress.prospring3.springblog.domain

Examples of com.apress.prospring3.springblog.domain.Comment


    for (Entry entry: entries) {
      System.out.println(entry);
    }
   
    System.out.println("Finding entry with id 1");
    Entry entry = entryService.findById(1l);
    System.out.println(entry);
   
    // insert entry
    entry = new Entry();
    //entry.setSubject("Testing entry clarence");
    entry.setSubject("Testing");
    entry.setBody("Testing entry clarence");
    entry.setPostDate(new DateTime());
    entry.setCategoryId("Spring");
    entryService.save(entry);
    System.out.println("New entry insert successfully");
   
        entries = entryService.findByCategoryId("Spring");
   
    for (Entry entryTemp: entries) {
      System.out.println(entryTemp);
    }   
   
    // Delete entry
    System.out.println("Deleting entry with id 2");
    entry = entryService.findById(2l);
    entryService.delete(entry);
   
        entries = entryService.findByCategoryId("Spring");
   
    for (Entry entryTemp: entries) {
      System.out.println(entryTemp);
   
   
    // Update entry
    System.out.println("Updating entry with id 1");
    entry = entryService.findById(1l);
    entry.setSubject("Updated entry subject crap");
    entryService.save(entry);
    System.out.println("Entry updated successfully");
   
        entries = entryService.findByCategoryId("Spring");
   
View Full Code Here


            return "blogs/" + UrlUtil.encodeUrlPathSegment(blogid.toString(), httpServletRequest) + "/comments/create";
        }
        uiModel.asMap().clear();
        redirectAttributes.addFlashAttribute("message", new Message("success", messageSource.getMessage("comment_save_success", new Object[]{}, locale)));
       
        Entry entry = entryService.findById(blogid);
        logger.info("Comment id: " + comment.getId());
        comment.setId(null);
        comment.setEntry(entry);
        commentService.save(comment);
        return "redirect:/blogs/" + UrlUtil.encodeUrlPathSegment(blogid.toString(), httpServletRequest);
View Full Code Here

        return "redirect:/blogs/" + UrlUtil.encodeUrlPathSegment(blogid.toString(), httpServletRequest);
    }

  @RequestMapping(params = "form", method = RequestMethod.GET)
    public String createForm(Model uiModel, @PathVariable("blogid") Long blogid, HttpServletRequest httpServletRequest) {
    Entry entry = entryService.findById(blogid);
        uiModel.addAttribute("entry", entry);
       
        Comment comment = new Comment();
    comment.setPostDate(new DateTime());
    comment.setPostBy(auditorAwareBean.getCurrentAuditor());
View Full Code Here

            return "blogs/" + UrlUtil.encodeUrlPathSegment(blogid.toString(), httpServletRequest) + "/comments/update";
        }
        uiModel.asMap().clear();
        redirectAttributes.addFlashAttribute("message", new Message("success", messageSource.getMessage("comment_save_success", new Object[]{}, locale)));       
       
        Entry entry = entryService.findById(blogid);
        comment.setEntry(entry);
        commentService.save(comment);
        return "redirect:/blogs/" + UrlUtil.encodeUrlPathSegment(blogid.toString(), httpServletRequest);
    }
View Full Code Here

    return "blogs/list";
  }
 
  @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public String show(@PathVariable("id") Long id, Model uiModel) {
        Entry entry = entryService.findById(id);
    uiModel.addAttribute("entry", entry);
        UploadItem uploadItem = new UploadItem();
        uploadItem.setBlogId(entry.getId());
        uiModel.addAttribute("uploadItem", uploadItem);
        return "blogs/show";
   
View Full Code Here

    }

  @PreAuthorize("isAuthenticated()")
  @RequestMapping(params = "form", method = RequestMethod.GET)
    public String createForm(Model uiModel) {
    Entry entry = new Entry();
        uiModel.addAttribute("entry", entry);
        populateSelectBox(uiModel, entry);
        return "blogs/create";
    }
View Full Code Here

        EntryAttachment entryAttachment = new EntryAttachment();
        entryAttachment.setFileName(getFileName(file));
        entryAttachment.setFileData(IOUtils.toByteArray(file.getInputStream()));
        entryAttachment.setContentType(file.getContentType());
       
        Entry entry = entryService.findById(blogId);
        entryAttachment.setEntry(entry);
        entry.addAttachment(entryAttachment);
        entryService.save(entry);
      } else {
        // Construct Attachment object
        CommentAttachment commentAttachment = new CommentAttachment();
        commentAttachment.setFileName(getFileName(file));
View Full Code Here

    List<Number> revisions = auditReader.getRevisions(Entry.class, id);
   
    revisions = Lists.reverse(revisions);

    List<Entry> entries = new ArrayList<Entry>();
    Entry entry;
    for (Number revision: revisions) {
      entry = auditReader.find(Entry.class, id, revision);
      entries.add(entry);
    }
    return entries;
View Full Code Here

    Message message;

    if (file.getSize() > 0) {
      if (uploadType.equalsIgnoreCase("entry")) {
        // Construct Attachment object
        EntryAttachment entryAttachment = new EntryAttachment();
        entryAttachment.setFileName(getFileName(file));
        entryAttachment.setFileData(IOUtils.toByteArray(file.getInputStream()));
        entryAttachment.setContentType(file.getContentType());
       
        Entry entry = entryService.findById(blogId);
        entryAttachment.setEntry(entry);
        entry.addAttachment(entryAttachment);
        entryService.save(entry);
      } else {
        // Construct Attachment object
        CommentAttachment commentAttachment = new CommentAttachment();
View Full Code Here

  @RequestMapping(value = "/entry/{id}", method=RequestMethod.GET, produces="application/force-download")
  @ResponseBody
  public byte[] downloadEntryAttachment(@PathVariable("id") Long id, HttpServletRequest request, HttpServletResponse response) {
    logger.info("Processing download for entry attachment with id {}", id);
   
    EntryAttachment attachment = entryAttachmentService.findById(id);
   
        response.setContentType(attachment.getContentType());
        response.setContentLength(attachment.getFileData().length);
        response.setHeader("Content-Disposition","attachment; filename=\"" + attachment.getFileName() +"\"");
   
    return attachment.getFileData();
  }
View Full Code Here

TOP

Related Classes of com.apress.prospring3.springblog.domain.Comment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.