Package org.apache.struts.upload

Examples of org.apache.struts.upload.FormFile


           fileVO.setTo(getTimestamp(endDay,endMonth,endYear,timeZone));
        }
      }

      // get file
      FormFile fileUpload = ((FileForm)form).getFile();
      // set file vo
      fileVO.setName(fileUpload.getFileName());
      fileVO.setFileSize(fileUpload.getFileSize());
      fileVO.setPhysicalFolder(Integer.parseInt(((FileForm)form).getUploadfolderid()));
      fileVO.setTitle(((FileForm)form).getTitle());
      fileVO.setDescription(((FileForm)form).getDescription());

      if(((FileForm)form).getAuthorid() != null && ((FileForm)form).getAuthorid().length() > 0)
        fileVO.setAuthorId(Integer.parseInt(((FileForm)form).getAuthorid()));

      if(((FileForm)form).getEntityid() != null && ((FileForm)form).getEntityid().length() > 0)
        fileVO.setRelateEntity(Integer.parseInt(((FileForm)form).getEntityid()));

      if(((FileForm)form).getIndividualid() != null && ((FileForm)form).getIndividualid().length() > 0)
        fileVO.setRelateIndividual(Integer.parseInt(((FileForm)form).getIndividualid()));

      fileVO.setRelatedFieldID(((FileForm)form).getRelatedFieldID());
      fileVO.setRelatedFieldValue(((FileForm)form).getRelatedFieldValue());
      fileVO.setRelatedTypeID(((FileForm)form).getRelatedTypeID());
      fileVO.setRelatedTypeValue(((FileForm)form).getRelatedTypeValue());
      fileVO.setVisibility(((FileForm)form).getAccess());
      fileVO.setCustomerView(((FileForm)form).getCustomerview());
      fileVO.setCompanyNews(((FileForm)form).getCompanynews());

      int userId = ((UserObject)session.getAttribute("userobject")).getIndividualID();
      fileVO.setCreatedBy(userId);
      fileVO.setOwner(userId);
      // call to file facade
      CvFileFacade fileFacade = new CvFileFacade();

      // set request back to jsp
        request.setAttribute(FileConstantKeys.TYPEOFFILE, FileConstantKeys.FILE);
        request.setAttribute(FileConstantKeys.CURRENTTAB, FileConstantKeys.DETAIL);
        request.setAttribute(FileConstantKeys.TYPEOFOPERATION, FileConstantKeys.ADD);
        request.setAttribute(FileConstantKeys.WINDOWID, "1");

      if (request.getParameter("closeornew").equals("close"))
      {
        request.setAttribute("closeWindow","true");
      }
      else
      {
        request.setAttribute("closeWindow","false");
      }

        FORWARD_final = FORWARD_savefile;

      try
      {
       int recordID=fileFacade.addFile(userId, fileVO.getPhysicalFolder(), fileVO, fileUpload.getInputStream(), dataSource);
       rowID=recordID;
      }
      catch(CvFileException e)
      {
        System.out.println("[Exception][SaveNewFileHandler.execute] Exception Thrown: "+e);
View Full Code Here


      int userId = userobjectd.getIndividualID();
      fileVO.setModifiedBy(userId);
      // call to file facade
      CvFileFacade fileFacade = new CvFileFacade();
      FormFile fileUpload = ((FileForm)form).getFile();

      if (fileUpload != null && !(fileUpload.equals("")))
      {
        fileVO.setName(fileUpload.getFileName());
        fileVO.setFileSize(fileUpload.getFileSize());
      }

      request.setAttribute(FileConstantKeys.TYPEOFFILE, FileConstantKeys.FILE);
      request.setAttribute(FileConstantKeys.CURRENTTAB, FileConstantKeys.DETAIL);
      request.setAttribute(FileConstantKeys.TYPEOFOPERATION, FileConstantKeys.EDIT);
      request.setAttribute(FileConstantKeys.WINDOWID, "1");
      request.setAttribute(FileConstantKeys.FFID, ""+fileVO.getFileId());

      if (request.getParameter("saveType").equals("save"))
        {
          request.setAttribute("bodycontent", "editdetailfile");
          FORWARD_final = FORWARD_editsavefile;
        }
        else // if (request.getParameter("saveType").equals("saveclose"))
        {
          request.setAttribute("bodycontent", null);
          FORWARD_final = FORWARD_editsaveclosefile;
        }
      try
      {
        fileFacade.updateFile(userId, otherFolderId, fileVO,fileUpload.getInputStream(), dataSource);

        if(fileUpload!=null && fileUpload.getFileName()!=null && (!fileUpload.getFileName().trim().equals("")) )  //CW: update the filename field to the new file name
        {

          ((FileForm)form).setFileInfo(fileUpload.getFileName());
        }
      }
      catch(CvFileException e)
      {
        System.out.println("[Exception][SaveEditFileHandler.execute] Exception Thrown: "+e);
View Full Code Here

      {

        UserObject userobjectd = (UserObject) session.getAttribute("userobject");
        int userid = userobjectd.getIndividualID();

        FormFile ff = (FormFile) fileform.getFile();
        String fileName = ff.getFileName();
        InputStream im = ff.getInputStream();

        CvFileFacade cvfile = new CvFileFacade();
        CvFileVO flvo = new CvFileVO();
        flvo.setTitle(fileName); //file name

        Calendar c = Calendar.getInstance();
        java.util.Date dt = c.getTime();
        DateFormat df = new SimpleDateFormat("MM_dd_yyyy_hh_mm_ss");
        String dateStamp = df.format(dt);

        flvo.setName("attachment_" + dateStamp +"_"+ fileName);
        flvo.setCreatedBy(userid);
        flvo.setOwner(userid);
        flvo.setAuthorId(userid);
        flvo.setFileSize((float) ff.getFileSize());

        CvFolderVO homeFolder = cvfile.getHomeFolder(userid, dataSource);
        int fileId = cvfile.addFile(userid, homeFolder.getFolderId(), flvo, im, dataSource);
        ArrayList fileList = new ArrayList();
        fileList.add(new DDNameValue(fileId+"#"+fileName,fileName));
View Full Code Here

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    // initialize new actionerror object
    ActionErrors errors = new ActionErrors();
    try {
      // file name
      FormFile file = this.getFile();

      String fileName = "";

      HttpSession session = request.getSession(true);
      String fEmployee = (String) session.getAttribute("FromEmployee");

      if (request.getParameter(FileConstantKeys.TYPEOFOPERATION).equals(FileConstantKeys.EDIT)) {
        fileName = this.getFileInfo();
        if (fileName == null || fileName.trim().length() == 0) {
          errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "File Name"));
        }
      } else if (file != null) {
        fileName = file.getFileName();
        if (fileName == null || fileName.trim().length() == 0) {
          errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "File Name"));
        }
      } else {
        if (fEmployee != null && !fEmployee.equals("EmployeeHandbook")) {
View Full Code Here

      CvFileFacade cvfile = new CvFileFacade();
      int literatureID = literatureForm.getLiteratureID();
      int prevFileID = literatureForm.getFileID();
      int fileID = 0;

      FormFile ff = (FormFile) literatureForm.getFile();

      if (ff.getFileSize() > 0) {
        String strf = ff.getFileName();
        InputStream im = ff.getInputStream();

        //Add file first
        CvFileVO flvo = new CvFileVO();
        flvo.setTitle("Literature"); //file name
        flvo.setName(strf);
View Full Code Here

      if (request.getParameter("buttonpress") != null) {
        typeOfSave = request.getParameter("buttonpress");
        String fileName = "";
        File fsRoot = CVUtility.getCentraViewFileSystemRoot(dataSource);
        if (typeOfSave != null && typeOfSave.equals("save")) {
          FormFile fileUpload = ((CustomerLogoForm)form).getFile();
          File logoFile = new File(fsRoot.getAbsolutePath() + Constants.CUSTOMERLOGO_PATH + fileUpload.getFileName());
          FileOutputStream fos = new FileOutputStream(logoFile);
          InputStream fis = fileUpload.getInputStream();
          try {
            int i = 0;
            while ((i = fis.read()) != -1) {
              fos.write(i);
            }
            siteInfo.setCustomerLogo(logoFile);
            siteInfo.setCustomerLogoDirty(true);
          } catch (IOException e) {
            logger.error("[execute] Exception thrown.", e);
          } finally {
            fis.close();
            fos.close();
          }
          fileName = fileUpload.getFileName();
        } else if (typeOfSave != null && typeOfSave.equals("delete")) {
          fileName = "logo_customer.gif";
          File logoFile = new File(fsRoot.getAbsolutePath() + Constants.CUSTOMERLOGO_PATH + fileName);
          siteInfo.setCustomerLogo(logoFile);
          siteInfo.setCustomerLogoDirty(true);
View Full Code Here

    try
    {
      // initialize validation
      Validation validation = new Validation();
      request.getParameter("file");
      FormFile fileUpload = this.getFile();
      String filename = fileUpload.getFileName();
      String customerlogo = this.getCustomerlogo();
      int index = filename.indexOf(".");
      String strfile = filename.substring(index + 1, filename.length());
      if (strfile.length() != 0 && (!(strfile.equalsIgnoreCase("jpg") || strfile.equalsIgnoreCase("gif") || strfile.equalsIgnoreCase("png"))))
      {
View Full Code Here

        FileForm fileform = (FileForm) form;
        UserObject userobjectd = (UserObject) session.getAttribute("userobject");
        int userid = userobjectd.getIndividualID();
        ListPreference listpreference = userobjectd.getListPreference("Email");

        FormFile ff = (FormFile) fileform.getFile();
        String strf = ff.getFileName();
        InputStream im = ff.getInputStream();

        CvFileFacade cvfile = new CvFileFacade();
        CvFileVO flvo = new CvFileVO();
        flvo.setTitle(strf); //file name

    Calendar c = Calendar.getInstance();
    java.util.Date dt = c.getTime();
    DateFormat df = new SimpleDateFormat("MM_dd_yyyy_hh_mm_ss");
    String dateStamp = df.format(dt);

    strf = "attachment_" + dateStamp +"_"+ strf;
        flvo.setName(strf);
        flvo.setCreatedBy(userid);
        flvo.setOwner(userid);
        flvo.setAuthorId(userid);
        flvo.setFileSize((float) ff.getFileSize());

        CvFolderVO homeFolder = cvfile.getHomeFolder(userid, dataSource);
        int xxx = cvfile.addFile(userid, homeFolder.getFolderId(), flvo, im, dataSource);
        //int xxx = cvfile.addEmailAttachment(userid, flvo, im, dataSource);
View Full Code Here

      ListMemberForm dyn = (ListMemberForm) session.getAttribute("importListForm");
      UserObject userobject = (UserObject) session.getAttribute("userobject");
      int indvID = userobject.getIndividualID();

      FormFile ff = dyn.getTheFile();
      String strf = ff.getFileName();
      InputStream im = ff.getInputStream();

      CvFileFacade cvfile = new CvFileFacade();
      CvFileVO flvo = new CvFileVO();
      flvo.setTitle("EmailAttachment");
      flvo.setName(strf);
View Full Code Here

         {
            FileForm fileform = (FileForm) form;
            UserObject userobjectd = (UserObject) session.getAttribute("userobject");
            int userid = userobjectd.getIndividualID();

            FormFile ff = (FormFile) fileform.getFile();
            String strf = ff.getFileName();
            InputStream im = ff.getInputStream();

            CvFileFacade cvfile = new CvFileFacade();
            CvFileVO flvo = new CvFileVO();
            flvo.setTitle(strf); //file name

            Calendar c = Calendar.getInstance();
            java.util.Date dt = c.getTime();
            DateFormat df = new SimpleDateFormat("MM_dd_yyyy_hh_mm_ss");
            String dateStamp = df.format(dt);

            strf = "attachment_" + dateStamp +"_"+ strf;
            flvo.setName(strf);
            flvo.setCreatedBy(userid);
            flvo.setOwner(userid);
            flvo.setAuthorId(userid);
            flvo.setFileSize((float) ff.getFileSize());

            CvFolderVO homeFolder = cvfile.getHomeFolder(userid, dataSource);
            int xxx = cvfile.addFile(userid, homeFolder.getFolderId(), flvo, im, dataSource);
            flvo = cvfile.getFile(userid, xxx, dataSource);
View Full Code Here

TOP

Related Classes of org.apache.struts.upload.FormFile

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.