Package com.cubusmail.server.mail

Examples of com.cubusmail.server.mail.IMailFolder


   * org.grouplite.mail.ui.mail.IMailConnection#renameFolder(org.grouplite
   * .mail.ui.mail.IMailFolder, java.lang.String)
   */
  public IMailFolder renameFolder( String folderId, String folderName ) throws MailFolderException {

    IMailFolder folder = getMailFolderById( folderId );
    try {
      String newName = folder.getId();
      if ( newName.lastIndexOf( getFolderSeparator() ) >= 0 ) {
        newName = newName.substring( 0, newName.lastIndexOf( getFolderSeparator() ) + 1 ) + folderName;
      }
      else {
        newName = folderName;
      }

      if ( folder.isOpen() ) {
        folder.close( false );
      }
      Folder newFolder = this.store.getFolder( newName );
      if ( !newFolder.exists() ) {
        if ( !folder.renameTo( newFolder ) ) {
          throw new MailFolderException( IErrorCodes.EXCEPTION_FOLDER_RENAME, null, folder );
        }
      }
      else {
        throw new MailFolderException( IErrorCodes.EXCEPTION_FOLDER_ALREADY_EXIST, null,
View Full Code Here


   *
   * @see com.cubusmail.mail.IMailbox#emptyFolder(java.lang.String)
   */
  public void emptyFolder( String folderId ) throws MailFolderException {

    IMailFolder folder = getMailFolderById( folderId );

    try {
      if ( !folder.isOpen() ) {
        folder.open( Folder.READ_WRITE );
      }

      if ( folder.getMessageCount() > 0 ) {
        Message[] msgs = folder.retrieveMessages( null, true, null, null );
        for (int i = 0; i < folder.getMessageCount(); i++) {
          msgs[i].setFlag( Flags.Flag.DELETED, true );
        }
      }
      folder.close( true );
    }
    catch (MessagingException ex) {
      throw new MailFolderException( IErrorCodes.EXCEPTION_FOLDER_EMPTY, ex, folder );
    }
  }
View Full Code Here

   *
   * @see com.cubusmail.mail.IMailbox#deleteFolder(java.lang.String)
   */
  public void deleteFolder( String folderId ) throws MailFolderException {

    IMailFolder folder = getMailFolderById( folderId );

    try {
      if ( folder.hasRight( Right.DELETE ) ) {
        if ( folder.isOpen() ) {
          folder.close( false );
        }

        if ( folder.delete( true ) ) {
          loadMailFolder();
          setCurrentFolder( getInboxFolder() );
        }
        else {
          throw new MailFolderException( IErrorCodes.EXCEPTION_FOLDER_DELETE, null, folder );
View Full Code Here

  public void copyMessages( long[] messageIds, String targetFolderId ) throws MessagingException {

    if ( !this.currentFolder.isOpen() ) {
      this.currentFolder.open( Folder.READ_WRITE );
    }
    IMailFolder targetFolder = getMailFolderById( targetFolderId );
    if ( !targetFolder.isOpen() ) {
      targetFolder.open( Folder.READ_WRITE );
    }

    this.currentFolder.copyMessages( messageIds, targetFolder );

    targetFolder.close( false );
  }
View Full Code Here

      }
    }

    // build the tree structure
    for (String folderName : topFolderNames) {
      IMailFolder mailFolder = this.mailFolderMap.get( folderName );
      this.mailFolderList.add( mailFolder );
      if ( mailFolder.hasChildren() ) {
        mailFolder.setSubfolders( getSubfolders( mailFolder ) );
      }
    }

    log.debug( "...finish: " + (System.currentTimeMillis() - millis) + "ms" );
  }
View Full Code Here

    Set<String> keys = this.mailFolderMap.keySet();
    for (String key : keys) {
      if ( key.startsWith( searchKey )
          && !StringUtils.contains( StringUtils.substringAfter( key, searchKey ), getFolderSeparator() ) ) {

        IMailFolder subfolder = this.mailFolderMap.get( key );
        subfolders.add( subfolder );
        if ( subfolder.hasChildren() ) {
          subfolder.setSubfolders( getSubfolders( subfolder ) );
        }
      }
    }

    return subfolders;
View Full Code Here

   */
  @Override
  public boolean equals( Object obj ) {

    boolean result = false;
    IMailFolder folder = (IMailFolder) obj;
    if ( folder.getId() != null ) {
      if ( folder.getId().equals( getId() ) ) {
        return true;
      }
    }

    return result;
View Full Code Here

    if ( completeTree ) {
      IMailFolder[] subfolders = mailFolder.getSubfolders();
      if ( subfolders.length > 0 ) {
        GWTMailFolder[] gwtSubfolders = new GWTMailFolder[subfolders.length];
        for (int i = 0; i < subfolders.length; i++) {
          IMailFolder subfolder = mailFolder.getSubfolders()[i];
          gwtSubfolders[i] = convert( subfolder, completeTree );
          gwtSubfolders[i].setParent( result );
        }
        result.setSubfolders( gwtSubfolders );
      }
View Full Code Here

   * org.grouplite.mail.ui.mail.IMailConnection#moveFolder(org.grouplite.mail
   * .ui.mail.IMailFolder, org.grouplite.mail.ui.mail.IMailFolder)
   */
  public IMailFolder moveFolder( String sourceFolderId, String targetFolderId ) throws MailFolderException {

    IMailFolder sourceFolder = null;
    IMailFolder targetFolder = null;

    try {
      String newFolderName;

      sourceFolder = getMailFolderById( sourceFolderId );
      targetFolder = getMailFolderById( targetFolderId );

      if ( sourceFolder != null ) {
        if ( targetFolder == null ) {
          newFolderName = sourceFolder.getName();
        }
        else {
          newFolderName = targetFolder.getId() + getFolderSeparator() + sourceFolder.getName();
        }

        if ( sourceFolder.isOpen() ) {
          sourceFolder.close( false );
        }
        if ( targetFolder != null && targetFolder.isOpen() ) {
          targetFolder.close( false );
        }

        Folder newFolder = this.store.getFolder( newFolderName );
        if ( !newFolder.exists() ) {
          sourceFolder.renameTo( newFolder );
View Full Code Here

  public GWTMailFolder createFolder( String parentFolderId, String folderName ) throws Exception {

    IMailbox mailbox = SessionManager.get().getMailbox();
    log.debug( "creating folder... " + folderName );

    IMailFolder newFolder;
    try {
      newFolder = mailbox.createFolder( parentFolderId, folderName );
      log.debug( "...successful" );

      return ConvertUtil.convert( newFolder, true );
View Full Code Here

TOP

Related Classes of com.cubusmail.server.mail.IMailFolder

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.