Examples of MessagingException


Examples of javax.mail.MessagingException

    { // HP Java runtime did not recognise MessagingException as a subtype
      // of
      // Throwable.
      try
      {
        MessagingException me = (MessagingException) e;
        Exception nextException = me.getNextException();
        if (nextException != null)
        {
          Trace.error(nextException.getMessage());
          if (nextException instanceof SendFailedException)
          {
View Full Code Here

Examples of javax.mail.MessagingException

    else if (sRecipientType.equalsIgnoreCase("bcc"))
      oRecType = RecipientType.BCC;
    else if (sRecipientType.equalsIgnoreCase("to"))
    oRecType = RecipientType.TO;
    else
      throw new MessagingException(sRecipientType+" is not a valid recipient type");

    if (sJobTl.length()>0) {
    if (null==oGlobalDbb)
      oDbb = new DBBind(sEnvCnfFileName);
    else
View Full Code Here

Examples of javax.mail.MessagingException

          if (!oRSet.wasNull()) iLen = Integer.parseInt(oLenPart.toString()); else iLen = -1;
          oOffset = oRSet.getObject(6);
          if (!oRSet.wasNull()) lOff = Long.parseLong(oOffset.toString()); else lOff = -1;

          if (lPos!=-1) {
            if (iLen==-1) throw new MessagingException("Part " + String.valueOf(iPartId) + " length not set at k_mime_parts table for message "+getMessage().getMessageGuid());
            if (lOff==-1 ) throw new MessagingException("Part " + String.valueOf(iPartId) + " offset not set at k_mime_parts table for message "+getMessage().getMessageGuid());

            if (DebugFile.trace) DebugFile.writeln("new MboxFile("+((DBFolder)getMessage().getFolder()).getFile()+")");

            MboxFile oMbox = new MboxFile(((DBFolder)getMessage().getFolder()).getFile(), MboxFile.READ_ONLY);

            InputStream oInStrm = oMbox.getPartAsStream(lPos, lOff, iLen);
            oMimeBody = new MimeBodyPart(oInStrm);
            oInStrm.close();

            oMbox.close();
          }
          else {
            if (DebugFile.trace) DebugFile.decIdent();
            throw new MessagingException("Part " + String.valueOf(iPartId) + " not found for message " + getMessage().getContentID());
          }
        } // fi (MODE_MBOX)
      } else {
        if (DebugFile.trace) {
          if (null==oFldr)
            DebugFile.writeln("Part "+String.valueOf(iPartId) + " not found in message ["+getMessage().getMessageGuid()+"] " + getMessage().getContentID());
          else
            DebugFile.writeln("Part "+String.valueOf(iPartId) + " not found in message ["+getMessage().getMessageGuid()+"] " + getMessage().getContentID() + " at folder " + oFldr.getCategoryGuid());
        }
      } // fi (oRset.next();

      oRSet.close();
      oRSet = null;
      oStmt.close();
      oStmt = null;
    } catch (SQLException sqle) {
      try { if (null!=oRSet) oRSet.close(); } catch (Exception ignore) {}
      try { if (null!=oStmt) oStmt.close(); } catch (Exception ignore) {}
      throw new MessagingException(sqle.getMessage(), sqle);
    } catch (com.enterprisedt.net.ftp.FTPException xcpt) {
      try { if (null!=oRSet) oRSet.close(); } catch (Exception ignore) {}
      try { if (null!=oStmt) oStmt.close(); } catch (Exception ignore) {}
      throw new MessagingException(xcpt.getMessage(), xcpt);
    }

    if (oMimeBody!=null) {
      if (DebugFile.trace) DebugFile.writeln("MimeBodyPart.getContent()");
      oRetVal = oMimeBody.getContent();
View Full Code Here

Examples of javax.mail.MessagingException

          if (!oRSet.wasNull()) iLenPart = oRSet.getInt(5);
          oOffset = oRSet.getObject(6);
          if (!oRSet.wasNull()) iOffset = oRSet.getInt(6);

          if (iPosition!=-1) {
            if (iLenPart==-1) throw new MessagingException("Part " + String.valueOf(iPartId) + " length not set at k_mime_parts table");
            if (iOffset==-1 ) throw new MessagingException("Part " + String.valueOf(iPartId) + " offset not set at k_mime_parts table");

            if (DebugFile.trace) DebugFile.writeln("new MboxFile("+((DBFolder)getMessage().getFolder()).getFile()+")");

            MboxFile oMbox = new MboxFile(((DBFolder)getMessage().getFolder()).getFile(), MboxFile.READ_ONLY);

            oMimeBody = new MimeBodyPart(oMbox.getPartAsStream(iPosition, iOffset, iLenPart));

            oMbox.close();
          }
          else {
            if (DebugFile.trace) DebugFile.decIdent();
            throw new MessagingException("Part " + String.valueOf(iPartId) + " not found for message " + getMessage().getContentID());
          }
        } // fi (MODE_MBOX)
      } // fi (oRset.next();

      oRSet.close();
      oRSet = null;
      oStmt.close();
      oStmt = null;
    } catch (SQLException sqle) {
      try { if (null!=oRSet) oRSet.close(); } catch (Exception ignore) {}
      try { if (null!=oStmt) oStmt.close(); } catch (Exception ignore) {}
      throw new MessagingException(sqle.getMessage(), sqle);
    }

    if (oMimeBody!=null) oRetVal = oMimeBody.getInputStream();

    if (DebugFile.trace) {
View Full Code Here

Examples of javax.mail.MessagingException

      }
      catch (SQLException sqle) {
        sFileName = null;
        if (oStmt!=null) { try { oStmt.close(); } catch (Exception ignore) {} }
        if (DebugFile.trace) DebugFile.decIdent();
        throw new MessagingException(sqle.getMessage(), sqle);
      }
    }
    else {
      sFileName = null;
    }
