You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by J Aaron Farr <fa...@apache.org> on 2009/10/29 03:16:22 UTC

how does initial-content work?

I'm trying to figure out loading initial-content from a bundle, but I'm
having a bit of trouble.

First, if I understand correctly, if I change files under my
initial-content directory and then reinstall the bundle, they *don't*
change in the repository, right?

Second, I was playing around with the espblog sample, to see if I
understand things correctly.  I added the following file:

   espblog/src/main/resources/initial-content/content/espblog/posts/first_post.json 

that looks like this:

    {
    "jcr:primaryType":"nt:unstructured",
    "posttext":"I'd like this post to be initial content.",
    "title":"First post"
    }

And when I deploy this bundle, the post is loaded where I expect:

   http://localhost:8080/content/espblog/posts/first_post.html

But, this URL no longer works:

   http://gandalf.local:8080/content/espblog/posts.list.html

and I believe that's because 'posts' is not a sling:Folder:

    Resource dumped by HtmlRendererServlet    
    Resource path: /content/espblog/posts
    Resource metadata: {sling.resolutionPath=/content/espblog/posts, sling.resolutionPathInfo=.list.html}
    Resource type: sling:Folder    
    Resource super type: -
    Resource properties   
    jcr:created: java.util.GregorianCalendar...
    jcr:primaryType: sling:Folder


So, if that's not the way to load the espblog with some initial blog
posts, what is?

-- 
   J. Aaron Farr
   馮傑仁
   www.cubiclemuses.com

Re: how does initial-content work?

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Aaron,

On Thu, Oct 29, 2009 at 3:16 AM, J Aaron Farr <fa...@apache.org> wrote:
> ...when I deploy this bundle, the post is loaded where I expect:
>
>   http://localhost:8080/content/espblog/posts/first_post.html
>
> But, this URL no longer works:
>
>   http://gandalf.local:8080/content/espblog/posts.list.html
>
> and I believe that's because 'posts' is not a sling:Folder:

For some reason the espblog sample seems to require the
nt:unstructured type for the "posts" node.

I haven't checked why, but to have that node type you can add a
posts.json file to your initial content alongside the posts folder,
samples/espblog/src/main/resources/initial-content/content/espblog/posts.json:

{
  "jcr:primaryType"="nt:unstructured"
}

in addition to your existing
samples/espblog/src/main/resources/initial-content/content/espblog/posts/first_post.json

This allows http://localhost:8888/content/espblog/posts.list.html to
work, but unfortunately the post is then missing the "created"
property that should be a date, and I don't think the initial content
mechanism allows for initializing date properties (unless you use
docview xml files for the initial content).

To really fix this, the espblog sample could be made to cope with
missing "created" properties, or we could improve the initial content
loader to better handle date properties.

-Bertrand

Re: how does initial-content work?

Posted by Vidar Ramdal <vi...@idium.no>.
On Thu, Oct 29, 2009 at 9:53 AM, J Aaron Farr <fa...@apache.org> wrote:

