You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Edgar Poce <ed...@gmail.com> on 2007/09/21 16:00:53 UTC
how does the default content mapping work?
Hi,
I'm running Sling and I'm trying to access the repository's root
node from the browser with the following url: http://localhost:8080.
According to http://wiki.apache.org/jackrabbit/ApacheSling/SlingGuideDefaultMappings
the default component must resolve the request if there's no custom
mapping, however I'm getting "404 not found".
the wiki says "If no mapping exists for the given node, an exception
is thrown and the request fails." and bellow it says "In such a case
of missing content mapping, a default Content mapping is defined in
the form of the org.apache.sling.content.jcr.DefaultContent class".
I'm not sure whether the expected behavior is to fail with a 404 error
or to process the request with the default component. Any idea?
thanks in advance,
Edgar
Re: how does the default content mapping work?
Posted by Felix Meschberger <fm...@gmail.com>.
Hi Edgar,
I just have attached a patch proposal to your issue, which implements my
opinion that the object returned should be the one I request (or an
extension thereof or nothing, if it is not possible to load the node
with the requested class).
I have to admit, that I do not understand this strategy stuff to the
depth :-)
Regards
Felix
Am Freitag, den 21.09.2007, 12:17 -0300 schrieb Edgar Poce:
> Hi Felix,
>
> thanks for your help, It seems that jcr-mapping tries to get a new
> ClassDescriptor by calling
> classDescriptor.getDescendantClassDescriptor(nodeType) instead of
> using the descriptor which maps to the given class.
>
> It seems this problem is related to the inheritance strategy. I tried
> to dive into the ocm but I couldn't understand how it works.
>
> Apparently, given that DefaultContent declares an interface
> (org.apache.sling.component.Content) it uses
> NODETYPE_PER_CONCRETECLASS[1], and for mappings with this strategy if
> the node's nodetype is not the same than the from classdescriptor's
> nodetype (null for DefaultContent) jcr-mapping tries to get the
> descendant descriptor (which is null for DefaultContent)[2] and
> jcr-mapping fails with NPE.
>
> [1] see ClassDescriptor.lookupInheritanceSettings()
> [2] see ObjectConverterImpl.getObject(Session session, Class clazz,
> String path) line 349
>
> br,
> Edgar
>
> On 9/21/07, Felix Meschberger <fm...@gmail.com> wrote:
> > Hi Edgar,
> >
> > It seems that this issue is probably related to your issue JCR-1142 you
> > reported to Jackrabbit. It seems actually, that OCM tries to resolve the
> > actual node against another class descriptor (again) without checking
> > whether such a descriptor really exists.
> >
> > IMHO this is not really correct, because when calling the
> > getObject(Session, Class, String) method I expect the object returned to
> > be at least assignement compatible to the class I have submitted.
> >
> > I will try to find a solution to that problem together with Christophe.
> >
> > Regards
> > Felix
> >
> > Am Freitag, den 21.09.2007, 11:00 -0300 schrieb Edgar Poce:
> > > Hi,
> > >
> > > I'm running Sling and I'm trying to access the repository's root
> > > node from the browser with the following url: http://localhost:8080.
> > > According to http://wiki.apache.org/jackrabbit/ApacheSling/SlingGuideDefaultMappings
> > > the default component must resolve the request if there's no custom
> > > mapping, however I'm getting "404 not found".
> > >
> > > the wiki says "If no mapping exists for the given node, an exception
> > > is thrown and the request fails." and bellow it says "In such a case
> > > of missing content mapping, a default Content mapping is defined in
> > > the form of the org.apache.sling.content.jcr.DefaultContent class".
> > > I'm not sure whether the expected behavior is to fail with a 404 error
> > > or to process the request with the default component. Any idea?
> > >
> > > thanks in advance,
> > > Edgar
> >
> >
Re: how does the default content mapping work?
Posted by Edgar Poce <ed...@gmail.com>.
Yes, I've just tried it and it works!
thanks,
edgar
On 9/21/07, Felix Meschberger <fm...@gmail.com> wrote:
> Hi,
>
> It seems, that applying the fix I attached to JCR-1142 does do the
> trick :-)
>
> Regards
> Felix
>
> Am Freitag, den 21.09.2007, 12:17 -0300 schrieb Edgar Poce:
> > Hi Felix,
> >
> > thanks for your help, It seems that jcr-mapping tries to get a new
> > ClassDescriptor by calling
> > classDescriptor.getDescendantClassDescriptor(nodeType) instead of
> > using the descriptor which maps to the given class.
> >
> > It seems this problem is related to the inheritance strategy. I tried
> > to dive into the ocm but I couldn't understand how it works.
> >
> > Apparently, given that DefaultContent declares an interface
> > (org.apache.sling.component.Content) it uses
> > NODETYPE_PER_CONCRETECLASS[1], and for mappings with this strategy if
> > the node's nodetype is not the same than the from classdescriptor's
> > nodetype (null for DefaultContent) jcr-mapping tries to get the
> > descendant descriptor (which is null for DefaultContent)[2] and
> > jcr-mapping fails with NPE.
> >
> > [1] see ClassDescriptor.lookupInheritanceSettings()
> > [2] see ObjectConverterImpl.getObject(Session session, Class clazz,
> > String path) line 349
> >
> > br,
> > Edgar
> >
> > On 9/21/07, Felix Meschberger <fm...@gmail.com> wrote:
> > > Hi Edgar,
> > >
> > > It seems that this issue is probably related to your issue JCR-1142 you
> > > reported to Jackrabbit. It seems actually, that OCM tries to resolve the
> > > actual node against another class descriptor (again) without checking
> > > whether such a descriptor really exists.
> > >
> > > IMHO this is not really correct, because when calling the
> > > getObject(Session, Class, String) method I expect the object returned to
> > > be at least assignement compatible to the class I have submitted.
> > >
> > > I will try to find a solution to that problem together with Christophe.
> > >
> > > Regards
> > > Felix
> > >
> > > Am Freitag, den 21.09.2007, 11:00 -0300 schrieb Edgar Poce:
> > > > Hi,
> > > >
> > > > I'm running Sling and I'm trying to access the repository's root
> > > > node from the browser with the following url: http://localhost:8080.
> > > > According to http://wiki.apache.org/jackrabbit/ApacheSling/SlingGuideDefaultMappings
> > > > the default component must resolve the request if there's no custom
> > > > mapping, however I'm getting "404 not found".
> > > >
> > > > the wiki says "If no mapping exists for the given node, an exception
> > > > is thrown and the request fails." and bellow it says "In such a case
> > > > of missing content mapping, a default Content mapping is defined in
> > > > the form of the org.apache.sling.content.jcr.DefaultContent class".
> > > > I'm not sure whether the expected behavior is to fail with a 404 error
> > > > or to process the request with the default component. Any idea?
> > > >
> > > > thanks in advance,
> > > > Edgar
> > >
> > >
>
>
Re: how does the default content mapping work?
Posted by Felix Meschberger <fm...@gmail.com>.
Hi,
It seems, that applying the fix I attached to JCR-1142 does do the
trick :-)
Regards
Felix
Am Freitag, den 21.09.2007, 12:17 -0300 schrieb Edgar Poce:
> Hi Felix,
>
> thanks for your help, It seems that jcr-mapping tries to get a new
> ClassDescriptor by calling
> classDescriptor.getDescendantClassDescriptor(nodeType) instead of
> using the descriptor which maps to the given class.
>
> It seems this problem is related to the inheritance strategy. I tried
> to dive into the ocm but I couldn't understand how it works.
>
> Apparently, given that DefaultContent declares an interface
> (org.apache.sling.component.Content) it uses
> NODETYPE_PER_CONCRETECLASS[1], and for mappings with this strategy if
> the node's nodetype is not the same than the from classdescriptor's
> nodetype (null for DefaultContent) jcr-mapping tries to get the
> descendant descriptor (which is null for DefaultContent)[2] and
> jcr-mapping fails with NPE.
>
> [1] see ClassDescriptor.lookupInheritanceSettings()
> [2] see ObjectConverterImpl.getObject(Session session, Class clazz,
> String path) line 349
>
> br,
> Edgar
>
> On 9/21/07, Felix Meschberger <fm...@gmail.com> wrote:
> > Hi Edgar,
> >
> > It seems that this issue is probably related to your issue JCR-1142 you
> > reported to Jackrabbit. It seems actually, that OCM tries to resolve the
> > actual node against another class descriptor (again) without checking
> > whether such a descriptor really exists.
> >
> > IMHO this is not really correct, because when calling the
> > getObject(Session, Class, String) method I expect the object returned to
> > be at least assignement compatible to the class I have submitted.
> >
> > I will try to find a solution to that problem together with Christophe.
> >
> > Regards
> > Felix
> >
> > Am Freitag, den 21.09.2007, 11:00 -0300 schrieb Edgar Poce:
> > > Hi,
> > >
> > > I'm running Sling and I'm trying to access the repository's root
> > > node from the browser with the following url: http://localhost:8080.
> > > According to http://wiki.apache.org/jackrabbit/ApacheSling/SlingGuideDefaultMappings
> > > the default component must resolve the request if there's no custom
> > > mapping, however I'm getting "404 not found".
> > >
> > > the wiki says "If no mapping exists for the given node, an exception
> > > is thrown and the request fails." and bellow it says "In such a case
> > > of missing content mapping, a default Content mapping is defined in
> > > the form of the org.apache.sling.content.jcr.DefaultContent class".
> > > I'm not sure whether the expected behavior is to fail with a 404 error
> > > or to process the request with the default component. Any idea?
> > >
> > > thanks in advance,
> > > Edgar
> >
> >
Re: how does the default content mapping work?
Posted by Edgar Poce <ed...@gmail.com>.
Hi Felix,
thanks for your help, It seems that jcr-mapping tries to get a new
ClassDescriptor by calling
classDescriptor.getDescendantClassDescriptor(nodeType) instead of
using the descriptor which maps to the given class.
It seems this problem is related to the inheritance strategy. I tried
to dive into the ocm but I couldn't understand how it works.
Apparently, given that DefaultContent declares an interface
(org.apache.sling.component.Content) it uses
NODETYPE_PER_CONCRETECLASS[1], and for mappings with this strategy if
the node's nodetype is not the same than the from classdescriptor's
nodetype (null for DefaultContent) jcr-mapping tries to get the
descendant descriptor (which is null for DefaultContent)[2] and
jcr-mapping fails with NPE.
[1] see ClassDescriptor.lookupInheritanceSettings()
[2] see ObjectConverterImpl.getObject(Session session, Class clazz,
String path) line 349
br,
Edgar
On 9/21/07, Felix Meschberger <fm...@gmail.com> wrote:
> Hi Edgar,
>
> It seems that this issue is probably related to your issue JCR-1142 you
> reported to Jackrabbit. It seems actually, that OCM tries to resolve the
> actual node against another class descriptor (again) without checking
> whether such a descriptor really exists.
>
> IMHO this is not really correct, because when calling the
> getObject(Session, Class, String) method I expect the object returned to
> be at least assignement compatible to the class I have submitted.
>
> I will try to find a solution to that problem together with Christophe.
>
> Regards
> Felix
>
> Am Freitag, den 21.09.2007, 11:00 -0300 schrieb Edgar Poce:
> > Hi,
> >
> > I'm running Sling and I'm trying to access the repository's root
> > node from the browser with the following url: http://localhost:8080.
> > According to http://wiki.apache.org/jackrabbit/ApacheSling/SlingGuideDefaultMappings
> > the default component must resolve the request if there's no custom
> > mapping, however I'm getting "404 not found".
> >
> > the wiki says "If no mapping exists for the given node, an exception
> > is thrown and the request fails." and bellow it says "In such a case
> > of missing content mapping, a default Content mapping is defined in
> > the form of the org.apache.sling.content.jcr.DefaultContent class".
> > I'm not sure whether the expected behavior is to fail with a 404 error
> > or to process the request with the default component. Any idea?
> >
> > thanks in advance,
> > Edgar
>
>
Re: how does the default content mapping work?
Posted by Felix Meschberger <fm...@gmail.com>.
Hi Edgar,
It seems that this issue is probably related to your issue JCR-1142 you
reported to Jackrabbit. It seems actually, that OCM tries to resolve the
actual node against another class descriptor (again) without checking
whether such a descriptor really exists.
IMHO this is not really correct, because when calling the
getObject(Session, Class, String) method I expect the object returned to
be at least assignement compatible to the class I have submitted.
I will try to find a solution to that problem together with Christophe.
Regards
Felix
Am Freitag, den 21.09.2007, 11:00 -0300 schrieb Edgar Poce:
> Hi,
>
> I'm running Sling and I'm trying to access the repository's root
> node from the browser with the following url: http://localhost:8080.
> According to http://wiki.apache.org/jackrabbit/ApacheSling/SlingGuideDefaultMappings
> the default component must resolve the request if there's no custom
> mapping, however I'm getting "404 not found".
>
> the wiki says "If no mapping exists for the given node, an exception
> is thrown and the request fails." and bellow it says "In such a case
> of missing content mapping, a default Content mapping is defined in
> the form of the org.apache.sling.content.jcr.DefaultContent class".
> I'm not sure whether the expected behavior is to fail with a 404 error
> or to process the request with the default component. Any idea?
>
> thanks in advance,
> Edgar