Package com.apress.prospring.domain

Examples of com.apress.prospring.domain.Attachment


public class AttachmentController extends MultiActionController {

  private BlogManager blogManager;

  public ModelAndView handleDownload(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Attachment attachment = blogManager.getAttachment(RequestUtils.getRequiredIntParameter(request, "attachmentId"));

    response.setContentType(attachment.getContentType());
    response.addHeader("Content-disposition", "attachment; filename=" + attachment.getFileName());
    response.getOutputStream().write(attachment.getFileData());

    return null;
  }
View Full Code Here


  /* (non-Javadoc)
   * @see com.apress.prospring.data.AttachmentDao#delete(int)
   */
  public void delete(int attachmentId) {
    Attachment a = new Attachment();
    a.setAttachmentId(attachmentId);
    getHibernateTemplate().delete(a);
  }
View Full Code Here

  protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
    EntryForm form = (EntryForm)command;
    getBlogManager().saveEntry(form, SessionSecurityManager.getUser(request));
   
    if (form.getAttachment() != null) {
      Attachment attachment = new Attachment();
      attachment.setContentType("");
      attachment.setFileData(form.getAttachment());
      attachment.setFileName("attachment.txt");
      getBlogManager().attachToEntry(attachment, form.getEntryId());
    }

    return new ModelAndView(getSuccessView());
  }
View Full Code Here

    if (comment.getReplyTo().intValue() == 0) comment.setReplyTo(null);
    model.put("entry", new Integer(comment.getEntry()));
    getBlogManager().saveComment(comment, User.ROOT);
   
    if (comment.getAttachment() != null) {
      Attachment attachment = new Attachment();
      attachment.setContentType("");
      attachment.setFileData(comment.getAttachment());
      attachment.setFileName("attachment.txt");
      getBlogManager().attachToComment(attachment, comment.getCommentId());
    }
   
    return new ModelAndView(getSuccessView(), model);
  }
View Full Code Here

      BeanUtils.copyProperties(entry, entryForm);
      entry.setPostDate(new Date(entryForm.getPostDateTime()));
      getBlogManager().saveEntry(entry, SessionSecurityManager.getUser(request));

      if (entryForm.getAttachment() != null) {
        Attachment attachment = new Attachment();
        attachment.setContentType("");
        attachment.setFileData(entryForm.getAttachment().getFileData());
        attachment.setFileName("attachment.txt");
        getBlogManager().attachToEntry(attachment, entry.getEntryId());
      }
     
      forward = "posted";
    }
View Full Code Here

   
    /* (non-Javadoc)
     * @see org.springframework.jdbc.object.MappingSqlQuery#mapRow(java.sql.ResultSet, int)
     */
    protected Object mapRow(ResultSet rs, int rowNum) throws SQLException {
      Attachment attachment = new Attachment();
 
      attachment.setAttachmentId(rs.getInt("AttachmentId"));
      attachment.setContentType(rs.getString("ContentType"));
      attachment.setFileData(rs.getBytes("FileData"));
      attachment.setFileName(rs.getString("FileName"));
     
      return attachment;
    }
View Full Code Here

TOP

Related Classes of com.apress.prospring.domain.Attachment

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.