View Full Code Here

Examples of javax.mail.MessagingException

      oStmt = getConnection().prepareStatement(sSQL+"?",ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY);
      oStmt.setString(1, oSrcMsg.getMessageGuid());
      oRSet = oStmt.executeQuery();
      if (!oRSet.next())
        throw new MessagingException("DBFolder.copyMessage() could not find source message " + oSrcMsg.getMessageGuid());
      oPg = oRSet.getBigDecimal(1);
      sId = oRSet.getString(2);
      oPos= oRSet.getBigDecimal(3);
      iLen= oRSet.getInt(4);
      oRSet.close();
      oRSet=null;
      oStmt.close();
      oStmt=null;
    }
    catch (SQLException sqle) {
      try { if (oRSet!=null) oRSet.close(); } catch (Exception ignore) {}
      try { if (oStmt!=null) oStmt.close(); } catch (Exception ignore) {}
      try { getConnection().rollback(); } catch (Exception ignore) {}
      if (DebugFile.trace) {
        DebugFile.writeln("DBFolder.copyMessage() SQLException " + sqle.getMessage());
        DebugFile.decIdent();
      }
      throw new MessagingException("DBFolder.copyMessage() SQLException " + sqle.getMessage(), sqle);
    }

    if (null==oPg) throw new MessagingException("DBFolder.copyMessage() Source Message not found");

    DBFolder oSrcFldr = (DBFolder) oSrcMsg.getFolder();

    MboxFile oMboxSrc = null;
    MimeMessage oMimeSrc;
    String sNewGuid = null;
    try {
      if ((oSrcFldr.mode&MODE_MBOX)!=0) {
        if (DebugFile.trace) DebugFile.writeln("new MboxFile(" + oSrcFldr.getFile() + ", MboxFile.READ_ONLY)");
        oMboxSrc = new MboxFile(oSrcFldr.getFile(), MboxFile.READ_ONLY);
        InputStream oInStrm = oMboxSrc.getMessageAsStream(oPos.longValue(), iLen);
        oMimeSrc = new MimeMessage(Session.getDefaultInstance(new Properties()), oInStrm);
        oInStrm.close();
        oMboxSrc.close();
        oMboxSrc=null;

        String sId2 = oMimeSrc.getMessageID();
        if ((sId!=null) && (sId2!=null)) {
          if (!sId.trim().equals(sId2.trim())) {
            throw new MessagingException("MessageID "+ sId + " at database does not match MessageID " + oMimeSrc.getMessageID() + " at MBOX file " + oSrcFldr.getFile().getName() + " for message index " + oPg.toString());
          }
        } // fi (sId!=null && sId2!=null)

        appendMessage(oMimeSrc);
      }
      else {
        ByteArrayOutputStream oByOutStrm = new ByteArrayOutputStream();
        oSrcMsg.writeTo(oByOutStrm);
        ByteArrayInputStream oByInStrm = new ByteArrayInputStream(oByOutStrm.toByteArray());
        oByOutStrm.close();
        oMimeSrc = new MimeMessage(Session.getDefaultInstance(new Properties()), oByInStrm);
        oByInStrm.close();
        appendMessage(oMimeSrc);
      }
    }
    catch (Exception e) {
      if (oMboxSrc!=null)  { try { oMboxSrc.close()} catch (Exception ignore) {} }
      try { oSrcFldr.getConnection().rollback(); } catch (Exception ignore) {}
      if (DebugFile.trace) {
        DebugFile.writeln("DBFolder.copyMessage() " + e.getClass().getName() + " "+ e.getMessage());
        DebugFile.writeStackTrace(e);
        DebugFile.writeln("");
        DebugFile.decIdent();
      }
      throw new MessagingException(e.getMessage(), e);
    }

    if (DebugFile.trace) {
      DebugFile.decIdent();
      DebugFile.writeln("End DBFolder.copyMessage() : " + sNewGuid);
View Full Code Here

Examples of javax.mail.MessagingException

            sSrcCatg = oSrcCatg.getStringNull(DB.gu_category,null);
          }
        }
        if (null==sSrcCatg) {
          DebugFile.decIdent();
          throw new MessagingException("Could not find folder for source message");
        }
        if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement(UPDATE "+DB.k_categories+" SET "+DB.len_size+"="+DB.len_size+"-"+String.valueOf(iLen)+" WHERE "+DB.gu_category+"='"+sSrcCatg+"')");
      }
      sSrcCatg = ((DBFolder)(oSrcMsg.getFolder())).getCategory().getString(DB.gu_category);
      oStmt = oConn.prepareStatement("UPDATE "+DB.k_categories+" SET "+DB.len_size+"="+DB.len_size+"-"+String.valueOf(iLen)+" WHERE "+DB.gu_category+"=?");
      oStmt.setString(1, sSrcCatg);
      oStmt.executeUpdate();
      oStmt.close();
      oStmt=null;
      if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement(UPDATE "+DB.k_categories+" SET "+DB.len_size+"="+DB.len_size+"+"+String.valueOf(iLen)+" WHERE "+DB.gu_category+"='"+getCategory().getStringNull(DB.gu_category,"null")+"')");
      oStmt = oConn.prepareStatement("UPDATE "+DB.k_categories+" SET "+DB.len_size+"="+DB.len_size+"+"+String.valueOf(iLen)+" WHERE "+DB.gu_category+"=?");
      oStmt.setString(1, getCategory().getString(DB.gu_category));
      oStmt.executeUpdate();
      oStmt.close();
      oStmt=null;

      if (DebugFile.trace) DebugFile.writeln("JDCConnection.commit()");

      oConn.commit();
    }
    catch (SQLException sqle) {
      if (DebugFile.trace) {
        DebugFile.writeln("SQLException "+sqle.getMessage());
        DebugFile.writeStackTrace(sqle);
      }
      if (null!=oRSet) { try {oRSet.close(); } catch (Exception ignore) {} }
      if (null!=oStmt) { try {oStmt.close(); } catch (Exception ignore) {} }
      if (null!=oConn) { try {oConn.rollback(); } catch (Exception ignore) {} }
      if (!bWasOpen) { try { close(false); } catch (Exception ignore) {} }
      throw new MessagingException(sqle.getMessage(), sqle);
    }

    if (null==oPg) {
      if (!bWasOpen) { try { close(false); } catch (Exception ignore) {} }
      throw new MessagingException("Source message "+oSrcMsg.getMessageGuid()+" not found");
    }

    // If position is null then message is only at the database and not also at
    // an MBOX file so skip moving from one MBOX file to another
    if (null!=oPos) {

      DBFolder oSrcFldr = (DBFolder) oSrcMsg.getFolder();

      MboxFile oMboxSrc = null, oMboxThis = null;
     
      try {
        if (DebugFile.trace) DebugFile.writeln("new MboxFile("+oSrcFldr.getFile().getPath()+", MboxFile.READ_WRITE)");
         
        oMboxSrc = new MboxFile(oSrcFldr.getFile(), MboxFile.READ_WRITE);

        if (DebugFile.trace) DebugFile.writeln("new MboxFile("+getFile().getPath()+", MboxFile.READ_WRITE)");

        oMboxThis = new MboxFile(getFile(), MboxFile.READ_WRITE);

        if (DebugFile.trace) DebugFile.writeln("MboxFile.appendMessage([MboxFile], "+oPos.toString()+","+String.valueOf(iLen)+")");

        oMboxThis.appendMessage(oMboxSrc, oPos.longValue(), iLen);

        oMboxThis.close();
        oMboxThis=null;

        oMboxSrc.purge (new int[]{oPg.intValue()});

        oMboxSrc.close();
        oMboxSrc=null;
      }
      catch (Exception e) {
        if (DebugFile.trace) {
          DebugFile.writeln(e.getClass()+" "+e.getMessage());
          DebugFile.writeStackTrace(e);
        }
        if (oMboxThis!=null) { try { oMboxThis.close(); } catch (Exception ignore) {} }
        if (oMboxSrc!=null)  { try { oMboxSrc.close()} catch (Exception ignore) {} }
        if (!bWasOpen) { try { close(false); } catch (Exception ignore) {} }
        throw new MessagingException(e.getMessage(), e);
      }
    } // fi (oPos)

    try {
      oConn = getConnection();
      oConn.setAutoCommit(false);

      BigDecimal dNext = getNextMessage();

      if (DebugFile.trace)
        DebugFile.writeln("JDCConnection.prepareStatement(UPDATE "+DB.k_mime_msgs+" SET "+DB.gu_category+"='"+sCatGuid+"',"+DB.pg_message+"="+dNext.toString()+" WHERE "+DB.gu_mimemsg+"='"+oSrcMsg.getMessageGuid()+"')");

      oStmt = oConn.prepareStatement("UPDATE "+DB.k_mime_msgs+" SET "+DB.gu_category+"=?,"+DB.pg_message+"=? WHERE "+DB.gu_mimemsg+"=?");
      oStmt.setString(1, sCatGuid);
      oStmt.setBigDecimal(2, dNext);
      oStmt.setString(3, oSrcMsg.getMessageGuid());
      int iAffected = oStmt.executeUpdate();     
      if (DebugFile.trace) DebugFile.writeln(String.valueOf(iAffected)+" updated rows");     
      oStmt.close();
      oStmt=null;

      if (DebugFile.trace) DebugFile.writeln("JDCConnection.commit()");

      oConn.commit();
    }
    catch (SQLException sqle) {

      if (DebugFile.trace) {
        DebugFile.writeln("MessagingException "+sqle.getMessage());
        DebugFile.writeStackTrace(sqle);
      }

      if (null!=oStmt) { try { oStmt.close(); } catch (Exception ignore) {}}
      if (null!=oConn) { try { oConn.rollback(); } catch (Exception ignore) {} }
      if (!bWasOpen) { try { close(false); } catch (Exception ignore) {} }

      throw new MessagingException(sqle.getMessage(), sqle);
    }

    if (!bWasOpen) close(false);

    if (DebugFile.trace) {
View Full Code Here

Examples of javax.mail.MessagingException

    try {
      String sGuid = ((DBStore) getStore()).getUser().getMailFolder(getConnection(),
                     Category.makeName(getConnection(), sFolderName));
      oCatg = new Category(getConnection(), sGuid);
    } catch (SQLException sqle) {
      throw new MessagingException(sqle.getMessage(), sqle);
    }
    return true;
  }
