I'm writing custom listener to send e-mail after document updates
according to:
http://platform.xwiki.org/xwiki/bin/view/DevGuide/GroovyNotificationTutorial and:
http://xwiki.475771.n2.nabble.com/Send-an-email-in-an-event-listener-td7579…
Although adding attachment is working in Velocity as described in:
http://extensions.xwiki.org/xwiki/bin/view/Extension/Mail+Sender+Plugin
Similar approach in Groovy raises exception:
java.lang.ClassCastException: com.xpn.xwiki.doc.XWikiAttachment cannot
be cast to com.xpn.xwiki.api.Attachment
at
com.xpn.xwiki.plugin.mailsender.MailSenderPlugin.createMimeMultipart(MailSenderPlugin.java:391)
~[xwiki-platform-mailsender-4.5.jar:na]
at
com.xpn.xwiki.plugin.mailsender.MailSenderPlugin.createMimeMessage(MailSenderPlugin.java:327)
~[xwiki-platform-mailsender-4.5.jar:na]
at
com.xpn.xwiki.plugin.mailsender.MailSenderPlugin.sendMails(MailSenderPlugin.java:726)
~[xwiki-platform-mailsender-4.5.jar:na]
at
com.xpn.xwiki.plugin.mailsender.MailSenderPlugin.sendMail(MailSenderPlugin.java:673)
~[xwiki-platform-mailsender-4.5.jar:na]
at
com.xpn.xwiki.plugin.mailsender.MailSenderPlugin.sendMail(MailSenderPlugin.java:659)
~[xwiki-platform-mailsender-4.5.jar:na]
at
com.xpn.xwiki.plugin.mailsender.MailSenderPluginApi.sendMail(MailSenderPluginApi.java:171)
[xwiki-platform-mailsender-4.5.jar:na]
at
com.xpn.xwiki.plugin.mailsender.MailSenderPluginApi.sendTextMessage(MailSenderPluginApi.java:98)
[xwiki-platform-mailsender-4.5.jar:na]
at com.xpn.xwiki.plugin.mailsender.MailSender
$sendTextMessage.call(Unknown Source)
[xwiki-platform-mailsender-4.5.jar:na]
at EmailSenderListener.onEvent(Script22.groovy:34) [script:na]
...
and line is: def attachments = source.getAttachmentList()
What should I do?
Thanks!
Valdis