You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Daniel, de la Cuesta Navarrete" <cu...@gmail.com> on 2009/03/16 18:31:31 UTC

Problem with jcr:created property in initial content loading

 Hi,

I am loading custom initial-content in the repository using a json file

This is  my json:

{
  "jcr:primaryType" : "nt:unstructured",
  "sling:resourceType" : "mycompany/content",
  "jcr:created" : "",
  "jcr:createdBy" : "",
  "jcr:lastModified" : "",
  "jcr:lastModifiedBy" : ""
}

It is strange because all properties are created except the jcr:created,

I always get a 404 (Resource not found) error when I try to acces this
property

Any idea?

Re: Problem with jcr:created property in initial content loading

Posted by Alexander Klimetschek <ak...@day.com>.
2009/3/19 Juan José Vázquez Delgado <ju...@gmail.com>
>
> > We want to use these reserved properties (jcr:created, jcr:createdBy, etc.)
> > because they are autocompleted by the SlingPostServlet and we are always to
> > create content using the SlingPostServlet.
> >
> > How can initalize the jcr:created with a long in a json?
>
> I don´t know why but "jcr:created" is ignored by "JsonReader" [1].
> Anyone knows the reason?
>
> [1] http://svn.apache.org/repos/asf/incubator/sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/JsonReader.java

