Package com.apress.prospring3.springblog

Examples of com.apress.prospring3.springblog.MyBatisTest


   
    System.out.println("App context initialized successfully");       

    UserService userService = ctx.getBean("userService", UserService.class);
   
    AppUser appUser = userService.findByUserName("clarence");
   
    System.out.println("User name: " + appUser.getUserName());
  }
View Full Code Here


    logger.info("Loading user record for user name: {}", userName);
   
    UserDetails userDetails = null;  
   
    AppUser user = userService.findByUserName(userName);
   
    if (user != null) {
     
      String password = user.getPassword();
           
            Set<Role> roles = user.getRoles();
            List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
            for (Role role: roles) {
                String roleName = role.getRoleId();
                GrantedAuthority grantedAuthority = new SimpleGrantedAuthority(roleName);
                authorities.add(grantedAuthority);
View Full Code Here

    public void filterObscenities(JoinPoint joinPoint)
            throws Throwable {
      Object[] args = joinPoint.getArgs();
        for (int x = 0; x < args.length; x++) {
            if (args[x] instanceof BlogPosting) {
                BlogPosting arg = (BlogPosting) args[x];
                if (obscenityFilter.containsObscenities(arg.getBody())) {
                    arg.setBody(obscenityFilter.obfuscateObscenities(arg.getBody()));
                }
                if (obscenityFilter.containsObscenities(arg.getSubject())) {
                    arg.setSubject(obscenityFilter
                            .obfuscateObscenities(arg.getSubject()));
                }
            }
        }
    }
View Full Code Here

  @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());
        uiModel.addAttribute("comment", comment);
        populateSelectBox(uiModel, blogid);
        return "blogs/" + UrlUtil.encodeUrlPathSegment(blogid.toString(), httpServletRequest) + "/comments/create";
   
View Full Code Here

        CommentAttachment commentAttachment = new CommentAttachment();
        commentAttachment.setFileName(getFileName(file));
        commentAttachment.setFileData(IOUtils.toByteArray(file.getInputStream()));
        commentAttachment.setContentType(file.getContentType())
       
        Comment comment = commentService.findById(commentId);
        commentAttachment.setComment(comment);
        comment.addAttachment(commentAttachment);
        commentService.save(comment);
      }

      message = new Message("success", "File '" + getFileName(file)
          + "' uploaded successfully");
View Full Code Here

        entryAttachment.setEntry(entry);
        entry.addAttachment(entryAttachment);
        entryService.save(entry);
      } else {
        // Construct Attachment object
        CommentAttachment commentAttachment = new CommentAttachment();
        commentAttachment.setFileName(getFileName(file));
        commentAttachment.setFileData(IOUtils.toByteArray(file.getInputStream()));
        commentAttachment.setContentType(file.getContentType())
       
        Comment comment = commentService.findById(commentId);
        commentAttachment.setComment(comment);
        comment.addAttachment(commentAttachment);
        commentService.save(comment);
      }

      message = new Message("success", "File '" + getFileName(file)
View Full Code Here

  @RequestMapping(value = "/comment/{id}", method=RequestMethod.GET, produces="application/force-download")
  @ResponseBody
  public byte[] downloadCommentAttachment(@PathVariable("id") Long id, HttpServletRequest request, HttpServletResponse response) {
    logger.info("Processing download for comment attachment with id {}", id);
   
    CommentAttachment attachment = commentAttachmentService.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

  private EntryService entryService;
 
  @RequestMapping(value = "/listdata", method = RequestMethod.GET)
  @ResponseBody
  public Entries listData() {
    return new Entries(entryService.findAll());
  }
View Full Code Here

  @Autowired
  private EntryService entryService;
 
  @Test
  public void testInsert() {
    Entry entry = new Entry();
    entry.setSubject("Testing entry clarence");
    entry.setBody("Testing entry clarence");
    entry.setPostDate(new DateTime());
    entry.setCategoryId("Spring");
    entry.setCreatedBy("prospring3");
    entry.setCreatedDate(new DateTime());
    entry.setLastModifiedBy("prospring3");
    entry.setLastModifiedDate(new DateTime());   
    entryService.save(entry);
System.out.println("Entry: " + entry);   
  }
View Full Code Here

    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.setBody("Testing entry clarence");
    entry.setPostDate(new DateTime());
    entry.setCategoryId("Spring");
    entry.setCreatedBy("clarence");
    DateTime currentDateTime = new DateTime();
    entry.setCreatedDate(currentDateTime);
    entry.setLastModifiedBy("clarence");
    entry.setLastModifiedDate(currentDateTime);
    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");
    currentDateTime = new DateTime();
    entry.setLastModifiedDate(currentDateTime);
    entryService.save(entry);
    System.out.println("Entry updated successfully");
   
        entries = entryService.findByCategoryId("Spring");
   
View Full Code Here

TOP

Related Classes of com.apress.prospring3.springblog.MyBatisTest

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.