#created on: 2007.04.03
package
hr.combis.unimsg.ruleengine.rules.message
#list any import classes here.
import
javax.mail.internet.MimeMessage;
import
javax.mail.internet.InternetAddress;
import
javax.mail.Message;
import
javax.mail.Header;
import
javax.mail.Multipart;
import
javax.mail.Part;
import
java.util.Enumeration;
import
java.lang.String;
import
java.lang.Object;
import
java.lang.Integer;
#declare any global variables here
#global IMessageService messageService;
rule
"Initial rule"
when
#conditions
msg : MimeMessage( )
then
#actions
drools.setFocus(
"Content group");
end
rule
"Header parsing rule"
agenda-group "Header group"
when
#conditions
msg : MimeMessage( )
then
#actions
if (msg.getContent() != null && msg.getAllHeaders() !=
null){
System.out.println(
"TODO: header processing");
}
end
rule
"Content parsing rule"
agenda-group "Content group"
when
#conditions
msg : MimeMessage( )
then
#actions
if (msg.getContent() != null){
if (msg.getContent() instanceof Multipart){
System.out.println(
"mail je multipart");
Object body = msg.getContent();
processMultipart((Multipart) body);
}
else{
System.out.println(
"mail je singlepart");
singlePart(msg);
}
}
drools.setFocus(
"Header group");
end
function
void singlePart(Part p) {
String fileName = p.getFileName( );
String disposition = p.getDisposition( );
String contentType = p.getContentType( );
if (contentType.toLowerCase( ).startsWith("multipart/")) {
System.out.println(
"Part ima svoje partove");
ProcessMultipart.processMultipart((Multipart) p.getContent( ) );
}
p.writeTo(System.out);
}
function
void processMultipart(Multipart mp){
System.out.println(
"procesiram multipart");
for (int i = 0; i < mp.getCount(); i++){
Part part = mp.getBodyPart(i);
System.out.println(
"Procesiram part: " + i);
SinglePart.singlePart(part);
}
}
When i assert in working memory multipart message , the first is being called processMultipart() method, which then calls singlePart() method for each part and that works just fine. But, when singlePart needs to call processMultipart() again (thats just the way javamail api works), everything crashes with no specific explanation. Here is the part of log:
ERROR 07 04 2007 12:36:05,031 - Bad error
com.ibm.ejs.container.UnknownLocalException:
at org.codehaus.janino.Parser.parseAdditiveExpression(Parser.java)
at org.codehaus.janino.Parser.parseShiftExpression
(Parser.java)
at org.codehaus.janino.Parser.parseRelationalExpression(Parser.java)
at org.codehaus.janino.Parser.parseEqualityExpression(Parser.java)
at org.codehaus.janino.Parser.parseAndExpression(Parser.java
)
at org.codehaus.janino.Parser.parseExclusiveOrExpression(Parser.java)
at org.codehaus.janino.Parser.parseInclusiveOrExpression(Parser.java)
at org.codehaus.janino.Parser.parseConditionalAndExpression(Parser.java
)
at org.codehaus.janino.Parser.parseConditionalOrExpression(Parser.java)
at org.codehaus.janino.Parser.parseConditionalExpression(Parser.java)
at org.codehaus.janino.Parser.parseAssignmentExpression(Parser.java
)
at org.codehaus.janino.Parser.parseExpression(Parser.java)
at org.codehaus.janino.Parser.parsePrimary(Parser.java)
at org.codehaus.janino.Parser.parseUnaryExpression(Parser.java)
at org.codehaus.janino.Parser.parseMultiplicativeExpression
(Parser.java)
at org.codehaus.janino.Parser.parseAdditiveExpression(Parser.java)
at org.codehaus.janino.Parser.parseShiftExpression(Parser.java)
at org.codehaus.janino.Parser.parseRelationalExpression(Parser.java
)
at org.codehaus.janino.Parser.parseEqualityExpression(Parser.java)
at org.codehaus.janino.Parser.parseAndExpression(Parser.java)
at org.codehaus.janino.Parser.parseExclusiveOrExpression(Parser.java)
at org.codehaus.janino.Parser.parseInclusiveOrExpression
(Parser.java)
at org.codehaus.janino.Parser.parseConditionalAndExpression(Parser.java)
at org.codehaus.janino.Parser.parseConditionalOrExpression(Parser.java)
at org.codehaus.janino.Parser.parseConditionalExpression
(Parser.java)
at org.codehaus.janino.Parser.parseAssignmentExpression(Parser.java)
at org.codehaus.janino.Parser.parseExpression(Parser.java)
at org.codehaus.janino.Parser.parseArgumentList(Parser.java)
at
org.codehaus.janino.Parser.parseArguments(Parser.java)
at org.codehaus.janino.Parser.parsePrimary(Parser.java)
at org.codehaus.janino.Parser.parseUnaryExpression(Parser.java)
.......
Please, help. Thnx