Hi Valdis
Looks to me as if you try to give a List of XWikiAttachments to a method
expecting Attachments. The class Attachment is the API class of
XWikiAttachment. So if you call getAttachmentList() on an XWikiDocument it
returns a List of XWikiAttachments, but calling the same method on a
Document returns a List of Attachments.
Long story short: I suppose calling getAttachmentList() on the source
Document instead of the XWikiDocument should solve your problem.
I hope this helps
Edo
On Thu, Apr 25, 2013 at 4:31 PM, Valdis Vītoliņš <valdis.vitolins(a)odo.lv>wrote;wrote:
I'm writing custom listener to send e-mail after
document updates
according to:
http://platform.xwiki.org/xwiki/bin/view/DevGuide/GroovyNotificationTutoria…:
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
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users