Package com.liusoft.dlog4j.formbean

Examples of com.liusoft.dlog4j.formbean.PhotoForm


   */
  protected ActionForward doRecommend(final ActionMapping mapping,
      final ActionForm form, final HttpServletRequest request,
      final HttpServletResponse response, String s_photo_id) throws Exception      
  {
    PhotoForm pform = (PhotoForm)form;
    super.validateClientId(request, pform);
   
    ActionMessages msgs = new ActionMessages();
    do{
      SessionUserObject loginUser = super.getLoginUser(request,response,false);
      if(loginUser==null){
        msgs.add("photo", new ActionMessage("error.user_not_login"));
        break;
      }
      PhotoOutlineBean pbean = PhotoDAO.getPhotoOutlineByID(pform.getId());
      if(pbean==null||pbean.getStatus()!=PhotoBean.STATUS_NORMAL){
        msgs.add("photo", new ActionMessage("error.invalid_photo", new Integer(pform.getId())));
        break;
      }
      //�����ʼ�
      String s_mails = request.getParameter("mails");     
      String[] emails = StringUtils.split(s_mails, ";",MAX_MAIL_COUNT);
View Full Code Here


   */
  protected ActionForward doDelete(final ActionMapping mapping,
      final ActionForm form, final HttpServletRequest request,
      final HttpServletResponse response, String s_photo_id) throws Exception      
  {
    PhotoForm photo = (PhotoForm)form;
    //ɾ����Ƭ�ļ�
    int photo_id = Integer.parseInt(s_photo_id);
    PhotoBean pbean = PhotoDAO.getPhotoByID(photo_id);
    String ext = null;
    if(pbean != null){
      HttpContext context = getHttpContext(mapping, form, request, response);
      getPhotoSaver().delete(context, pbean.getImageURL());
      if(!pbean.getPreviewURL().equals(pbean.getImageURL()))
        getPhotoSaver().delete(context, pbean.getPreviewURL());
      //ɾ�����ݿ���Ϣ
      PhotoDAO.delete(pbean);
      SearchProxy.remove(pbean);
      ext = "aid="+pbean.getAlbum().getId();
    }
    return makeForward(mapping.findForward("photo_album"), photo.getSid(), ext);
  }
View Full Code Here

   */
  protected ActionForward doUpload(final ActionMapping mapping,
      final ActionForm form, final HttpServletRequest request,
      final HttpServletResponse response) throws Exception      
  {
    PhotoForm photo1 = (PhotoForm)form;
    validateClientId(request, photo1);
   
    ActionMessages msgs = new ActionMessages();
    do{
      FormFile[] files = new FormFile[5];
      files[0] = photo1.getImage();
      files[1] = photo1.getImage2();
      files[2] = photo1.getImage3();
      files[3] = photo1.getImage4();
      files[4] = photo1.getImage5();
     
      //����ಾ�Ƿ���Ч
      AlbumBean album = AlbumDAO.getAlbumByID(photo1.getAlbum());
      if (album == null) {
        msgs.add(ERROR_KEY, new ActionMessage(
            "error.object_not_found", String.valueOf(photo1
                .getAlbum())));
        break;
      }

      SiteBean site = super.getSiteBean(request);
      UserBean loginUser = super.getLoginUserAfterValidateSiteOwner(request);

      String photo_desc;
      if(StringUtils.isNotEmpty(photo1.getDesc())){
        photo_desc = StringUtils.abbreviate(super.autoFiltrate(
            site, photo1.getDesc()), MAX_PHOTO_DESC_LENGTH);
        photo_desc = super.filterScriptAndStyle(photo_desc);
      }
      else
        photo_desc = " ";
     
      for(int i=0;i<files.length;i++){
        if(files[i]==null || files[i].getFileSize()<=0 || StringUtils.isEmpty(files[i].getFileName()))
          continue;
        //�жϵ���ͼƬ�Ĵ�С
        /*
        if(files[i].getFileSize()>4194304){//4*1024*1024
          msgs.add(ERROR_KEY, new ActionMessage("error.file_too_large"));
          break;
        }*/
        if(!accept(files[i])){
          msgs.add(ERROR_KEY, new ActionMessage("error.upload_file_not_supported"));
          break;
        }
        //����ϴ��ռ�����
        int photo_size = DLOG4JUtils.sizeInKbytes(files[i].getFileSize());
        int max_photo_size = site.getCapacity().getPhotoTotal();
        if(max_photo_size >= 0){       
          int current_size = site.getCapacity().getPhotoUsed();
          if((current_size + photo_size) > max_photo_size){
            msgs.add(ERROR_KEY, new ActionMessage("error.photo_space_full"));
            break;
          }
        }
        //������Ƭ����������ͼ
        Photo img = null;
        try{
          img = getPhotoSaver().save(
              getHttpContext(mapping, form, request, response),
              files[i], photo1.getAutoRotate() == 1);
          if(img == null){
            msgs.add(ERROR_KEY, new ActionMessage("error.upload_failed"));
            break;       
          }
          //д�뵽���ݿ�
          PhotoBean pbean = new PhotoBean();
          pbean.setSite(site);
          pbean.setUser(loginUser);
          if(StringUtils.isNotEmpty(photo1.getName())){
            pbean.setName(super.autoFiltrate(site, photo1.getName()));
          }
          else
            pbean.setName(img.getName());
          pbean.setDesc(photo_desc);
          if(StringUtils.isNotEmpty(photo1.getKeyword())){
            if(site.isFlagSet(SiteBean.Flag.ILLEGAL_GLOSSARY_IGNORE))
              pbean.setKeyword(photo1.getKeyword());
            else
              pbean.setKeyword(DLOGSecurityManager.IllegalGlossary
                  .deleteIllegalWord(photo1.getKeyword()));
          }
          pbean.setPreviewURL(img.getPreviewURL());
          pbean.setImageURL(img.getImageURL());
         
          pbean.setPhotoInfo(img);
          pbean.setFileName(super.autoFiltrate(site,img.getFileName()));
          pbean.setStatus(photo1.getStatus());//������������
          PhotoDAO.create(album, pbean, (photo1.getCover()==1));
        }catch(IllegalAccessException e){
          msgs.add(ERROR_KEY, new ActionMessage("error.access_deny", e.getMessage()));
          break;
        }catch(Exception e){
          log.error("Upload photo file failed.", e);
          msgs.add(ERROR_KEY, new ActionMessage("error.upload_failed", e.getMessage()));
          break;
        }
      }
      break;
    }while(true);
   
    if(!msgs.isEmpty()){
      saveMessages(request, msgs);
      ActionForward upload = makeForward(mapping.findForward("photo_upload"), photo1.getSid());
      upload.setRedirect(false);
      return upload;
    }
    String ext = "aid=" + photo1.getAlbum();
    return makeForward(mapping.findForward("photo_album"), photo1.getSid(), ext);
  }
View Full Code Here

   */
  protected ActionForward doUpdate(final ActionMapping mapping,
      final ActionForm form, HttpServletRequest request,
      final HttpServletResponse response) throws Exception      
  {
    PhotoForm photo = (PhotoForm)form;
    validateClientId(request, photo);
    ActionMessages msgs = new ActionMessages();
   
    if(StringUtils.isEmpty(photo.getName()))
      msgs.add("name", new ActionMessage("error.photo.name_empty"));
    else{
      PhotoBean pbean = PhotoDAO.getPhotoByID(photo.getId());
      if(pbean != null){
        if(!StringUtils.equals(pbean.getName(), photo.getName())){
          pbean.setName(super.autoFiltrate(pbean.getSite(), photo.getName()));
        }
       
        if(!StringUtils.equals(pbean.getDesc(),photo.getDesc())){
          String desc = StringUtils.abbreviate(super.autoFiltrate(
              pbean.getSite(), photo.getDesc()),
              MAX_PHOTO_DESC_LENGTH);
          pbean.setDesc(super.filterScriptAndStyle(desc));
        }
        else
          pbean.setDesc(" ");
        pbean.setStatus(photo.getStatus());
        int new_album = photo.getAlbum();
        String new_Keyword = photo.getKeyword();
        if(!pbean.getSite().isFlagSet(SiteBean.Flag.ILLEGAL_GLOSSARY_IGNORE))
          new_Keyword = DLOGSecurityManager.IllegalGlossary.deleteIllegalWord(new_Keyword);
        PhotoDAO.update(new_album, pbean, new_Keyword, (photo.getCover()==1));
      }
    }
   
    if(!msgs.isEmpty()){
      saveMessages(request, msgs);
      return mapping.findForward("photo_edit");
    }
   
    String ext = "aid=" + photo.getAlbum() +"&pid=" + photo.getId();
    return makeForward(mapping.findForward("photo_show"), photo.getSid(), ext);
  }
View Full Code Here

TOP

Related Classes of com.liusoft.dlog4j.formbean.PhotoForm

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.