View Full Code Here

Examples of javax.mail.MessagingException

      DebugFile.incIdent();
    }

    if ((0==(mode&READ_ONLY)) && (0==(mode&READ_WRITE))) {
      if (DebugFile.trace) DebugFile.decIdent();
      throw new MessagingException("Folder must be opened in either READ_ONLY or READ_WRITE mode");
    }
    else if (ALL_OPTIONS!=(mode|ALL_OPTIONS)) {
      if (DebugFile.trace) DebugFile.decIdent();
      throw new MessagingException("Invalid DBFolder open() option mode");
    } else {
      if ((0==(mode&MODE_MBOX)) && (0==(mode&MODE_BLOB)))
        mode |= MODE_MBOX;

      iOpenMode = mode;
      JDCConnection oConn = null;
      try {
        oConn = getConnection();
      } catch (SQLException sqle) {
        throw new MessagingException(sqle.getMessage(), sqle);
      }
      if ((iOpenMode&MODE_MBOX)!=0) {
        String sFolderUrl;
        try {
          sFolderUrl = Gadgets.chomp(getStore().getURLName().getFile(), File.separator) + oCatg.getPath(oConn);
          if (DebugFile.trace) DebugFile.writeln("mail folder directory is " + sFolderUrl);
          if (sFolderUrl.startsWith("file://"))
            sFolderDir = sFolderUrl.substring(7);
          else
            sFolderDir = sFolderUrl;
          if (File.separator.equals("\\")) sFolderDir = sFolderDir.replace('/','\\');
        } catch (SQLException sqle) {
          iOpenMode = 0;
          oConn = null;
          if (DebugFile.trace) DebugFile.decIdent();
          throw new MessagingException (sqle.getMessage(), sqle);
        }
        try {
          File oDir = new File (sFolderDir);
          if (!oDir.exists()) {
            FileSystem oFS = new FileSystem();
            oFS.mkdirs(sFolderUrl);
          }
        } catch (IOException ioe) {
          iOpenMode = 0;
          oConn = null;
          if (DebugFile.trace) DebugFile.decIdent();
          throw new MessagingException (ioe.getMessage(), ioe);
        } catch (SecurityException se) {
          iOpenMode = 0;
          oConn = null;
          if (DebugFile.trace) DebugFile.decIdent();
          throw new MessagingException (se.getMessage(), se);
        } catch (Exception je) {
          iOpenMode = 0;
          oConn = null;
          if (DebugFile.trace) DebugFile.decIdent();
          throw new MessagingException (je.getMessage(), je);
        }

        // Create a ProductLocation pointing to the MBOX file if it does not exist
        try {
          oConn = getConnection();
        } catch (SQLException sqle) {
          throw new MessagingException(sqle.getMessage(), sqle);
        }
        PreparedStatement oStmt = null;
        ResultSet oRSet = null;
        boolean bHasFilePointer;
        try {
          oStmt = oConn.prepareStatement("SELECT NULL FROM "+DB.k_x_cat_objs+ " WHERE "+DB.gu_category+"=? AND "+DB.id_class+"=15",
                                         ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
          oStmt.setString(1, getCategory().getString(DB.gu_category));
          oRSet = oStmt.executeQuery();
          bHasFilePointer = oRSet.next();
          oRSet.close();
          oRSet = null;
          oStmt.close();
          oStmt = null;

          if (!bHasFilePointer) {
            oConn.setAutoCommit(false);

            Product oProd = new Product();
            oProd.put(DB.gu_owner, oCatg.getString(DB.gu_owner));
            oProd.put(DB.nm_product, oCatg.getString(DB.nm_category));
            oProd.store(oConn);

            ProductLocation oLoca = new ProductLocation();
            oLoca.put(DB.gu_product, oProd.getString(DB.gu_product));
            oLoca.put(DB.gu_owner, oCatg.getString(DB.gu_owner));
            oLoca.put(DB.pg_prod_locat, 1);
            oLoca.put(DB.id_cont_type, 1);
            oLoca.put(DB.id_prod_type, "MBOX");
            oLoca.put(DB.len_file, 0);
            oLoca.put(DB.xprotocol, "file://");
            oLoca.put(DB.xhost, "localhost");
            oLoca.put(DB.xpath, Gadgets.chomp(sFolderDir, File.separator));
            oLoca.put(DB.xfile, oCatg.getString(DB.nm_category)+".mbox");
            oLoca.put(DB.xoriginalfile, oCatg.getString(DB.nm_category)+".mbox");
            oLoca.store(oConn);

            oStmt = oConn.prepareStatement("INSERT INTO "+DB.k_x_cat_objs+" ("+DB.gu_category+","+DB.gu_object+","+DB.id_class+") VALUES (?,?,15)");
            oStmt.setString(1, oCatg.getString(DB.gu_category));
            oStmt.setString(2, oProd.getString(DB.gu_product));
            oStmt.executeUpdate();
            oStmt.close();
            oStmt = null;

            oConn.commit();
          }
        }
        catch (SQLException sqle) {
          if (DebugFile.trace) {
            DebugFile.writeln("SQLException " + sqle.getMessage());
            DebugFile.decIdent();
          }
          if (oStmt!=null) { try { oStmt.close(); } catch (SQLException ignore) {} }
          if (oConn!=null) { try { oConn.rollback(); } catch (SQLException ignore) {} }
          throw new MessagingException(sqle.getMessage(), sqle);
        }
      }
      else {
        sFolderDir = null;
      }
View Full Code Here

Examples of javax.mail.MessagingException

  public boolean delete(boolean recurse) throws MessagingException {
    try {
      wipe();
      return oCatg.delete(getConnection());
    } catch (SQLException sqle) {
      throw new MessagingException(sqle.getMessage(), sqle);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.