Re: [xwiki-users] Problem in Extension

2016-04-10 Thread Thomas Mortagne
On Fri, Apr 8, 2016 at 10:51 PM, Matthias Wegner  wrote:
> Hi Users,
>
> i programmed two years ago the Citation-Extension at
> https://github.com/matthiaw/xwiki-rendering-macro-citations.
>
> Now i found a bug in XWiki 8.x when i add on different pages the
> CitationClass-Object. There is a null-pointer-exception at Line 79, see
> https://github.com/matthiaw/xwiki-rendering-macro-citations/blob/master/xwiki-rendering-macro-citations/src/main/java/org/xwiki/rendering/citations/CitationClassBuilder.java#L79
>
> The Problem is that all Documents with the custom-object (doc in line 77)
> are found, but the method returns an empty null-list for nested documents.
>
> The Macro works when the Document with added XWiki.CitationClass-Objects is
> NOT nested. But when it is nested then the reference looks like
> Parent\.Child.WebHome. Is the Backlash the Problem? And when yes, where does
> it come from?

"Parent\.Child.WebHome" means space "Parent\.Child" and page "WebHome"
so it looks like the code that created the DocumentReference given to
buildComponents is wrong if its supported to be targeting page with
space "Parent", subspace "Child" and page "WebHome".

>From what I could find the issue is probably in
https://github.com/matthiaw/xwiki-rendering-macro-citations/blob/master/xwiki-rendering-macro-citations/src/main/java/org/xwiki/rendering/citations/CitationClassBuilder.java#L53
because doc.space meaning moved from unique space name in a wold were
there was only one level of space to space reference ("Parent.Child"
in your case). It would be much simpler to request doc.fullName
instead and use a "current "DocumentReferenceResolver to create the
DocumentReference for you (all that is compatible with 5.3). This is
indeed the main breaking change that was done when implementing nested
spaces.

Something like:

@Inject
@Named("current")
private DocumentReferenceResolver resolver;

@Override
public List getDocumentReferences() {
List references = new ArrayList();

try {
   Query query = queryManager.createQuery("SELECT doc.fullName
FROM Document doc, doc.object(" + Constants.SPACE + "." +
Citation.CLASS + "Class) AS obj", Query.XWQL);
List results = query.execute();
for (Object[] result : results) {
references.add(resolver.resolve((String) result[0]);
}
} catch (Exception e) {
e.printStackTrace();
}

return references;
}

See 
http://www.xwiki.org/xwiki/bin/view/ReleaseNotes/ReleaseNotesXWiki72#HSpaceReferenceinsteadofSpacename
for more details.

>
> You have any clue what i can do? Is that a bug or a mistake?

Unrelated note: Its not a good idea to depend on a SNAPSHOT version in
https://github.com/matthiaw/xwiki-rendering-macro-citations/blob/master/xwiki-rendering-macro-citations/pom.xml.
You should put 5.3 instead since right now it's impossible to build
your module (5.3-SNAPSHOT does not exist anymore).

>
> Regards,
> Matthias
>
>
>
> --
> View this message in context: 
> http://xwiki.475771.n2.nabble.com/Problem-in-Extension-tp7598895.html
> Sent from the XWiki- Users mailing list archive at Nabble.com.
> ___
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users



-- 
Thomas Mortagne
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] Problem in Extension

2016-04-08 Thread Matthias Wegner
Hi Users,

i programmed two years ago the Citation-Extension at
https://github.com/matthiaw/xwiki-rendering-macro-citations.

Now i found a bug in XWiki 8.x when i add on different pages the
CitationClass-Object. There is a null-pointer-exception at Line 79, see
https://github.com/matthiaw/xwiki-rendering-macro-citations/blob/master/xwiki-rendering-macro-citations/src/main/java/org/xwiki/rendering/citations/CitationClassBuilder.java#L79

The Problem is that all Documents with the custom-object (doc in line 77)
are found, but the method returns an empty null-list for nested documents.

The Macro works when the Document with added XWiki.CitationClass-Objects is
NOT nested. But when it is nested then the reference looks like
Parent\.Child.WebHome. Is the Backlash the Problem? And when yes, where does
it come from?

You have any clue what i can do? Is that a bug or a mistake?

Regards,
Matthias



--
View this message in context: 
http://xwiki.475771.n2.nabble.com/Problem-in-Extension-tp7598895.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users