Hi!
Thank you very much for answering me. The documentation and your
suggestions were really useful for me. I've created a component that
implements the XWikiModel interface and now the type of the Image is
DOCUMENT as I expected to be. The problem is , when I cast the Image to the
DocumentImage, the getDocumentName() method returns NULL, instead of the
real document name. Should I implement something else to get the real value?
Thank you for your help,
Cristina
On Fri, Aug 14, 2009 at 2:21 PM, Thomas Mortagne
<thomas.mortagne(a)xwiki.com>wrote;wrote:
On Fri, Aug 14, 2009 at 12:51, Vincent
Massol<vincent(a)massol.net> wrote:
On Aug 14, 2009, at 12:43 PM, Thomas Mortagne wrote:
Hi Cristina,
Unless you are in wiki mode you will always get URL.
To be in wiki mode you need to provide an implementation of WikiModel
component interface.
See
http://code.xwiki.org/xwiki/bin/view/Modules/RenderingModule (I've
just updated it).
The implementation of WikiModel is in xwiki-rendering-xwiki.
Actually i did not said to use it because the one in
xwiki-rendering-xwiki depends on a DocumentAccessBridge so it's easier
to implement just WikiMacro.
Thanks
-Vincent
> On Thu, Aug 13, 2009 at 19:08, Cristina Scheau<
scheau.cristina(a)gmail.com
> > wrote:
>> Hi everybody!
>>
>> Sorry for bother you again with my questions, but I have a problem
>> that
>> blocks me. I need to know what images are internal (they are
>> attached to
>> the current page or other XWiki page) in order to download them
>> with my
>> XMLRPC client. Using the rendering module I get every ImageBlock
>> [1] and I
>> check the ImageType[2] of every Image[3] object. My problem is that
>> this
>> type is URL for both external and internal images and that's why I
>> can't
>> cast to the DocumentImage class. I've pasted bellow my code and the
>> output
>> for some inputs. Can somebody tell me what I am wrong? Is there
>> any other
>> solution for getting the associated attachments?
>>
>> My client has these methods for getting the attachment data:
>>
>>
>> - Attachment<
http://confluence.atlassian.com/display/DOC/Remote+API+Specification#Remote…
>> >
>> getAttachment(String
>> token, String pageId, String fileName, String versionNumber) - get
>> information about an attachment.
>> - byte[] getAttachmentData(String token, String pageId, String
>> fileName,
>> String versionNumber) - get the contents of an attachment.
>> - byte[] getAttachmentData(Attachment attachment) - get the
>> contents of
>> an attachment.
>>
>>
>>
>> My code:
>>
>>
>> // Parse
>> Parser parser = ecm.lookup(Parser.class,
>> syntax.toIdString());
>> XDOM xdom = parser.parse(new StringReader(source));
>>
>> for (ImageBlock block :
>> xdom.getChildrenByType(ImageBlock.class,
>> true)) {
>> Image image = block.getImage();
>> System.out.println(image.getType() + "");
>> System.out.println(image.getName() + "");
>> }
>>
>>
>> Tests:
>> Input:
>> source: [[image:IMG3219.JPG]]
>>
>>
image:http://www.balsamiq.com/images/xwiki_logo.png
>> Syntax : XWIKI_2_0
>>
>> Output:
>>
>> URL
>> IMG3219.JPG
>> URL
>>
http://www.balsamiq.com/images/xwiki_logo.png
>>
>> Input:
>> source: <p><img src="IMG3219.JPG"
alt="IMG3219.JPG"/><br/><br/
>> ><img src="
>>
http://www.balsamiq.com/images/xwiki_logo.png"
>> class="wikimodel-freestanding" alt="
>>
http://www.balsamiq.com/images/xwiki_logo.png"/></p>
>> syntax: XHTML_1_0
>>
>> Output:
>> URL
>> IMG3219.JPG
>> URL
>>
http://www.balsamiq.com/images/xwiki_logo.png
>>
>>
>> Links:
>>
>> [1]
>>
http://svn.xwiki.org/svnroot/xwiki/platform/core/trunk/xwiki-rendering/xwik…
>> [2]
>>
http://svn.xwiki.org/svnroot/xwiki/platform/core/trunk/xwiki-rendering/xwik…
>> [3]
>>
http://svn.xwiki.org/svnroot/xwiki/platform/core/trunk/xwiki-rendering/xwik…
>
>
> Best regards,
> Cristina
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs
--
Thomas Mortagne
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs