As written previously I'm trying to trigger some code on document save.
Sergiu explained issue I had with (com.xpn.xwiki.doc.XWikiDocument vs.
com.xpn.xwiki.api.Document). I got most the stuff to work except (last
two lines of code) I am not able to save image from url as attachment.
I get Wrapped Exception: No signature of method
com.xpn.xwiki.doc.XWikiDocument.addAttachment() is applicable for
argument types: (java.lang.String, [B, com.xpn.xwiki.XWikiContext)
values: {"notif1.png", [-119,.., ["vcontext":...]}
Looking at the documentation at
http://maven.xwiki.org/site/xwiki-core-parent/xwiki-core/apidocs/com/xpn
/xwiki/doc/XWikiDocument.html
Says " XWikiAttachment | addAttachment(java.lang.String fileName, byte[]
data, XWikiContext context) "
Have I got type issue here or???
This is what I'm doing
def doc = xwiki.getDocument(docName, context); //use this for
com.xpn.xwiki.XWiki
def tmpElList = el.split("[\"]")
def umlImage = tmpElList[1]
def imgAsBites =
xwiki.getURLContentAsBytes("http://www.websequencediagrams.com/index.p…
"+umlImage, context);
def newAttachment = doc.addAttachment(filenameToSavaAs,imgAsBites,
context); //use this for com.xpn.xwiki.XWiki
saveAttachmentContent(newAttachment,context);
Has anyone had a similar problem?
Ajdin
-----Original Message-----
From: users-bounces(a)xwiki.org [mailto:users-bounces@xwiki.org] On Behalf
Of Sergiu Dumitriu
Sent: 14 January 2009 17:03
To: XWiki Users
Subject: Re: [xwiki-users] groovy.lang.MissingMethodException
Ajdin Brandic wrote:
Hi
I'm trying to execute another script on "Save" event. I've created a
notification class (based on xwiki example
http://dev.xwiki.org/xwiki/bin/view/Drafts/GroovyNotifications) and
pointed to it in "Administration > Programming > Notification pages".
This script gets called every time which is fine and when I try to
display name of a document that is being saved (doc.fullName) all
works well. document name it works fine but when I try to display one
of the fieldnames doc.display('Summary') I get
groovy.lang.MissingMethodException: No signature of method
com.xpn.xwiki.doc.XWikiDocument.display() is applicable for argument
types: (java.lang.String) values: {"Summary"}
I tried
def tmpDoc = context.getWiki().getDocument(doc.fullName, context);
But again fullName is OK but display('Summary') isn't
Am I missing something in my syntax? How do I make document values
available in my Notification class?
As you see, that is not an api object, but an internal class
(com.xpn.xwiki.doc.XWikiDocument vs. com.xpn.xwiki.api.Document). This
means that API methods don't work, unless they have an equivalent in the
other class.
You can either look at the methods of the XWikiDocument class, or get an
API object and work with it (new com.xpn.xwiki.apiDocument(tmpDoc)
--
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
--------------------------------------------------------
NOTICE
This message and any files transmitted with it is intended for the addressee only and may
contain information that is confidential or privileged. Unauthorised use is strictly
prohibited. If you are not the addressee, you should not read, copy, disclose or otherwise
use this message, except for the purpose of delivery to the addressee.
Any views or opinions expressed within this e-mail are those of the author and do not
necessarily represent those of Coventry University.