Export & Import After Changed WebAppPath

#1

I have an XWiki 11.1 installation below tomcat_ home\webapps\xwiki on a Windows10 desktop A and a freshly set up XWiki 11.1 installation below tomcat_home\webapps\marvin on another Windows10 desktop B. On B I’ve set xwiki.webapppath=marvin in xwiki.cfg. I exported the content of XWiki on A and imported it to the XWiki on B. Now on B the attachments are stored below permanent_directory/store/file/xwiki, but it seems that XWikiDocument.loadAttachements() expects the attachments below permanent_directory/store/file/marvin:

Caused by: com.xpn.xwiki.XWikiException: Error number 3002 in 3: The attachment [C:\kido\app\.marvin\store\file\marvin\1\5\eeb8a5779ea416f517621bd9244ab5\attachments\7\b\a19dd46704ef89490bd295809139b6\f.png] could not be found in the filesystem attachment store.
	at org.xwiki.store.legacy.store.internal.FilesystemAttachmentStore.loadAttachmentContent(FilesystemAttachmentStore.java:214)
	at com.xpn.xwiki.doc.XWikiAttachment.loadAttachmentContent(XWikiAttachment.java:1073)
	at com.xpn.xwiki.doc.XWikiDocument.loadAttachments(XWikiDocument.java:4217)
	at de.deka.marvin.internal.Archiver.archiveEntity(Archiver.java:239)
	at de.deka.marvin.internal.Archiver.archive(Archiver.java:149)
	... 168 more

Did I miss to configure a relevant property?

0 Likes

#2

Hi @Kido

you mean by using Administration -> export / import, or did you perform it another way?

0 Likes

#3

I use a groovy script, which looks something like

    DocumentInstanceInputProperties iProps = new DocumentInstanceInputProperties()
    iProps.setEntities(entities)
    iProps.setVerbose(true)
    iProps.setWithJRCSRevisions(false)
    iProps.setWithRevisions(false)
    Map oProps = [
            packageBackupPack: Boolean.TRUE
    ]
    String filename = Util.encodeURI("Robo.${now}.xar", xcontext.getContext())
    XWikiServletResponse response = xcontext.getResponse()
    response.setContentType("application/zip")
    response.setHeader("Content-disposition", "attachment; filename=${filename}")
    oProps["target"] = response.getOutputStream()
    Job job = services.filter.instance.startExport(FilterStreamType.XWIKI_XAR_CURRENT, oProps, iProps)
    job.join()
0 Likes

#4

BTW that’s a cool script! Would be awesome if you could share it on https://snippets.xwiki.org :slight_smile:

0 Likes

#5

And you don’t have any issue if you add a new attachment, or you got the same error? It feels like a bug on our side, but it should behave the same way for newly added attachment and imported ones.

0 Likes

#6

No, no problems. The point is: On import the attachement is stored as

C:\kido\app\.marvin\store\file\xwiki\1\5\eeb8a5779ea416f517621bd9244ab5\attachments\7\b\a19dd46704ef89490bd295809139b6\f.png

and that’s fine so far. I can, e.g., view the attached image. But when my script calls loadAttachements() the attachement is assumed to be stored as

C:\kido\app\.marvin\store\file\marvin\1\5\eeb8a5779ea416f517621bd9244ab5\attachments\7\b\a19dd46704ef89490bd295809139b6\f.png

So it’s just the new WebAppPath that causes the problem somehow. Would be great if you could provide an educated guess, what could be wrong. If you cannot, I’ll set up a small test case…

0 Likes

#7

See Export Selected Pages/Spaces

0 Likes

#8

Nice, thanks!

0 Likes

#9

The difference between those two paths is the name of the wiki. Looks like the first one is stored in the wiki xwiki (the main wiki) and the second one in the wiki marvin.

0 Likes

#10

Yes, that’s what I tried to say: I changed the wepapppath from xwiki to marvin and now the attachements are looked for in the wrong place or imported to the wrong place. I do not know.

0 Likes

#11

The change here have nothing to do with the webpath (from attachment point of view at least). It’s the id of the subwiki where the attachment is supposed to be stored, looks like the attachment is searched in wiki marvin instead of wiki xwiki. Maybe the URL you are using makes XWiki identify it as the wrong wiki (could be a bug in the URL parser used for the /download/ action).

Could you paste the complete error with all the caused by.

By the way make sure you properly set xwiki.webapppath property in xwiki.cfg. You don’t seems to mention it in previous messages.

0 Likes

#12

I did in my very first message.

0 Likes

#13

Indeed I missed it, then it’s something else.

0 Likes

#14

My fault: I wrongly took the webapppath to provide the name for the main wiki, but the name of the main wiki seems to be hard-wired to “xwiki”.

0 Likes

#15

It’s actually possible to change it but I wouldn’t recommend doing so: https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-tools/xwiki-platform-tool-configuration-resources/src/main/resources/xwiki.cfg.vm#L157

0 Likes