Package com.centraview.file

Examples of com.centraview.file.CvFolderVO


        emailForm.set("cc", cc.toString());
      } // end if (replyToAll != null && replyToAll.booleanValue())

      ArrayList attachmentMap = new ArrayList();
      if (saveOrigBodyAsAttachment) {
        CvFolderVO attachmentFolderVO = remote.getAttachmentFolder(individualID);
        int attachmentFolderID = attachmentFolderVO.getFolderId();
        int newFileID = -1;

        // somehow create a file using CvFileFacade, and get a CvFileVO from
        // that.
        CvFileVO fileVO = new CvFileVO();
View Full Code Here


        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));

        String[] files = fileform.getFileList();
        if(files != null){
View Full Code Here

    Vector viewColumns = view.getColumns();
    ArrayList columns = new ArrayList();   
    ActionUtil.mapOldView(columns, viewColumns, ValueListConstants.EMPLOYEE_HANDBOOK_LIST_TYPE);
    listParameters.setColumns(columns);
   
    CvFolderVO folder = null;
    try {
      CvFileHome home = (CvFileHome)CVUtility.getHomeObject("com.centraview.file.CvFileHome", "CvFile");
      CvFile remote = (CvFile)home.create();
      remote.setDataSource(dataSource);
      folder = remote.getFolderByName(individualId, 2, "CV_EMPLOYEEHANDBOOK_DEFAULT_FOLDER");
    } catch (Exception e) {
      logger.error("Exception thrown in EmployeeHandbookValueListAction");
      e.printStackTrace();
    }
    int folderID = folder.getFolderId();
/*    String param = request.getParameter("folderId");
    if (param != null) {
      if (param.indexOf("*") == -1)
        folderID = Integer.parseInt(param);
      else
View Full Code Here

            CvFileHome homeFile = (CvFileHome)CVUtility.getHomeObject(
                "com.centraview.file.CvFileHome", "CvFile");
            CvFile remoteFile = homeFile.create();
            remoteFile.setDataSource(dataSource);

            CvFolderVO homeFld = remoteFile.getHomeFolder(individualID);

            int rn = (new Random()).nextInt();
            Calendar c = Calendar.getInstance();
            java.util.Date dt = c.getTime();
            DateFormat df = new SimpleDateFormat("MM_dd_yyyy");
            String dateStamp = df.format(dt);

            CvFileVO flvo = new CvFileVO();
            flvo.setTitle("Print Template_" + rn);
            flvo.setName("Template_" + "_" + rn + "_" + dateStamp + ".html");
            Message[1] = "Template_" + "_" + rn + "_" + dateStamp + ".html";

            flvo.setPhysicalFolder(homeFld.getFolderId());
            flvo.setIsTemporary("NO");
            flvo.setOwner(individualID);
            flvo.setPhysical(CvFileVO.FP_PHYSICAL);
            StringBuffer documentContent = new StringBuffer();

            for (int i = 0; i < ptContent.size(); i++) {
              documentContent.append(ptContent.get(i));
              if (i != (ptContent.size() - 1)) {
                documentContent.append("<br><<Page Break>><br>");
              }
            }
            ByteArrayInputStream inputStream = new ByteArrayInputStream(documentContent.toString()
                .getBytes());
            // Add the File to the Files Module so that we can download it...
            int fileId = cvf.addFile(individualID, homeFld.getFolderId(), flvo, inputStream,
                dataSource);
            Message[2] = String.valueOf(fileId);
          } catch (Exception e) {
            logger.error("[execute] Exception thrown.", e);
          }
View Full Code Here

    File returnFile = null;
    try {
      CvFileHome fileHome = (CvFileHome) getHomeObject("com.centraview.file.CvFileHome", "CvFile");
      CvFile fileRemote = fileHome.create();
      fileRemote.setDataSource(dataSource);
      CvFolderVO rootFolder = fileRemote.getFolder(-13, 1);
      returnFile = new File(rootFolder.getLocationName());
    } catch (Exception e) {
      logger.error("[getCentraViewFileSystemRoot] Exception thrown.", e);
    }
    return returnFile;
  }
View Full Code Here

        String fileName = fileVO.getTitle();
        attachmentMap.add(new DDNameValue(fileID+"#"+fileName,fileName));
      }

      if (saveOrigBodyAsAttachment) {
        CvFolderVO attachmentFolderVO = (CvFolderVO)remote.getAttachmentFolder(individualID);
        int attachmentFolderID = attachmentFolderVO.getFolderId();
        int newFileID = -1;

        // somehow create a file using CvFileFacade, and get a CvFileVO from that.
        CvFileVO fileVO = new CvFileVO();
        SimpleDateFormat df = new SimpleDateFormat("MMMM_dd_yyyy_hh_mm_ss_S");
View Full Code Here

   */
  private int deleteMessageAttachments(int individualID, int messageID, CVDal cvdal)
  {
    int numberDeleted = 0;
    CvFileFacade fileFacade = new CvFileFacade();
    CvFolderVO attachmentFolder = getAttachmentFolder(individualID);

    String selectQuery = "SELECT AttachmentID, FileID FROM attachment WHERE MessageID = ?";
    cvdal.setSqlQuery(selectQuery);
    cvdal.setInt(1, messageID);

    Collection resultsCollection = cvdal.executeQuery();
    cvdal.setSqlQueryToNull();

    String deleteQuery = "DELETE FROM attachment WHERE AttachmentID = ?";
    cvdal.setSqlQuery(deleteQuery);

    if (resultsCollection != null) {
      Iterator resultsIterator = resultsCollection.iterator();
      while (resultsIterator.hasNext()) {
        HashMap resultsHashMap = (HashMap) resultsIterator.next();
        Number fileID = (Number) resultsHashMap.get("FileID");
        Number attachmentID = (Number) resultsHashMap.get("AttachmentID");
        try {
          fileFacade.deleteFile(individualID, fileID.intValue(), attachmentFolder.getFolderId(), this.dataSource);
        } catch (Exception e) {
          logger.error("Exception in deleteMessageAttachments");
          e.printStackTrace();
        }

View Full Code Here

   * @param individualID The User to find the attachment folder for.
   * @return A populated attachment folder CvFolderVO.
   */
  public CvFolderVO getAttachmentFolder(int individualID)
  {
    CvFolderVO attachmentFolderVO = new CvFolderVO();
   

    try {
      InitialContext ic = new InitialContext();
      CvFileLocalHome home = (CvFileLocalHome)ic.lookup("local/CvFile");
      CvFileLocal remote =  home.create();
      remote.setDataSource(this.dataSource);

      CvFolderVO homeFolderVO = remote.getHomeFolder(individualID);

      try {
        attachmentFolderVO = remote.getFolderByName(individualID, homeFolderVO.getFolderId(), CvFolderVO.EMAIL_ATTACHMENT_FOLDER);
      }catch(CvFileException cfe){
        //If the Attachment folder is not created, create it.
        int newFolderID = this.createAttachmentFolder(individualID);
        attachmentFolderVO = remote.getFolder(individualID, newFolderID);
      }
View Full Code Here

  public int createAttachmentFolder(int individualID)
  {
    int newFolderID = -1;
    try {
      CvFileFacade fileFacade = new CvFileFacade();
      CvFolderVO homeFolderVO = fileFacade.getHomeFolder(individualID, this.dataSource);

      CvFolderVO attachmentFolderVO = new CvFolderVO();
      attachmentFolderVO.setCreatedBy(individualID);
      attachmentFolderVO.setDescription("Email Attachments are kept here.");
      attachmentFolderVO.setOwner(individualID);
      attachmentFolderVO.setName(CvFolderVO.EMAIL_ATTACHMENT_FOLDER);
      attachmentFolderVO.setParent(homeFolderVO.getFolderId());

      try {
        newFolderID = fileFacade.addFolder(individualID, attachmentFolderVO, this.dataSource);
      }catch(CvFileException cfe){
        cfe.printStackTrace();
View Full Code Here

    try {
      // I'm assuming that the sent folder is called Sent.
      // big assumption, I know.
      MailFolderVO sentFolder = this.getEmailFolderByName(mailAccountVO.getAccountID(), MailFolderVO.SENT_FOLDER_NAME);

      CvFolderVO attachmentFolder = this.getAttachmentFolder(mailAccountVO.getOwnerID());

      Address arrayBcc[] = new Address[0];
      Address arrayCc[] = new Address[0];
      Address arrayTo[] = new Address[0];

      //Build the JavaMail message
      Properties props = System.getProperties();
      if (mailAccountVO.getSmtpServer() != null) {
        props.put("mail.smtp.host", mailAccountVO.getSmtpServer());
      } else {
        logger.error("[sendMessage]: The accountVO doesn't have a smtpserver setup: "+mailAccountVO);
        throw new SendFailedException("<error>The SMTP Server has not been setup.</error>");
      }

      Session session = Session.getDefaultInstance(props, null);
      MimeMessage message = new MimeMessage(session);

      Collection bccList = mailMessageVO.getBccList();
      Collection ccList = mailMessageVO.getCcList();
      Collection toList = mailMessageVO.getToList();
      Collection attachments = mailMessageVO.getAttachedFiles();
      String subject = mailMessageVO.getSubject();
      String body = mailMessageVO.getBody();
      String fromAddress = mailMessageVO.getFromAddress();
      String replyToAddress = mailMessageVO.getReplyTo();
      String headers = mailMessageVO.getHeaders();
      String messageType = mailMessageVO.getContentType();

      arrayBcc = this.getAddressAddress(bccList);
      arrayCc = this.getAddressAddress(ccList);
      arrayTo = this.getAddressAddress(toList);

      message.addRecipients(Message.RecipientType.TO, arrayTo);
      message.addRecipients(Message.RecipientType.CC, arrayCc);
      message.addRecipients(Message.RecipientType.BCC, arrayBcc);

      message.setFrom(new InternetAddress(fromAddress));
      // So we don't require a Reply-To address
      if (replyToAddress != null && replyToAddress.length() != 0) {
        message.setReplyTo(new Address[] {new InternetAddress(replyToAddress)});
      }
      //Add raw headers to message object
      StringTokenizer tokenizer = new StringTokenizer(headers, System.getProperty("line.separator", "\n"));
      while (tokenizer.hasMoreTokens()) {
        message.addHeaderLine(tokenizer.nextToken());
      }

      //Most email clients add this line with the name of
      //their software and the version
      message.addHeader("X-Mailer", "Centraview v. " + CentraViewConfiguration.getVersion());

      message.setSubject(subject);
      BodyPart messageBodyPart = new MimeBodyPart();
      messageBodyPart.setContent(body, messageType);

      Multipart multipart = new MimeMultipart();
      multipart.addBodyPart(messageBodyPart);

      // Handle attachments
      if (attachments != null) {
        message.setContent(multipart);
        Iterator attachmentIterator = attachments.iterator();
        while (attachmentIterator.hasNext()) {
          messageBodyPart = new MimeBodyPart();
          CvFileVO thisAttachment = (CvFileVO) attachmentIterator.next();
          String path = thisAttachment.getPhysicalFolderVO().getFullPath(null, true) + thisAttachment.getName();
          DataSource source = new FileDataSource(path);
          messageBodyPart.setDataHandler(new DataHandler(source));
          messageBodyPart.setFileName(thisAttachment.getTitle());
          multipart.addBodyPart(messageBodyPart);
        }
      }

      message.setSentDate(new Date());
      //End of Build The JavaMail message

      messageSent = this.sendSimpleMessage(message, mailAccountVO.getSmtpServer(),
        mailAccountVO.getLogin(), mailAccountVO.getPassword(), mailAccountVO.getSmtpPort(),
        mailAccountVO.isPopRequiredBeforeSMTP(), mailAccountVO.isAuthenticationRequiredForSMTP(),
        mailAccountVO.getAccountType(), mailAccountVO.getMailServer());

      //Save Message to Sent Folder
      if (messageSent) {
        logger.error("[sendMessage]["+dataSource+"]: Mail Message Successfully sent.");
        int messageID = this.addMessage(message, "", mailAccountVO.getAccountID(), mailAccountVO.getOwnerID(), sentFolder.getFolderID(), cvdal);
        HashMap embededImageMap = new HashMap();
        this.saveAttachments(this.getPartContent(message), messageID, mailAccountVO.getAccountID(), mailAccountVO.getOwnerID(), attachmentFolder.getFolderId(), cvdal,embededImageMap);
        this.addBody(message, messageID, embededImageMap, cvdal);
        embededImageMap = null;
      }
    } finally {
      cvdal.destroy();
View Full Code Here

TOP

Related Classes of com.centraview.file.CvFolderVO

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.