Hi, I'm trying to use the notification system to trigger the sending of email whenever a comment is added to a blog article. I'm patterning my groovy class after the pircbot example on the xwiki snippets site.
My system is xwiki workspaces as a virtual xwiki under xem. The platform version is 1.5.2. Here's my groovy class (XWSNotify.BlogMailNotificationGroovyClass): /* Groovy Class #* */ import com.xpn.xwiki.api.XWiki; import com.xpn.xwiki.XWikiContext; import com.xpn.xwiki.notify.XWikiDocChangeNotificationInterface; import com.xpn.xwiki.notify.DocObjectChangedRule; import com.xpn.xwiki.notify.XWikiNotificationRule; import com.xpn.xwiki.doc.XWikiDocument; public class BlogMailNotificationGroovyClass implements \ XWikiDocChangeNotificationInterface { def xwiki; def rule; def name; public void initClasses(XWikiContext context) { this.xwiki = context.getWiki(); // listen to notifications this.rule = DocObjectChangedRule(this); context.getWiki().getNotificationManager().addGeneralRule(rule); } public void notify(XWikiNotificationRule rule, XWikiDocument newdoc, \ XWikiDocument olddoc, int event, XWikiContext context) { def length = newdoc.getSpace().length(); def lastFour = length - 4; if(newdoc.getSpace().substring(lastFour) == "Blog") { def ms = xwiki.getPlugin("mailsender"); def nb = ms.sendHtmlMessage(context.getUser(), "[EMAIL PROTECTED] ", \ context.get("ccrecipients"), context.get("bccrecipients"), \ context.get("subject"), newdoc.getRenderedContent(), \ newdoc.getContent(), newdoc.getAttachments()); } } } /* *# */ Here's a velocity script I'm using to initialize/test: #set($sc = $context.getContext().getEngineContext().getServletContext()) $sc.getAttribute("blgmailnotif")<br/> #set($blgmlnotif = $xwiki.parseGroovyFromPage("XWSNotify.BlogMailNotificationGroovyClass")) #set($ok = $sc.setAttribute("blgmailnotif", $blgmlnotif)) #set($blgmailnotif = $sc.getAttribute("blgmailnotif")) $sc.getAttribute("blgmailnotif")<br/> #set($ok = $blgmlnotif.initClasses($context)) #set($ok = $blgmlnotif.notify($blgmlnotif.rule,$newdoc,$newdoc, 3,$context)) Here's the output from the velocity script: [EMAIL PROTECTED] [EMAIL PROTECTED] So, the groovy class gets initialized to a new reference successfully each time parseGroovyFromPage is called. Here's what appears in the log after running the velocity script: [ERROR] Left side ($request.title) of '!=' operation has null value. Operation not possible. [line 53, column 43] [WARNING] Cannot retrieve method notify from object of class BlogMailNotificationGroovyClass due to security restrictions. If I alter the velocity script to: #set($sc = $context.getContext().getEngineContext().getServletContext()) $sc.getAttribute("blgmailnotif")<br/> Here's what appears in the log: [ERROR] Left side ($request.title) of '!=' operation has null value. Operation not possible. [line 53, column 43] So, the [WARNING] is the only log entry pertaining to the groovy class. If I add a comment to a Blog article (with or without the BlogMailNotificationGroovyClass initialized), the following appears in the log: [ERROR] Left side ($index) of addition operation has null value. Operation not possible. [line 20, column 25] [ERROR] Left side ($index) of addition operation has null value. Operation not possible. [line 20, column 25] [ERROR] Left side ($index) of addition operation has null value. Operation not possible. [line 20, column 25] [ERROR] Left side ($index) of addition operation has null value. Operation not possible. [line 20, column 25] [ERROR] Left side ($index) of addition operation has null value. Operation not possible. [line 20, column 25] [ERROR] Left side ($index) of addition operation has null value. Operation not possible. [line 20, column 25] [ERROR] Left side ($index) of addition operation has null value. Operation not possible. [line 20, column 25] [ERROR] Left side ($index) of addition operation has null value. Operation not possible. [line 20, column 25] [ERROR] Left side ($index) of addition operation has null value. Operation not possible. [line 20, column 25] The number of lines corresponds to the number of comments present in the Blog article. There's nothing in the log pertaining to the groovy class. What am I doing wrong? Is there a way to put additional groovy debugging information into the log? Thanks, Dan Svoboda University of Pittsburgh Center for HIV Protein Interactions _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users