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.
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+Specif…
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