jcr:created is autocreated and protected by the JCR implementation, at
least for all cases where it is used by built-in nodetypes such as
nt:file and nt:folder (see
http://www.day.com/specs/jcr/1.0/6.7.22.5_nt_hierarchyNode.html).
That's why you would get an error when you try to set it.

One could improve the JsonReader to check for the property definition
(ie. if the property to set is protected) before setting it but I
think the better solution is to not use jcr:created in custom
applications.

Regards,
Alex

--
Alexander Klimetschek
alexander.klimetschek@day.com

Re: Problem with jcr:created property in initial content loading

Posted by Juan José Vázquez Delgado <ju...@gmail.com>.
> We want to use these reserved properties (jcr:created, jcr:createdBy, etc.)
> because they are autocompleted by the SlingPostServlet and we are always to
> create content using the SlingPostServlet.
>
> How can initalize the jcr:created with a long in a json?

I don´t know why but "jcr:created" is ignored by "JsonReader" [1].
Anyone knows the reason?

[1] http://svn.apache.org/repos/asf/incubator/sling/trunk/bundles/jcr/contentloader/src/main/java/org/apache/sling/jcr/contentloader/internal/readers/JsonReader.java

Re: Problem with jcr:created property in initial content loading

Posted by "Daniel, de la Cuesta Navarrete" <cu...@gmail.com>.
We want to use these reserved properties (jcr:created, jcr:createdBy, etc.)
because they are autocompleted by the SlingPostServlet and we are always to
create content using the SlingPostServlet.

How can initalize the jcr:created with a long in a json?

thank you.



El 17 de marzo de 2009 12:19, Juan José Vázquez Delgado <
juanjo.vazquez@gmail.com> escribió:

> Hi Daniel,
>
> > The property isn't there
> >
> > ** Resource dumped by StreamRendererServlet**
> > Resource path:/content/mycontent
> > Resource metadata: {sling.resolutionPathInfo=,
> > sling.resolutionPath=/content/mycontent}
> >
> > ** Resource properties **
> > title: My content title
> > size:
> > sling:resourceType: gad/mycontent
> > jcr:primaryType: nt:unstructured
> > cr:lastModifiedBy:
> > jcr:createdBy:
> > jcr:lastModified:
> >
> > But the other properties (lastModified, lastModifiedBy and createdBy) are
> > there.
>
> The problem is that "jcr:" properties are connected  to his own
> nodetype. I mean, "jcr:created" is connected to "nt:hierarchyNode" [1]
> and the other ones are connected to "nt:resource" [2]. In the other
> hand, "jcr:created" and "jcr:lastModified" are dates, so you must
> initialize them with a long (milliseconds).
>
> If you want keep on using unstructured nodes yo are free to choose
> another name for the properties. Another option would be defining your
> own custom nodetype inheriting "nt:file" for instance. Have a look to
> this [3].
>
> Regards,
>
> Juanjo.
>
> [1] http://wiki.apache.org/jackrabbit/nt%3ahierarchyNode
> [2] http://wiki.apache.org/jackrabbit/nt%3aresource
> [3]
> http://svn.apache.org/repos/asf/incubator/sling/trunk/bundles/jcr/resource/src/main/resources/SLING-INF/nodetypes
>

Re: Problem with jcr:created property in initial content loading

Posted by Juan José Vázquez Delgado <ju...@gmail.com>.
Hi Daniel,

> The property isn't there
>
> ** Resource dumped by StreamRendererServlet**
> Resource path:/content/mycontent
> Resource metadata: {sling.resolutionPathInfo=,
> sling.resolutionPath=/content/mycontent}
>
> ** Resource properties **
> title: My content title
> size:
> sling:resourceType: gad/mycontent
> jcr:primaryType: nt:unstructured
> cr:lastModifiedBy:
> jcr:createdBy:
> jcr:lastModified:
>
> But the other properties (lastModified, lastModifiedBy and createdBy) are
> there.

The problem is that "jcr:" properties are connected  to his own
nodetype. I mean, "jcr:created" is connected to "nt:hierarchyNode" [1]
and the other ones are connected to "nt:resource" [2]. In the other
hand, "jcr:created" and "jcr:lastModified" are dates, so you must
initialize them with a long (milliseconds).

If you want keep on using unstructured nodes yo are free to choose
another name for the properties. Another option would be defining your
own custom nodetype inheriting "nt:file" for instance. Have a look to
this [3].

Regards,

Juanjo.

[1] http://wiki.apache.org/jackrabbit/nt%3ahierarchyNode
[2] http://wiki.apache.org/jackrabbit/nt%3aresource
[3] http://svn.apache.org/repos/asf/incubator/sling/trunk/bundles/jcr/resource/src/main/resources/SLING-INF/nodetypes

Re: Problem with jcr:created property in initial content loading

Posted by "Daniel, de la Cuesta Navarrete" <cu...@gmail.com>.
El 16 de marzo de 2009 20:17, Juan José Vázquez Delgado <
juanjo.vazquez@gmail.com> escribió:

> > For example, thorugh the browser:
> > http.//localhost:8888/content/mycontent/jcr:created
>
> What do you get when try this?:
>
> http.//localhost:8888/content/mycontent.txt


The property isn't there

** Resource dumped by StreamRendererServlet**
Resource path:/content/mycontent
Resource metadata: {sling.resolutionPathInfo=,
sling.resolutionPath=/content/mycontent}

** Resource properties **
title: My content title
size:
sling:resourceType: gad/mycontent
jcr:primaryType: nt:unstructured
cr:lastModifiedBy:
jcr:createdBy:
jcr:lastModified:


But the other properties (lastModified, lastModifiedBy and createdBy) are
there.

>
>
> In the other hand, have you any error in Sling log?


There is an error log,

16.03.2009 18:43:32.127 *INFO* [127.0.0.1 [1237225412124] GET
/mycontent/jcr:created HTTP/1.1]
org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResource
setMetaData: Problem extracting metadata information for /content/mycontent/
javax.jcr.ValueFormatException: conversion to long failed: For input string:
"": For input string: ""

It is strange because the property jcr:lastModified is similar to
jcr:created and doesn't cause any error.


>
>
> BR,
>
> Juanjo.
>

Re: Problem with jcr:created property in initial content loading

Posted by Juan José Vázquez Delgado <ju...@gmail.com>.
> For example, thorugh the browser:
> http.//localhost:8888/content/mycontent/jcr:created

What do you get when try this?:

http.//localhost:8888/content/mycontent.txt

In the other hand, have you any error in Sling log?

BR,

Juanjo.

Re: Problem with jcr:created property in initial content loading

Posted by "Daniel, de la Cuesta Navarrete" <cu...@gmail.com>.
El 16 de marzo de 2009 19:07, Juan José Vázquez Delgado <
juanjo.vazquez@gmail.com> escribió:

> Hi Daniel,
>
> >  Hi,
> >
> > I am loading custom initial-content in the repository using a json file
> >
> > This is  my json:
> >
> > {
> >  "jcr:primaryType" : "nt:unstructured",
> >  "sling:resourceType" : "mycompany/content",
> >  "jcr:created" : "",
> >  "jcr:createdBy" : "",
> >  "jcr:lastModified" : "",
> >  "jcr:lastModifiedBy" : ""
> > }
> >
> > It is strange because all properties are created except the jcr:created,
>
> If I understand you properly, you create an initial resource with that
> properties but "jcr:created" is not initialized, is that correct?.


Yes,  the property is not initialized.

>
>
> > I always get a 404 (Resource not found) error when I try to acces this
> > property
> >
> > Any idea?
>
> What do you mean with "when I try to acces this property"?. How are
> you trying to access to the property?


For example, thorugh the browser:
http.//localhost:8888/content/mycontent/jcr:created

or through the jcr api in a JSP



>
> Regards,
>
> Juanjo.
>

Re: Problem with jcr:created property in initial content loading

Posted by Juan José Vázquez Delgado <ju...@gmail.com>.
Hi Daniel,

>  Hi,
>
> I am loading custom initial-content in the repository using a json file
>
> This is  my json:
>
> {
>  "jcr:primaryType" : "nt:unstructured",
>  "sling:resourceType" : "mycompany/content",
>  "jcr:created" : "",
>  "jcr:createdBy" : "",
>  "jcr:lastModified" : "",
>  "jcr:lastModifiedBy" : ""
> }
>
> It is strange because all properties are created except the jcr:created,

If I understand you properly, you create an initial resource with that
properties but "jcr:created" is not initialized, is that correct?.

> I always get a 404 (Resource not found) error when I try to acces this
> property
>
> Any idea?

What do you mean with "when I try to acces this property"?. How are
you trying to access to the property?

Regards,

Juanjo.