>>> [...]
>>> and I believe that's because 'posts' is not a sling:Folder:
>>
>> That shouldn't be relevant, as long as you did install the Path based
>> RTP bundle, which uses elements of the path (not the nt:primaryType or
>> sling:resourceType) to provide a resource type.
>> Check your web console (http://localhost:8080/system/console) for
>> "Apache Sling Sample Path Based Resource Type Provider". Is it there?
>
> Yep.

I'm unable to reproduce your problem, but I'm thinking you may be
victim of SLING-1163 [1].
Could you check http://localhost:8080/system/console/components, and
see if any components are listed as 'unsatisfied'?
If so, restarting the bundle called 'Apache Sling Dynamic Class Loader
Support' might help.

[1] https://issues.apache.org/jira/browse/SLING-1163

-- 
Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
Sommerrogata 13-15, N-0255 Oslo, Norway
+ 47 22 00 84 00 / +47 21 531941, ext 2070

Re: how does initial-content work?

Posted by J Aaron Farr <fa...@apache.org>.
On Thu 29 Oct 2009 04:48, Vidar Ramdal <vi...@idium.no> wrote:
>
> Just in case: The server in your first url is localhost:8080, the
> second is gandalf.local:8080 ...

Issue from copying.  The local computer is named gandalf, so it doesn't
matter.

>> and I believe that's because 'posts' is not a sling:Folder:
>
> That shouldn't be relevant, as long as you did install the Path based
> RTP bundle, which uses elements of the path (not the nt:primaryType or
> sling:resourceType) to provide a resource type.
> Check your web console (http://localhost:8080/system/console) for
> "Apache Sling Sample Path Based Resource Type Provider". Is it there?

Yep.

-- 
   J. Aaron Farr
   馮傑仁
   www.cubiclemuses.com

Re: how does initial-content work?

Posted by Vidar Ramdal <vi...@idium.no>.
On Thu, Oct 29, 2009 at 3:16 AM, J Aaron Farr <fa...@apache.org> wrote:
>
> I'm trying to figure out loading initial-content from a bundle, but I'm
> having a bit of trouble.
>
> First, if I understand correctly, if I change files under my
> initial-content directory and then reinstall the bundle, they *don't*
> change in the repository, right?
>
> Second, I was playing around with the espblog sample, to see if I
> understand things correctly.  I added the following file:
>
>   espblog/src/main/resources/initial-content/content/espblog/posts/first_post.json
>
> that looks like this:
>
>    {
>    "jcr:primaryType":"nt:unstructured",
>    "posttext":"I'd like this post to be initial content.",
>    "title":"First post"
>    }
>
> And when I deploy this bundle, the post is loaded where I expect:
>
>   http://localhost:8080/content/espblog/posts/first_post.html
>
> But, this URL no longer works:
>
>   http://gandalf.local:8080/content/espblog/posts.list.html

Just in case: The server in your first url is localhost:8080, the
second is gandalf.local:8080 ...

> and I believe that's because 'posts' is not a sling:Folder:

That shouldn't be relevant, as long as you did install the Path based
RTP bundle, which uses elements of the path (not the nt:primaryType or
sling:resourceType) to provide a resource type.
Check your web console (http://localhost:8080/system/console) for
"Apache Sling Sample Path Based Resource Type Provider". Is it there?

-- 
Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
Sommerrogata 13-15, N-0255 Oslo, Norway
+ 47 22 00 84 00 / +47 21 531941, ext 2070

Re: how does initial-content work?

Posted by Christophe Lombart <ch...@gmail.com>.
Hello

2009/10/29 J Aaron Farr <fa...@apache.org>:
>
> I'm trying to figure out loading initial-content from a bundle, but I'm
> having a bit of trouble.
>
> First, if I understand correctly, if I change files under my
> initial-content directory and then reinstall the bundle, they *don't*
> change in the repository, right?
>

No, you can reloaded the content when you reinstall the bundle.
for exemple, you can add in your bundle pom.xml :

<Sling-Initial-Content>
		SLING-INF/initial-content;path:=/content/myfolder;overwrite:=true;uninstall:=true
</Sling-Initial-Content>

You have other options for the initial-content.
see on the page :
http://sling.apache.org/site/content-loading-jcrcontentloader.html



> Second, I was playing around with the espblog sample, to see if I
> understand things correctly.  I added the following file:
>
>   espblog/src/main/resources/initial-content/content/espblog/posts/first_post.json
>
> that looks like this:
>
>    {
>    "jcr:primaryType":"nt:unstructured",
>    "posttext":"I'd like this post to be initial content.",
>    "title":"First post"
>    }
>
> And when I deploy this bundle, the post is loaded where I expect:
>
>   http://localhost:8080/content/espblog/posts/first_post.html
>
> But, this URL no longer works:
>
>   http://gandalf.local:8080/content/espblog/posts.list.html
>
> and I believe that's because 'posts' is not a sling:Folder:
>
>    Resource dumped by HtmlRendererServlet
>    Resource path: /content/espblog/posts
>    Resource metadata: {sling.resolutionPath=/content/espblog/posts, sling.resolutionPathInfo=.list.html}
>    Resource type: sling:Folder
>    Resource super type: -
>    Resource properties
>    jcr:created: java.util.GregorianCalendar...
>    jcr:primaryType: sling:Folder
>
>
> So, if that's not the way to load the espblog with some initial blog
> posts, what is?
>

Sorry, I never used this application but your content loading seems to be good.
If needed, you can also initialize the properties for the "posts" node.
Maybe, someone else can help ?


Christophe

> --
>   J. Aaron Farr
>   馮傑仁
>   www.cubiclemuses.com
>