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