Examples of JDCConnection


Examples of com.knowgate.jdc.JDCConnection

    ResultSet oRSet = oStmt.executeQuery();
    while (oRSet.next() && (null==sRetVal)) {
      Product oProd = new Product();
      oProd.put(DB.gu_product, oRSet.getString(1));
      oProd.put(DB.gu_owner, oRSet.getString(2));
      Shop oShop = oProd.getShop(new JDCConnection(oConn,null));
      if (null!=oShop) {
        if (oShop.getString(DB.gu_workarea).equals(sWorkAreaId))
          sRetVal = oProd.getString(DB.gu_product);
      }
    } // wend
View Full Code Here

Examples of com.knowgate.jdc.JDCConnection

    // *************************************************
    // Get the list of all messages stored at this folder

    MboxFile oMBox = null;
    DBSubset oDeleted = new DBSubset(DB.k_mime_msgs, DB.gu_mimemsg+","+DB.pg_message, DB.gu_category+"='"+oCatg.getString(DB.gu_category)+"'", 100);
    JDCConnection oConn = null;

    try {
    oConn = getConnection();
      int iDeleted = oDeleted.load(oConn);
      if (DebugFile.trace) DebugFile.writeln("there are "+String.valueOf(iDeleted)+" messages to be deleted");

      // ****************************************
      // Erase files referenced by draft messages   
      oStmt = oConn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
      if (DebugFile.trace) DebugFile.writeln("Statement.executeQuery(SELECT p." + DB.file_name + " FROM " + DB.k_mime_parts + " p," + DB.k_mime_msgs + " m WHERE p." + DB.gu_mimemsg + "=m."+ DB.gu_mimemsg + " AND m." + DB.id_disposition + "='reference' AND m." + DB.bo_deleted + "=1 AND m." + DB.gu_category +"='"+oCatg.getString(DB.gu_category)+"')");
      oRSet = oStmt.executeQuery("SELECT p." + DB.file_name + " FROM " + DB.k_mime_parts + " p," + DB.k_mime_msgs + " m WHERE p." + DB.gu_mimemsg + "=m."+ DB.gu_mimemsg + " AND m." + DB.id_disposition + "='reference' AND m." + DB.bo_deleted + "=1 AND m." + DB.gu_category +"='"+oCatg.getString(DB.gu_category)+"'");

      while (oRSet.next()) {
        String sFileName = oRSet.getString(1);
        if (!oRSet.wasNull()) {
          try {
            File oRef = new File(sFileName);
            if (oRef.exists()) oRef.delete();
          }
          catch (SecurityException se) {
            if (DebugFile.trace) DebugFile.writeln("SecurityException " + sFileName + " " + se.getMessage());
          }
        }
      } // wend

      oRSet.close();
      oRSet = null;
      oStmt.close();
      oStmt = null;

      // *************************
      // Set Category size to zero

      oStmt = oConn.createStatement();
      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate(UPDATE "+DB.k_categories+" SET "+DB.len_size+"=0 WHERE "+DB.gu_category+"='"+getCategory().getString(DB.gu_category)+"')");
      oStmt.executeUpdate("UPDATE "+DB.k_categories+" SET "+DB.len_size+"=0 WHERE "+DB.gu_category+"='"+getCategory().getString(DB.gu_category)+"'");
      oStmt.close();
      oStmt=null;

      // *********************************************
      // Actually delete messages from database tables

      if (oConn.getDataBaseProduct()==JDCConnection.DBMS_POSTGRESQL) {
        oStmt = oConn.createStatement();
        for (int d=0; d<iDeleted; d++)
          oStmt.executeQuery("SELECT k_sp_del_mime_msg('" + oDeleted.getString(0,d) + "')");
        oStmt.close();
        oStmt=null;
      }
      else {
        oCall = oConn.prepareCall("{ call k_sp_del_mime_msg(?) }");

        for (int d=0; d<iDeleted; d++) {
          oCall.setString(1, oDeleted.getString(0,d));
          oCall.execute();
        } // next
        oCall.close();
        oCall=null;
      }

      // *************************************
      // Truncate MBOX file

      File oFile = getFile();
      if (oFile.exists()) {
        if (DebugFile.trace) DebugFile.writeln("File.delete("+getFilePath()+")");
        oFile.delete();
      }

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

      oConn.commit();
    } catch (Exception sqle) {
      try { if (oMBox!=null) oMBox.close(); } catch (Exception e) {}
      try { if (oStmt!=null) oStmt.close(); } catch (Exception e) {}
      try { if (oCall!=null) oCall.close(); } catch (Exception e) {}
      try { if (oConn!=null) oConn.rollback(); } catch (Exception e) {}
      throw new MessagingException (sqle.getMessage(), sqle);
    }

    if (DebugFile.trace) {
      DebugFile.decIdent();
View Full Code Here

Examples of com.knowgate.jdc.JDCConnection

                             DB.bo_draft+","+DB.bo_flagged+","+DB.bo_recent+","+
                             DB.bo_seen+","+DB.tx_email_from+","+DB.tx_email_reply+","+
                             DB.nm_from+","+DB.by_content;
    InternetAddress oFrom = null, oReply = null;
    MimeMultipart oParts = new MimeMultipart();
  JDCConnection oConn = null;
 
    try {
      oConn = getConnection();
      switch (IdType) {
        case 1:
          sSQL = "SELECT "+sColList+" FROM " + DB.k_mime_msgs + " WHERE " + DB.gu_mimemsg + "=?";
          if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement("+sSQL+")");

          oStmt = oConn.prepareStatement(sSQL, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
          oStmt.setString(1, sMsgId);
          break;
        case 2:
          sSQL = "SELECT "+sColList+" FROM " + DB.k_mime_msgs + " WHERE " + DB.id_message + "=?";
          if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement("+sSQL+")");

          oStmt = oConn.prepareStatement(sSQL, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
          oStmt.setString(1, sMsgId);
          break;
        case 3:
          sSQL = "SELECT "+sColList+" FROM " + DB.k_mime_msgs + " WHERE " + DB.pg_message + "=?";
          if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement("+sSQL+")");

          oStmt = oConn.prepareStatement(sSQL, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
          oStmt.setBigDecimal(1, new java.math.BigDecimal(sMsgId));
          break;
      }

      if (DebugFile.trace) DebugFile.writeln("ResultSet = PreparedStatement.executeQuery("+sSQL+")");
View Full Code Here

Examples of com.knowgate.jdc.JDCConnection

    if (DebugFile.trace) {
      DebugFile.writeln("Begin DBFolder.saveMimeParts([Connection], [MimeMessage], " + sBoundary + ", " + sMsgGuid + "," + sMsgId + ", " + String.valueOf(iPgMessage) + ", " + String.valueOf(iOffset) + ", [Properties])");
      DebugFile.incIdent();
    }

    JDCConnection oConn = null;
    PreparedStatement oStmt = null;
    Blob oContentTxt;
    ByteArrayOutputStream byOutPart;
    int iPrevPart = 0, iThisPart = 0, iNextPart = 0, iPartStart = 0;

    try {
      MimeMultipart oParts = (MimeMultipart) oMsg.getContent();

      final int iParts = oParts.getCount();

      if (DebugFile.trace) DebugFile.writeln("message has " + String.valueOf(iParts) + " parts");

      if (iParts>0) {
        // Skip boundary="..."; from Mime header
        // and boundaries from all previous parts
        if (sMsgCharSeq!=null && sBoundary!=null && ((iOpenMode&MODE_MBOX)!=0)) {
          // First boundary substring acurrence is the one from the message headers
          iPrevPart = sMsgCharSeq.indexOf(sBoundary, iPrevPart);
          if (iPrevPart>0) {
            iPrevPart += sBoundary.length();
            if (DebugFile.trace) DebugFile.writeln("found message boundary token at " + String.valueOf(iPrevPart));
          } // fi (message boundary)
        } // fi (sMsgCharSeq && sBoundary)

    oConn = getConnection();

        String sSQL = "INSERT INTO " + DB.k_mime_parts + "(gu_mimemsg,id_message,pg_message,nu_offset,id_part,id_content,id_type,id_disposition,len_part,de_part,tx_md5,file_name,by_content) VALUES ('"+sMsgGuid+"',?,?,?,?,?,?,?,?,?,NULL,?,?)";

        if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement(" + sSQL + ")");

        oStmt = oConn.prepareStatement(sSQL);

        for (int p = 0; p < iParts; p++) {
          if (DebugFile.trace) {
            DebugFile.writeln("processing part " + String.valueOf(p));
            DebugFile.writeln("previous part at " + String.valueOf(iPrevPart));
            DebugFile.writeln("part boundary is " + sBoundary);
            if (null==sMsgCharSeq) DebugFile.writeln("characer sequence is null");
          }

          BodyPart oPart = oParts.getBodyPart(p);
          byOutPart = new ByteArrayOutputStream(oPart.getSize() > 0 ? oPart.getSize() : 131072);
          oPart.writeTo(byOutPart);

          if (sMsgCharSeq!=null && sBoundary!=null && iPrevPart>0) {
            iThisPart = sMsgCharSeq.indexOf(sBoundary, iPrevPart);
            if (iThisPart>0) {
              if (DebugFile.trace) DebugFile.writeln("found part " + String.valueOf(p+iOffset) + " boundary at " + String.valueOf(iThisPart));
              iPartStart = iThisPart + sBoundary.length();
              while (iPartStart<sMsgCharSeq.length()) {
                if (sMsgCharSeq.charAt(iPartStart)!=' ' && sMsgCharSeq.charAt(iPartStart)!='\r' && sMsgCharSeq.charAt(iPartStart)!='\n' && sMsgCharSeq.charAt(iPartStart)!='\t')
                  break;
                else
                  iPartStart++;
              } // wend
            }
            iNextPart = sMsgCharSeq.indexOf(sBoundary, iPartStart);
            if (iNextPart<0)  {
              if (DebugFile.trace) DebugFile.writeln("no next part found");
              iNextPart = sMsgCharSeq.length();
            }
            else {
              if (DebugFile.trace) DebugFile.writeln("next part boundary found at " + String.valueOf(iNextPart));
            }
          } // fi (sMsgCharSeq!=null && sBoundary!=null && iPrevPart>0)

          String sContentType = oPart.getContentType();
          if (sContentType!=null) sContentType = MimeUtility.decodeText(sContentType);

          boolean bForwardedAttachment = false;

          if ((null!=sContentType) && (null!=((DBStore) getStore()).getSession())) {
            if (DebugFile.trace) DebugFile.writeln("Part Content-Type: " + sContentType.replace('\r',' ').replace('\n',' '));

            if (sContentType.toUpperCase().startsWith("MULTIPART/ALTERNATIVE") ||
              sContentType.toUpperCase().startsWith("MULTIPART/RELATED") ||
              sContentType.toUpperCase().startsWith("MULTIPART/SIGNED")) {
              try {
                ByteArrayInputStream byInStrm = new ByteArrayInputStream(byOutPart.toByteArray());

                MimeMessage oForwarded = new MimeMessage (((DBStore) getStore()).getSession(), byInStrm);

                saveMimeParts (oForwarded, sMsgCharSeq, getPartsBoundary(oForwarded), sMsgGuid, sMsgId, iPgMessage, iOffset+iParts);

                byInStrm.close();
                byInStrm = null;

                bForwardedAttachment = true;
              }
              catch (Exception e) {
               if (DebugFile.trace) DebugFile.writeln(e.getClass().getName() + " " + e.getMessage());
              }
            } // fi (MULTIPART/ALTERNATIVE)
          } // fi (null!=sContentType && null!=getSession())

          if (!bForwardedAttachment) {
            if (DebugFile.trace) {
              if ((iOpenMode&MODE_MBOX)!=0) {
                DebugFile.writeln("MBOX mode");
                DebugFile.writeln("nu_offset=" + String.valueOf(iPartStart));
                DebugFile.writeln("nu_len=" + String.valueOf(iNextPart-iPartStart));
              } else if ((iOpenMode&MODE_BLOB)!=0) {
                DebugFile.writeln("BLOB mode");
                DebugFile.writeln("nu_offset=null");
                DebugFile.writeln("nu_len=" + String.valueOf(oPart.getSize() > 0 ? oPart.getSize() : byOutPart.size()));
              }
              DebugFile.writeln("id_message=" + sMsgId);
              DebugFile.writeln("id_part=" + String.valueOf(p+iOffset));
              DebugFile.writeln("pg_message=" + String.valueOf(iPgMessage));
            }

            oStmt.setString(1, sMsgId); // id_message
            oStmt.setBigDecimal(2, new BigDecimal(iPgMessage)); // pg_message

            if ((iPartStart>0) && ((iOpenMode&MODE_MBOX)!=0))
              oStmt.setBigDecimal(3, new BigDecimal(iPartStart)); // nu_offset
            else
              oStmt.setNull(3, oConn.getDataBaseProduct()==JDCConnection.DBMS_ORACLE ? Types.NUMERIC : Types.DECIMAL);

            oStmt.setInt(4, p+iOffset); // id_part
            oStmt.setString(5, ((javax.mail.internet.MimeBodyPart) oPart).getContentID()); // id_content
            oStmt.setString(6, Gadgets.left(sContentType, 254)); // id_type
            oStmt.setString(7, Gadgets.left(oPart.getDisposition(), 100));

            if ((iOpenMode&MODE_MBOX)!=0)
              oStmt.setInt(8, iNextPart-iPartStart);
            else
              oStmt.setInt(8, oPart.getSize() > 0 ? oPart.getSize() : byOutPart.size());

            if (oPart.getDescription()!=null)
              oStmt.setString(9, Gadgets.left(MimeUtility.decodeText(oPart.getDescription()), 254));
            else
              oStmt.setNull(9, Types.VARCHAR);

            if (DebugFile.trace) DebugFile.writeln("file name is " + oPart.getFileName());

            if (oPart.getFileName()!=null)
              oStmt.setString(10, Gadgets.left(MimeUtility.decodeText(oPart.getFileName()), 254));
            else
              oStmt.setNull(10, Types.VARCHAR);

            if ((iOpenMode&MODE_BLOB)!=0)
              oStmt.setBinaryStream(11, new ByteArrayInputStream(byOutPart.toByteArray()),byOutPart.size());
            else
              oStmt.setNull (11, Types.LONGVARBINARY);

            if (DebugFile.trace) DebugFile.writeln("PreparedStatement.executeUpdate()");

            oStmt.executeUpdate();
          } // fi (bForwardedAttachment)

          byOutPart.close();
          byOutPart = null;
          oContentTxt = null;

          if ((iOpenMode&MODE_MBOX)!=0) iPrevPart = iNextPart;

        } // next (p)

        if (DebugFile.trace) DebugFile.writeln("PreparedStatement.close()");
        oStmt.close();
      } // fi (iParts>0)
    } catch (SQLException e) {
      if (DebugFile.trace) {
        DebugFile.writeln("SQLException " + e.getMessage());
        DebugFile.decIdent();
      }
      // Ensure that statement is closed and re-throw
      if (null!=oStmt) { try {oStmt.close();} catch (Exception ignore) {} }
      try { if (null!=oConn) oConn.rollback(); } catch (Exception ignore) {}
      throw new MessagingException (e.getMessage(), e);
    }
    catch (IOException e) {
      if (DebugFile.trace) {
        DebugFile.writeln("IOException " + e.getMessage());
View Full Code Here

Examples of com.knowgate.jdc.JDCConnection

  } // getPartsBoundary

  // ---------------------------------------------------------------------------

  private synchronized BigDecimal getNextMessage() throws MessagingException {
    JDCConnection oConn = null;
    PreparedStatement oStmt = null;
    ResultSet oRSet = null;
    BigDecimal oNext;
 
    try {
      oConn = getConnection();

      oStmt = oConn.prepareStatement("SELECT MAX("+DB.pg_message+") FROM "+DB.k_mime_msgs+" WHERE "+DB.gu_category+"=?",
                                     ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY);
      oStmt.setString(1, getCategory().getString(DB.gu_category));
      oRSet = oStmt.executeQuery();
      oRSet.next();
      oNext = oRSet.getBigDecimal(1);
View Full Code Here

Examples of com.knowgate.jdc.JDCConnection

      DBBind oDBB = (DBBind) getPortletContext().getAttribute("GlobalDBBind");

      DBSubset oCalls = new DBSubset (DB.k_phone_calls, DB.gu_phonecall + "," + DB.tp_phonecall + "," + DB.dt_start + "," + DB.dt_end + "," + DB.gu_contact + "," + DB.contact_person + "," + DB.tx_phone + "," + DB.tx_comments,
                                      DB.gu_workarea + "=? AND " + DB.gu_user + "=? AND " + DB.id_status + "=0 ORDER BY 3 DESC", 10);

      JDCConnection oCon = null;

      try  {
        oCon = oDBB.getConnection("CallsTab");

        iCalls = oCalls.load (oCon, new Object[]{sWorkAreaId,sUserId});

        for (int c=0; c<iCalls; c++) {
          if (oCalls.isNull(2,c))
            oCalls.setElementAt("",2,c);
          else {
            Date dtStart = oCalls.getDate(2,c);

            oCalls.setElementAt(Gadgets.leftPad(String.valueOf(dtStart.getHours()), '0', 2) + ":" + Gadgets.leftPad(String.valueOf(dtStart.getMinutes()), '0', 2), 2,c);
          }
        } // next (c)

        oCon.close("CallsTab");
        oCon = null;

        sXML += "<calls>\n"+oCalls.toXML("","call")+"</calls>";
      }
      catch (SQLException e) {
        sXML += "<calls/>";

        try {
          if (null != oCon)
            if (!oCon.isClosed())
              oCon.close("CallsTab");
        } catch (SQLException ignore) { }
      }
    }

    try {
View Full Code Here

Examples of com.knowgate.jdc.JDCConnection

                        "[ByteArrayOutputStream], "+sMsgCharSeq+")");
      DebugFile.incIdent();
    }

    Properties pFrom = new Properties(), pTo = new Properties(), pCC = new Properties(), pBCC = new Properties();
    JDCConnection oConn = null;
    PreparedStatement oStmt = null;
    BigDecimal dPgMessage;
    String sSQL;

    String sBoundary = getPartsBoundary(oMsg);
    if (DebugFile.trace) DebugFile.writeln("part boundary is \"" + (sBoundary==null ? "null" : sBoundary) + "\"");

    try {
      oConn = getConnection();
     
      sSQL = "INSERT INTO " + DB.k_mime_msgs + "(gu_mimemsg,gu_workarea,gu_category,id_type,id_content,id_message,id_disposition,len_mimemsg,tx_md5,de_mimemsg,file_name,tx_encoding,tx_subject,dt_sent,dt_received,tx_email_from,nm_from,tx_email_reply,nm_to,id_priority,bo_answered,bo_deleted,bo_draft,bo_flagged,bo_recent,bo_seen,bo_spam,pg_message,nu_position,by_content) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

      if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement(" + sSQL + ")");

      oStmt = oConn.prepareStatement(sSQL);
      oStmt.setString(1, sGuMimeMsg);
      oStmt.setString(2, sGuWorkArea);

      if (oCatg.isNull(DB.gu_category))
        oStmt.setNull(3,Types.CHAR);
      else
        oStmt.setString(3, oCatg.getString(DB.gu_category));

      oStmt.setString(4, Gadgets.left(sContentType,254));
      oStmt.setString(5, Gadgets.left(sContentID,254));
      oStmt.setString(6, Gadgets.left(sMessageID, 254));
      oStmt.setString(7, Gadgets.left(sDisposition, 100));
      oStmt.setObject(8, iSize, Types.INTEGER);

      oStmt.setString(9, Gadgets.left(sContentMD5, 32));
      oStmt.setString(10, Gadgets.left(sDescription, 254));
      oStmt.setString(11, Gadgets.left(sFileName, 254));
      oStmt.setString(12, Gadgets.left(sEncoding,16));
      oStmt.setString(13, Gadgets.left(sSubject,254));
      oStmt.setTimestamp(14, tsSent);
      oStmt.setTimestamp(15, tsReceived);

      if (null==oFrom) {
        oStmt.setNull(16, Types.VARCHAR);
        oStmt.setNull(17, Types.VARCHAR);
      }
      else {
        oStmt.setString(16, Gadgets.left(oFrom.getAddress(),254));
        oStmt.setString(17, Gadgets.left(oFrom.getPersonal(),254));
      }

      if (null==oReply)
        oStmt.setNull(18, Types.VARCHAR);
      else
        oStmt.setString(18, Gadgets.left(oReply.getAddress(),254));

      Address[] aRecipients;
      String sRecipientName;

      aRecipients = oTo;
      if (null!=aRecipients) if (aRecipients.length==0) aRecipients=null;

      if (null!=aRecipients) {
        sRecipientName = ((InternetAddress) aRecipients[0]).getPersonal();
        if (null==sRecipientName) sRecipientName = ((InternetAddress) aRecipients[0]).getAddress();
        oStmt.setString(19, Gadgets.left(sRecipientName,254));
      } else {
        aRecipients = oCC;
        if (null!=aRecipients) {
          if (aRecipients.length>0) {
            sRecipientName = ((InternetAddress) aRecipients[0]).getPersonal();
            if (null==sRecipientName)
              sRecipientName = ((InternetAddress) aRecipients[0]).getAddress();
            oStmt.setString(19, Gadgets.left(sRecipientName,254));
          }
          else
            oStmt.setNull(19, Types.VARCHAR);
        }
        else {
          aRecipients = oBCC;
          if (null!=aRecipients) {
            if (aRecipients.length>0) {
              sRecipientName = ( (InternetAddress) aRecipients[0]).getPersonal();
              if (null == sRecipientName)
                sRecipientName = ( (InternetAddress) aRecipients[0]).getAddress();
              oStmt.setString(19, Gadgets.left(sRecipientName,254));
            }
            else
              oStmt.setNull(19, Types.VARCHAR);
          }
          else {
            oStmt.setNull(19, Types.VARCHAR);
          } // fi (MimeMessage.RecipientType.BCC)
        } // fi (MimeMessage.RecipientType.CC)
      } // fi (MimeMessage.RecipientType.TO)

      if (null==sPriority)
        oStmt.setNull(20, Types.VARCHAR);
      else
        oStmt.setString(20, sPriority);

      // For Oracle insert flags in NUMBER columns and message body in a BLOB column.
      // for any other RDBMS use SMALLINT columns for Flags and a LONGVARBINARY column for the body.

      dPgMessage = getNextMessage();

      if (oConn.getDataBaseProduct()==JDCConnection.DBMS_ORACLE) {
        if (DebugFile.trace) DebugFile.writeln("PreparedStatement.setBigDecimal(21, ...)");

        oStmt.setBigDecimal(21, new BigDecimal(oFlgs.contains(Flags.Flag.ANSWERED) ? "1" : "0"));
        oStmt.setBigDecimal(22, new BigDecimal(oFlgs.contains(Flags.Flag.DELETED) ? "1" : "0"));
        oStmt.setBigDecimal(23, new BigDecimal(0));
        oStmt.setBigDecimal(24, new BigDecimal(oFlgs.contains(Flags.Flag.FLAGGED) ? "1" : "0"));
        oStmt.setBigDecimal(25, new BigDecimal(oFlgs.contains(Flags.Flag.RECENT) ? "1" : "0"));
        oStmt.setBigDecimal(26, new BigDecimal(oFlgs.contains(Flags.Flag.SEEN) ? "1" : "0"));
        oStmt.setBigDecimal(27, new BigDecimal(bIsSpam ? "1" : "0"));
        oStmt.setBigDecimal(28, dPgMessage);
        oStmt.setBigDecimal(29, dPosition);

        if (DebugFile.trace) DebugFile.writeln("PreparedStatement.setBinaryStream(30, new ByteArrayInputStream("+String.valueOf(byOutStrm.size())+"))");

        if (byOutStrm.size()>0)
          oStmt.setBinaryStream(30, new ByteArrayInputStream(byOutStrm.toByteArray()), byOutStrm.size());
        else
          oStmt.setNull(30, Types.LONGVARBINARY);
      }
      else {
        if (DebugFile.trace) DebugFile.writeln("PreparedStatement.setShort(21, ...)");

        oStmt.setShort(21, (short) (oFlgs.contains(Flags.Flag.ANSWERED) ? 1 : 0));
        oStmt.setShort(22, (short) (oFlgs.contains(Flags.Flag.DELETED) ? 1 : 0));
        oStmt.setShort(23, (short) (0));
        oStmt.setShort(24, (short) (oFlgs.contains(Flags.Flag.FLAGGED) ? 1 : 0));
        oStmt.setShort(25, (short) (oFlgs.contains(Flags.Flag.RECENT) ? 1 : 0));
        oStmt.setShort(26, (short) (oFlgs.contains(Flags.Flag.SEEN) ? 1 : 0));
        oStmt.setShort(27, (short) (bIsSpam ? 1 : 0));
        oStmt.setBigDecimal(28, dPgMessage);
        oStmt.setBigDecimal(29, dPosition);

        if (DebugFile.trace) DebugFile.writeln("PreparedStatement.setBinaryStream(30, new ByteArrayInputStream("+String.valueOf(byOutStrm.size())+"))");

    if (DebugFile.trace) DebugFile.writeln("Binding ByteArrayInputStream of "+String.valueOf(byOutStrm.size()));
     
        if (byOutStrm.size()>0)
          oStmt.setBytes(30, byOutStrm.toByteArray());
          // oStmt.setBinaryStream(30, new ByteArrayInputStream(byOutStrm.toByteArray()), byOutStrm.size());
        else
          oStmt.setNull(30, Types.LONGVARBINARY);
      }

      if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate()");

      oStmt.executeUpdate();
      oStmt.close();
      oStmt=null;

    } catch (SQLException sqle) {
      String sTrace = "";
      try { sTrace = com.knowgate.debug.StackTraceUtil.getStackTrace(sqle);
        DebugFile.writeln(sTrace);
      } catch (Exception ignore) {}
      try { if (null!=oStmt) oStmt.close(); oStmt=null; } catch (Exception ignore) {}
      try { if (null!=oConn) oConn.rollback(); } catch (Exception ignore) {}
      throw new MessagingException(DB.k_mime_msgs + " " + sqle.getMessage(), sqle);
    }
    if ((iOpenMode&MODE_BLOB)!=0) {
      // Deallocate byte array containing message body for freeing memory as soon as possible
      try { byOutStrm.close(); } catch (IOException ignore) {}
      byOutStrm = null;
    }

    // *************************************************************************
    // Now that we have saved the main message reference proceed to store
    // its parts into k_mime_parts

    try {
      Object oContent = oMsg.getContent();
      if (oContent instanceof MimeMultipart) {
        try {
          saveMimeParts(oMsg, sMsgCharSeq, sBoundary, sGuMimeMsg, sMessageID, dPgMessage.intValue(), 0);
        } catch (MessagingException msge) {
          // Close Mbox file rollback and re-throw
          try { oConn.rollback(); } catch (Exception ignore) {}
          throw new MessagingException(msge.getMessage(), msge.getNextException());
        }
      } // fi (MimeMultipart)
    } catch (Exception xcpt) {
      try { oConn.rollback(); } catch (Exception ignore) {}
      throw new MessagingException("MimeMessage.getContent() " + xcpt.getMessage(), xcpt);
    }

    // *************************************************************************
    // Store message recipients at k_inet_addrs

    try {
      if (oConn.getDataBaseProduct()==JDCConnection.DBMS_MYSQL)
        sSQL = "SELECT "+DB.gu_contact+","+DB.gu_company+","+DB.tx_name+","+DB.tx_surname+","+DB.tx_surname+" FROM "+DB.k_member_address+" WHERE "+DB.tx_email+"=? AND "+DB.gu_workarea+"=? UNION SELECT "+DB.gu_user+",CONVERT('****************************USER' USING utf8),"+DB.nm_user+","+DB.tx_surname1+","+DB.tx_surname2+" FROM "+DB.k_users+" u WHERE (u."+DB.tx_main_email+"=? OR u."+DB.tx_alt_email+"=? OR EXISTS (SELECT a."+DB.gu_user+" FROM "+DB.k_user_mail+" a WHERE a."+DB.gu_user+"=u."+DB.gu_user+" AND a."+DB.tx_main_email+"=?)) AND "+DB.gu_workarea+"=?";
      else
        sSQL = "SELECT "+DB.gu_contact+","+DB.gu_company+","+DB.tx_name+","+DB.tx_surname+","+DB.tx_surname+" FROM "+DB.k_member_address+" WHERE "+DB.tx_email+"=? AND "+DB.gu_workarea+"=? UNION SELECT "+DB.gu_user+",'****************************USER',"+DB.nm_user+","+DB.tx_surname1+","+DB.tx_surname2+" FROM "+DB.k_users+" u WHERE (u."+DB.tx_main_email+"=? OR u."+DB.tx_alt_email+"=? OR EXISTS (SELECT a."+DB.gu_user+" FROM "+DB.k_user_mail+" a WHERE a."+DB.gu_user+"=u."+DB.gu_user+" AND a."+DB.tx_main_email+"=?)) AND "+DB.gu_workarea+"=?";
    } catch (SQLException sqle) {
      if (DebugFile.trace) DebugFile.writeln("SQLException " + sqle.getMessage());
      sSQL = "SELECT "+DB.gu_contact+","+DB.gu_company+","+DB.tx_name+","+DB.tx_surname+","+DB.tx_surname+" FROM "+DB.k_member_address+" WHERE "+DB.tx_email+"=? AND "+DB.gu_workarea+"=? UNION SELECT "+DB.gu_user+",'****************************USER',"+DB.nm_user+","+DB.tx_surname1+","+DB.tx_surname2+" FROM "+DB.k_users+" u WHERE (u."+DB.tx_main_email+"=? OR u."+DB.tx_alt_email+"=? OR EXISTS (SELECT a."+DB.gu_user+" FROM "+DB.k_user_mail+" a WHERE a."+DB.gu_user+"=u."+DB.gu_user+" AND a."+DB.tx_main_email+"=?)) AND "+DB.gu_workarea+"=?";
    }

    if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement(" + sSQL + ")");

    PreparedStatement oAddr = null;

    try {
      oAddr = oConn.prepareStatement(sSQL, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
      ResultSet oRSet;

      InternetAddress oInetAdr;
      String sTxEmail, sGuCompany, sGuContact, sTxName, sTxSurname1, sTxSurname2, sTxPersonal;

      // Get From address and keep them into pFrom properties

      if (oFrom!=null) {
        oAddr.setString(1, oFrom.getAddress());
        oAddr.setString(2, sGuWorkArea);
        oAddr.setString(3, oFrom.getAddress());
        oAddr.setString(4, oFrom.getAddress());
        oAddr.setString(5, oFrom.getAddress());
        oAddr.setString(6, sGuWorkArea);

        oRSet = oAddr.executeQuery();
        if (oRSet.next()) {
          sGuContact = oRSet.getString(1);
          if (oRSet.wasNull()) sGuContact = "null";
          sGuCompany = oRSet.getString(2);
          if (oRSet.wasNull()) sGuCompany = "null";

          if (sGuCompany.equals("****************************USER")) {
            sTxName = oRSet.getString(3);
            if (oRSet.wasNull()) sTxName = "";
            sTxSurname1 = oRSet.getString(4);
            if (oRSet.wasNull()) sTxSurname1 = "";
            sTxSurname2 = oRSet.getString(4);
            if (oRSet.wasNull()) sTxSurname2 = "";
            sTxPersonal = Gadgets.left(sTxName+" "+sTxSurname1+" "+sTxSurname2, 254).replace(',',' ').trim();
          }
          else
            sTxPersonal = "null";

          if (DebugFile.trace) DebugFile.writeln("from "+sGuContact+","+sGuCompany+","+sTxPersonal);
          pFrom.put(oFrom.getAddress(), sGuContact+","+sGuCompany+","+sTxPersonal);
        }
        else
          pFrom.put(oFrom.getAddress(), "null,null,null");

      oRSet.close();
      } // fi (oFrom)

      if (DebugFile.trace) DebugFile.writeln("from count = " + pFrom.size());

      // Get TO address and keep them into pTo properties

      if (oTo!=null) {
        for (int t=0; t<oTo.length; t++) {
          oInetAdr = (InternetAddress) oTo[t];
          sTxEmail = Gadgets.left(oInetAdr.getAddress(), 254);

          oAddr.setString(1, sTxEmail);
          oAddr.setString(2, sGuWorkArea);
          oAddr.setString(3, sTxEmail);
          oAddr.setString(4, sTxEmail);
          oAddr.setString(5, sTxEmail);
          oAddr.setString(6, sGuWorkArea);

          oRSet = oAddr.executeQuery();
          if (oRSet.next()) {
            sGuContact = oRSet.getString(1);
            if (oRSet.wasNull()) sGuContact = "null";
            sGuCompany = oRSet.getString(2);
            if (oRSet.wasNull()) sGuCompany = "null";
            if (sGuCompany.equals("****************************USER")) {
              sTxName = oRSet.getString(3);
              if (oRSet.wasNull()) sTxName = "";
              sTxSurname1 = oRSet.getString(4);
              if (oRSet.wasNull()) sTxSurname1 = "";
              sTxSurname2 = oRSet.getString(4);
              if (oRSet.wasNull()) sTxSurname2 = "";
              sTxPersonal = Gadgets.left(sTxName+" "+sTxSurname1+" "+sTxSurname2, 254).replace(',',' ').trim();
            }
            else
              sTxPersonal = "null";

            pTo.put(sTxEmail, sGuContact+","+sGuCompany+","+sTxPersonal);
          } // fi (oRSet.next())
          else
            pTo.put(sTxEmail, "null,null,null");

          oRSet.close();
        } // next (t)
      } // fi (oTo)

      if (DebugFile.trace) DebugFile.writeln("to count = " + pTo.size());

      // Get CC address and keep them into pTo properties

      if (oCC!=null) {
        for (int c=0; c<oCC.length; c++) {
          oInetAdr = (InternetAddress) oCC[c];
          sTxEmail = Gadgets.left(oInetAdr.getAddress(), 254);

          oAddr.setString(1, sTxEmail);
          oAddr.setString(2, sGuWorkArea);
          oAddr.setString(3, sTxEmail);
          oAddr.setString(4, sTxEmail);
          oAddr.setString(5, sTxEmail);
          oAddr.setString(6, sGuWorkArea);

          oRSet = oAddr.executeQuery();
          if (oRSet.next()) {
            sGuContact = oRSet.getString(1);
            if (oRSet.wasNull()) sGuContact = "null";
            sGuCompany = oRSet.getString(2);
            if (oRSet.wasNull()) sGuCompany = "null";
            if (sGuCompany.equals("****************************USER")) {
              sTxName = oRSet.getString(3);
              if (oRSet.wasNull()) sTxName = "";
              sTxSurname1 = oRSet.getString(4);
              if (oRSet.wasNull()) sTxSurname1 = "";
              sTxSurname2 = oRSet.getString(4);
              if (oRSet.wasNull()) sTxSurname2 = "";
              sTxPersonal = Gadgets.left(sTxName+" "+sTxSurname1+" "+sTxSurname2, 254).replace(',',' ').trim();
            }
            else
              sTxPersonal = "null";

            pCC.put(sTxEmail, sGuContact+","+sGuCompany+","+sTxPersonal);
          } // fi (oRSet.next())
          else
            pCC.put(sTxEmail, "null,null,null");

          oRSet.close();
        } // next (c)
      } // fi (oCC)

      if (DebugFile.trace) DebugFile.writeln("cc count = " + pCC.size());

      // Get BCC address and keep them into pTo properties

      if (oBCC!=null) {
        for (int b=0; b<oBCC.length; b++) {
          oInetAdr = (InternetAddress) oBCC[b];
          sTxEmail = Gadgets.left(oInetAdr.getAddress(), 254);

          oAddr.setString(1, sTxEmail);
          oAddr.setString(2, sGuWorkArea);
          oAddr.setString(3, sTxEmail);
          oAddr.setString(4, sTxEmail);
          oAddr.setString(5, sTxEmail);
          oAddr.setString(6, sGuWorkArea);

          oRSet = oAddr.executeQuery();
          if (oRSet.next()) {
            sGuContact = oRSet.getString(1);
            if (oRSet.wasNull()) sGuContact = "null";
            sGuCompany = oRSet.getString(2);
            if (oRSet.wasNull()) sGuCompany = "null";
            if (sGuCompany.equals("****************************USER")) {
              sTxName = oRSet.getString(3);
              if (oRSet.wasNull()) sTxName = "";
              sTxSurname1 = oRSet.getString(4);
              if (oRSet.wasNull()) sTxSurname1 = "";
              sTxSurname2 = oRSet.getString(4);
              if (oRSet.wasNull()) sTxSurname2 = "";
              sTxPersonal = Gadgets.left(sTxName+" "+sTxSurname1+" "+sTxSurname2, 254).replace(',',' ').trim();
            }
            else
              sTxPersonal = "null";

            pBCC.put(sTxEmail, sGuContact+","+sGuCompany);
          } // fi (oRSet.next())
          else
            pBCC.put(sTxEmail, "null,null,null");

          oRSet.close();
        } // next (b)
      } // fi (oCBB)

      if (DebugFile.trace) DebugFile.writeln("bcc count = " + pBCC.size());

      oAddr.close();

      sSQL = "INSERT INTO " + DB.k_inet_addrs + " (gu_mimemsg,id_message,pg_message,tx_email,tp_recipient,gu_user,gu_contact,gu_company,tx_personal) VALUES ('"+sGuMimeMsg+"',?,"+String.valueOf(dPgMessage.intValue())+",?,?,?,?,?,?)";

      if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement(" + sSQL + ")");

      oStmt = oConn.prepareStatement(sSQL);

      java.util.Enumeration oMailEnum;
      String[] aRecipient;

      if (!pFrom.isEmpty()) {
        oMailEnum = pFrom.keys();
        while (oMailEnum.hasMoreElements()) {
          oStmt.setString(1, sMessageID);
          sTxEmail = (String) oMailEnum.nextElement();
          if (DebugFile.trace) DebugFile.writeln("processing mail address "+sTxEmail);
          aRecipient = Gadgets.split(pFrom.getProperty(sTxEmail),',');

          oStmt.setString(2, sTxEmail);
          oStmt.setString(3, "from");

          if (aRecipient[0].equals("null") && aRecipient[1].equals("null")) {
            oStmt.setNull(4, Types.CHAR);
            oStmt.setNull(5, Types.CHAR);
            oStmt.setNull(6, Types.CHAR);
          }
          else if (aRecipient[1].equals("****************************USER")) {
            oStmt.setString(4, aRecipient[0]);
            oStmt.setNull(5, Types.CHAR);
            oStmt.setNull(6, Types.CHAR);
          }
          else {
            oStmt.setNull(4, Types.CHAR);
            oStmt.setString(5, aRecipient[0].equals("null") ? null : aRecipient[0]);
            oStmt.setString(6, aRecipient[1].equals("null") ? null : aRecipient[1]);
          }

          if (aRecipient[2].equals("null"))
            oStmt.setNull(7, Types.VARCHAR);
          else
            oStmt.setString(7, aRecipient[2]);

          if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate()");
          oStmt.executeUpdate();
        } // wend
      } // fi (from)

      if (!pTo.isEmpty()) {
        oMailEnum = pTo.keys();
        while (oMailEnum.hasMoreElements()) {
          oStmt.setString(1, sMessageID);
          sTxEmail = (String) oMailEnum.nextElement();
          aRecipient = Gadgets.split(pTo.getProperty(sTxEmail),',');

          oStmt.setString(2, sTxEmail);
          oStmt.setString(3, "to");

          if (aRecipient[0].equals("null") && aRecipient[1].equals("null")) {
            oStmt.setNull(4, Types.CHAR);
            oStmt.setNull(5, Types.CHAR);
            oStmt.setNull(6, Types.CHAR);
          }
          else if (aRecipient[1].equals("****************************USER")) {
            oStmt.setString(4, aRecipient[0]);
            oStmt.setNull(5, Types.CHAR);
            oStmt.setNull(6, Types.CHAR);
          }
          else {
            oStmt.setNull(4, Types.CHAR);
            oStmt.setString(5, aRecipient[0].equals("null") ? null : aRecipient[0]);
            oStmt.setString(6, aRecipient[1].equals("null") ? null : aRecipient[1]);
          }

          if (aRecipient[2].equals("null"))
            oStmt.setNull(7, Types.VARCHAR);
          else
            oStmt.setString(7, aRecipient[2]);

          if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate()");

          oStmt.executeUpdate();
        } // wend
      } // fi (to)

      if (!pCC.isEmpty()) {
        oMailEnum = pCC.keys();
        while (oMailEnum.hasMoreElements()) {
          oStmt.setString(1, sMessageID);
          sTxEmail = (String) oMailEnum.nextElement();
          aRecipient = Gadgets.split(pCC.getProperty(sTxEmail),',');

          oStmt.setString(2, sTxEmail);
          oStmt.setString(3, "cc");

          if (aRecipient[0].equals("null") && aRecipient[1].equals("null")) {
            oStmt.setNull(4, Types.CHAR);
            oStmt.setNull(5, Types.CHAR);
            oStmt.setNull(6, Types.CHAR);
          }
          else if (aRecipient[1].equals("****************************USER")) {
            oStmt.setString(4, aRecipient[0]);
            oStmt.setString(5, null);
            oStmt.setString(6, null);
          }
          else {
            oStmt.setString(4, null);
            oStmt.setString(5, aRecipient[0].equals("null") ? null : aRecipient[0]);
            oStmt.setString(6, aRecipient[1].equals("null") ? null : aRecipient[1]);
          }

          if (aRecipient[2].equals("null"))
            oStmt.setNull(7, Types.VARCHAR);
          else
            oStmt.setString(7, aRecipient[2]);

          if (DebugFile.trace) DebugFile.writeln("Statement.executeUpdate()");

          oStmt.executeUpdate();
        } // wend
      } // fi (cc)

      if (!pBCC.isEmpty()) {
        oMailEnum = pBCC.keys();
        while (oMailEnum.hasMoreElements()) {
          oStmt.setString(1, sMessageID);
          sTxEmail = (String) oMailEnum.nextElement();
          aRecipient = Gadgets.split(pBCC.getProperty(sTxEmail),',');

          oStmt.setString(2, sTxEmail);
          oStmt.setString(3, "bcc");

          if (aRecipient[0].equals("null") && aRecipient[1].equals("null")) {
            oStmt.setNull(4, Types.CHAR);
            oStmt.setNull(5, Types.CHAR);
            oStmt.setNull(6, Types.CHAR);
          }
          else if (aRecipient[1].equals("****************************USER")) {
            oStmt.setString(4, aRecipient[0]);
            oStmt.setNull(5, Types.CHAR);
            oStmt.setNull(6, Types.CHAR);
          }
          else {
            oStmt.setNull(4, Types.CHAR);
            oStmt.setString(5, aRecipient[0].equals("null") ? null : aRecipient[0]);
            oStmt.setString(6, aRecipient[1].equals("null") ? null : aRecipient[1]);
          }

          if (aRecipient[2].equals("null"))
            oStmt.setNull(7, Types.VARCHAR);
          else
            oStmt.setString(7, aRecipient[2]);

          oStmt.executeUpdate();
        } // wend
      } // fi (bcc)

      oStmt.close();
      oStmt=null;

      oStmt = oConn.prepareStatement("UPDATE "+DB.k_categories+" SET "+DB.len_size+"="+DB.len_size+"+"+String.valueOf(iSize)+" WHERE "+DB.gu_category+"=?");
      oStmt.setString(1, getCategory().getString(DB.gu_category));
      oStmt.executeUpdate();
      oStmt.close();
      oStmt=null;

View Full Code Here

Examples of com.knowgate.jdc.JDCConnection

      throw new javax.mail.FolderClosedException(this, "Folder is closed");
    }

    Properties oRetVal;
    PreparedStatement oStmt;
    JDCConnection oJdcn = null;
   
    try {
      oJdcn = getConnection();
    } catch (MessagingException msge) {
      throw new SQLException(msge.getMessage(), msge);
    }
   
    if (sMsgId.length()==32) {
      if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement(SELECT " + DB.gu_mimemsg + "," + DB.id_message + "," + DB.pg_message + "," + DB.tx_subject + " FROM " + DB.k_mime_msgs + " WHERE " + DB.gu_mimemsg + "='"+sMsgId+"' OR " + DB.id_message + "='"+sMsgId+"') AND " + DB.gu_category + "='"+getCategoryGuid()+"' AND " + DB.bo_deleted + "<>1)");

      oStmt = oJdcn.prepareStatement("SELECT " + DB.gu_mimemsg + "," + DB.id_message + "," + DB.pg_message + "," + DB.tx_subject + "," + DB.tx_email_from + "," + DB.tx_email_reply + "," + DB.nm_from +
                                     " FROM " + DB.k_mime_msgs +
                                     " WHERE (" + DB.gu_mimemsg + "=? OR " + DB.id_message + "=?) AND " + DB.gu_category + "=? AND " + DB.bo_deleted + "<>1",
                                     ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
      oStmt.setString(1, sMsgId);
      oStmt.setString(2, sMsgId);
      oStmt.setString(3, getCategoryGuid());
    }
    else {
      if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement(SELECT " + DB.gu_mimemsg + "," + DB.id_message + "," + DB.pg_message + "," + DB.tx_subject + "," + DB.tx_email_from + "," + DB.tx_email_reply + "," + DB.nm_from + " FROM " + DB.k_mime_msgs + " WHERE " + DB.id_message + "='"+sMsgId+"' AND " + DB.gu_category + "='"+getCategoryGuid()+"' AND " + DB.bo_deleted + "<>1)");

      oStmt = oJdcn.prepareStatement("SELECT " + DB.gu_mimemsg + "," + DB.id_message + "," + DB.pg_message + "," +
                                                 DB.tx_subject + "," + DB.tx_email_from + "," + DB.tx_email_reply + "," +
                                                 DB.nm_from + " FROM " + DB.k_mime_msgs +
                                     " WHERE " + DB.id_message + "=? AND " + DB.gu_category + "=? AND " + DB.bo_deleted + "<>1",
                                     ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
      oStmt.setString(1, sMsgId);
View Full Code Here

Examples of com.knowgate.jdc.JDCConnection

    String sMsgCharSeq;
    String sContentMD5;
    int iSize;
    Integer oSize;
    MboxFile oInputMbox = null;
  JDCConnection oConn = null;
 
    if (DebugFile.trace) {
      DebugFile.writeln("Begin DBFolder.reindexMbox("+sMboxFilePath+")");
      DebugFile.incIdent();
    }

    try {
      ByteArrayOutputStream byOutStrm = null;
      Session oSession = ((DBStore)getStore()).getSession();
      String sGuWorkArea = ((DBStore)getStore()).getUser().getString(DB.gu_workarea);
      String sGuFolder = getCategoryGuid();
      oInputMbox = new MboxFile(sMboxFilePath, MboxFile.READ_ONLY);
      DBSubset oMsgs = new DBSubset (DB.k_mime_msgs, DB.gu_mimemsg+","+DB.gu_workarea, DB.gu_category+"=?", 1000);
      oConn = getConnection();
      iMsgCount = oMsgs.load(oConn, new Object[]{sGuFolder});

      if (DebugFile.trace) DebugFile.writeln(String.valueOf(iMsgCount)+" indexed messages");

      for (int m=0; m<iMsgCount; m++)
        DBMimeMessage.delete(oConn, sGuFolder, oMsgs.getString(0,m));

      iMsgCount = oInputMbox.getMessageCount();

      if (DebugFile.trace) DebugFile.writeln(String.valueOf(iMsgCount)+" stored messages");

      for (int m=0; m<iMsgCount; m++) {
        sGuMimeMsg = Gadgets.generateUUID();
        oMsgStrm = oInputMbox.getMessageAsStream(m);
        oMsg = new MimeMessage(oSession, oMsgStrm);
        oHlpr = new HeadersHelper(oMsg);
        oRecps = new RecipientsHelper(oMsg);
        dPgMessage = new BigDecimal(m);
        sMessageID = oHlpr.decodeMessageId(sGuMimeMsg);
        sMsgCharSeq = DBMimeMessage.source(oMsg, "ISO8859_1");
        sContentMD5 = oHlpr.getContentMD5();
        if (null==sContentMD5) sContentMD5 = HeadersHelper.computeContentMD5(sMsgCharSeq.getBytes());
        iSize = ((iOpenMode&MODE_MBOX)!=0) ? sMsgCharSeq.length() : oMsg.getSize();
        oSize = (iSize>=0 ? new Integer(iSize) : null);
        byOutStrm = getBodyAsStream(oMsg);

        indexMessage(Gadgets.generateUUID(), sGuWorkArea, oMsg, oSize,
                   ((iOpenMode&MODE_MBOX)!=0) ? new BigDecimal(oInputMbox.getMessagePosition(m)) : null,
                   oHlpr.getContentType(),
                   oHlpr.getContentID(), sMessageID,
                   oHlpr.getDisposition(), sContentMD5,
                   oHlpr.getDescription(), oHlpr.getFileName(),
                   oHlpr.getEncoding(), oHlpr.getSubject(),
                   oHlpr.getPriority(), oHlpr.getFlags(),
                   oHlpr.getSentTimestamp(), oHlpr.getReceivedTimestamp(),
                   RecipientsHelper.getFromAddress(oMsg),
                   RecipientsHelper.getReplyAddress(oMsg),
                   oRecps.getRecipients(Message.RecipientType.TO),
                   oRecps.getRecipients(Message.RecipientType.CC),
                   oRecps.getRecipients(Message.RecipientType.BCC),
                   oHlpr.isSpam(), byOutStrm, sMsgCharSeq);

        byOutStrm.close();
        oMsgStrm.close();
      } // next
      oInputMbox.close();
      oInputMbox=null;
      oConn.commit();
    } catch (FileNotFoundException fnfe) {
      try {oConn.rollback();} catch (Exception ignore) {}
      throw fnfe;
    } catch (IOException ioe) {
      try {oConn.rollback();} catch (Exception ignore) {}
      throw ioe;
    } catch (MessagingException me) {
      try {oConn.rollback();} catch (Exception ignore) {}
      throw me;
    } catch (SQLException sqle) {
      try {oConn.rollback();} catch (Exception ignore) {}
      throw sqle;
    } finally {
      try { if (null!=oInputMbox) oInputMbox.close(); } catch (Exception ignore) {}
    }
    if (DebugFile.trace) {
View Full Code Here

Examples of com.knowgate.jdc.JDCConnection

      DBBind oDBB = (DBBind) getPortletContext().getAttribute("GlobalDBBind");

      DBSubset oBugs = new DBSubset (DB.k_bugs, DB.gu_bug + "," + DB.tl_bug,
                                     "(" + DB.tx_status + " IS NULL OR " + DB.tx_status + " IN ('EN ESPERA', 'ASIGNADO', 'VERIFICADO')) AND (" + DB.nm_assigned + "=? OR " + DB.tx_rep_mail + " IN (SELECT " + DB.tx_main_email + " FROM " + DB.k_users + " WHERE " + DB.gu_user + "=?)) ORDER BY " + DB.od_priority + " DESC", 10);

      JDCConnection oCon = null;

      try  {
        oCon = oDBB.getConnection("MyIncidencesTab");

        iBugs = oBugs.load (oCon, new Object[]{sUserId,sUserId});

        oCon.close("MyIncidencesTab");
        oCon = null;

        sXML += "<bugs>\n"+oBugs.toXML("","bug")+"</bugs>";
      }
      catch (SQLException e) {
        sXML += "<bugs/>";

        try {
          if (null != oCon)
            if (!oCon.isClosed())
              oCon.close("MyIncidencesTab");
        } catch (SQLException ignore) { }
      }
    }

    try {
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.