Hi Guillaume, Thank you a lot, that really helps! The only thing is which library I should import :
1. org.xwiki.model.reference 2. org.wiki.rendering.wikimodel Moreover, there is a place to find how this "reference-game" works? I mean that I've found Entity References, Document References, SpaceReferecens, Wiki References but I don't understand how this works. Thank you, Giordano 2016-01-12 17:05 GMT+01:00 Guillaume "Louis-Marie" Delhumeau < [email protected]>: > Hi Giordano. > > Is it possible for you to modify your method to have a list of spaces > instead of the space name? Or better: having a DocumentReference as input? > > If not, it means that you need to parse your "wikiSpace" input, get the > list of spaces from it, and then create a clean DocumentReference. > > You should use a SpaceReferenceResolver to get a clean space reference. > > Example: > > @Inject > @Named("current") > private SpaceReferenceResolver<String> spaceReferenceResolver; > > public void myMethod(String wikiName, String wikiSpace, String wikiPage) { > // resolve the spaces: > SpaceReference spaceRef = spaceReferenceResolver.resolve(wikiSpace, new > WikiReference(wikiName)); > // Create a clean DocumentReference: > DocumentReference docRef = new DocumentReference(wikiPage, spaceRef); > // Work with the docRef > XWikiDocument doc = xwiki.getDocument(docRef, xcontext); > // ... > } > > Similar code in Groovy: > > {{groovy}} > def spaceReferenceResolver = > > services.component.getInstance(org.xwiki.model.reference.SpaceReferenceResolver.TYPE_STRING, > "current"); > def spaceRef = spaceReferenceResolver.resolve("AB.CD\\.E.F", new > org.xwiki.model.reference.WikiReference('hello')); > def docRef = new org.xwiki.model.reference.DocumentReference('page', > spaceRef); > {{/groovy}} > > I hope it helps, > Guillaume > > > 2016-01-12 16:27 GMT+01:00 Giordano Ninonà <[email protected]>: > > > Hi users, > > > > I have a problem with my Java component. I have a hjava method wich take > as > > input 3 strings: wikiName, wikiSpace and the wiki page to retrieve the > doc, > > thus the content and perform modification. > > > > Ok, when I try to delete a terminal page inside a nested page, there is > no > > problem, the component retrieve the page's document and can delete it, it > > works! > > > > But when I want to delete a terminal page that is inside a nested page > > which is inside another nested page it stops working. The point is that I > > can't retrieve the terminal page's document, probably because of the > > wikiSpace variable. > > I have tried "NestedPage1.NestedPage2" but it is not woking at all, it is > > keep creating and successively deleting new documents(thus pages). > > > > Thank you, > > Giordano. > > _______________________________________________ > > users mailing list > > [email protected] > > http://lists.xwiki.org/mailman/listinfo/users > > > > > > -- > Guillaume Delhumeau ([email protected]) > Research & Development Engineer at XWiki SAS > Committer on the XWiki.org project > _______________________________________________ > users mailing list > [email protected] > http://lists.xwiki.org/mailman/listinfo/users > _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
