You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Peter Svensson <ps...@gmail.com> on 2008/01/21 15:41:10 UTC

How does one build Sling?

Hi, I'm attempting again to grok how to write a new version of
JsonItemWriter, et.c. But I think I need to download the whole thing,s ince
I only have a version of usling at the moment.
I've tried to look in the docs for a checkout and build process, but
couldn't find one.  COuld someone point me out to some info on this?

Thanks,

Cheers,
PS

Re: How does one build Sling?

Posted by Peter Svensson <ps...@gmail.com>.
OK. Thanks, I'll have to debug anyway, to see where the oddities lie. it
really should create an array :)

Cheers,
PS

On Jan 22, 2008 10:30 AM, Bertrand Delacretaz <bd...@apache.org>
wrote:

> On Jan 22, 2008 10:19 AM, Peter Svensson <ps...@gmail.com> wrote:
>
> > ...I wanted to look in the class "javax.jcr.Property",
> > because it defines if a property is multiple or not (leading to the
> > generation of an array)....
>
> Ok - in the case of Sling we're only dealing with the Property
> interface, which docs you can usually find on Google by searching for
> "JCR Property" which should lead you to
>
> http://www.day.com/maven/jsr170/javadocs/jcr-1.0/javax/jcr/Property.html
>
> -Bertrand
>

Re: How does one build Sling?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Jan 22, 2008 10:19 AM, Peter Svensson <ps...@gmail.com> wrote:

> ...I wanted to look in the class "javax.jcr.Property",
> because it defines if a property is multiple or not (leading to the
> generation of an array)....

Ok - in the case of Sling we're only dealing with the Property
interface, which docs you can usually find on Google by searching for
"JCR Property" which should lead you to

http://www.day.com/maven/jsr170/javadocs/jcr-1.0/javax/jcr/Property.html

-Bertrand

Re: How does one build Sling?

Posted by Peter Svensson <ps...@gmail.com>.
Thanks!

But hmm. Maybe not, but I wanted to look in the class "javax.jcr.Property",
because it defines if a property is multiple or not (leading to the
generation of an array). However, I think that one could implement that
oneself. It's just that I have been coding in js only for nearly half a
year, and it feels so hard to fire up Eclipse again and all the time
everything takes. I'm just very lazy :)  I'll do it, though. Just another
cup of coffee...

Cheers,
PS

On Jan 22, 2008 10:10 AM, Bertrand Delacretaz <bd...@apache.org>
wrote:

> Hi Peter,
>
> (replied to the JSON part in a renamed thread to separate matters)
>
> >... What I meant with not finding the source code to the JCR Property
> class was
> > that i did a grep . -exec "javax.jcr.Property" {} \;  -print   and every
> > file listed was one referering to it, not defining it, except for a jar
> > file, which came from the jcr project. So I kind of gave up on that
> point :)...
>
> Ah ok - I don't think you need the JCR Property source code, as the
> JSON format is completely generated by Sling.
>
> In microsling-core, that's
>
>
> ./src/main/java/org/apache/sling/microsling/helpers/json/JsonItemWriter.java
>
> ./src/main/java/org/apache/sling/microsling/slingservlets/renderers/JsonRendererServlet.java
>
> And in launchpad/launchpad-servlets that's
>
> ./src/main/java/org/apache/sling/launchpad/renderers/JsonItemWriter.java
>
> ./src/main/java/org/apache/sling/launchpad/renderers/JsonRendererServlet.java
>
> -Bertrand
>

Re: How does one build Sling?

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

(replied to the JSON part in a renamed thread to separate matters)

>... What I meant with not finding the source code to the JCR Property class was
> that i did a grep . -exec "javax.jcr.Property" {} \;  -print   and every
> file listed was one referering to it, not defining it, except for a jar
> file, which came from the jcr project. So I kind of gave up on that point :)...

Ah ok - I don't think you need the JCR Property source code, as the
JSON format is completely generated by Sling.

In microsling-core, that's

./src/main/java/org/apache/sling/microsling/helpers/json/JsonItemWriter.java
./src/main/java/org/apache/sling/microsling/slingservlets/renderers/JsonRendererServlet.java

And in launchpad/launchpad-servlets that's

./src/main/java/org/apache/sling/launchpad/renderers/JsonItemWriter.java
./src/main/java/org/apache/sling/launchpad/renderers/JsonRendererServlet.java

-Bertrand

Re: How does one build Sling?

Posted by Peter Svensson <ps...@gmail.com>.
Hi Bertrand,

The json that would be nice to have is something like this;

{
    label: 'name',
    identifier: 'name',
    items:
    [
        { name:'Fruit', type:'category'},
        { name:'Cinammon', type: 'category',
        children:
        [
        { name:'Cinammon Roll', type:'poptart' },
        { name:'Brown Sugar Cinnamon', type:'poptart' },
        { name:'French Toast', type:'poptart' }
        ]
        },
        { name:'Chocolate', type: 'category'}
    ]
}

Where the only important stuff here is that child nodes should be put in a
separate array [], not as an object  to the parent node, like this;

{
    "jcr:primaryType":"nt:unstructured",
    "testing":
           {"jcr:primaryType":"nt:unstructured",
        "test2":
                   {
"title":"test2","sling:resourceType":"usling/example","jcr:primaryType":"nt:unstructured","text":"Default
text of the test node"},
        "dojo_editor":
                   { "title":"dojo
editor","sling:resourceType":"usling/editor","jcr:primaryType":"nt:unstructured","text":"This
is the dojo 1.x editor" },
               "d1":
                   { "title":"d1","sling:resourceType":"<!DOCTYPE HTML
PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\r\n            \"
http://www.w3.org/TR/html4/strict.dtd\">\r\n<html>\r\n<head>\r\n<meta
http-equiv=\"Content-Type\" content=\"text/html;
charset=UTF-8\">\r\n<title>Editor Demo<\/title>\r\n    <style
type=\"text/css\">\r\n        @import \"
http://o.aolcdn.com/dojo/1.0.0/dijit/themes/tundra/tundra.css\";\r\n
@import \" http://o.aolcdn.com/dojo/1.0.0/dojo/resources/dojo.css\"\r\n
<\/style>\r\n    <script type=\"text/javascript\" src=\"
http://o.aolcdn.com/dojo/1.0.0/dojo/dojo.xd.js\ "\r\n
djConfig=\"parseOnLoad: true\"><\/script>\r\n        <script
type=\"text/javascript\">\r\n       dojo.require(\"dojo.parser\");\r\n
dojo.require(\" dijit.Editor\");\r\n     <\/script>\r\n<\/head>\r\n<body
class=\"tundra\">\r\n<form method=\"post\">\r\n<textarea name=\"field\"
width=\"200px\" dojoType=\" dijit.Editor\">\r\n        It was a dark and
stormy night.  Your story belongs here!\r\n<\/textarea>\r\n<input
type=\"submit\" value=\"Save\"
/>\r\n<\/form>\r\n<\/body>\r\n<\/html>","jcr:primaryType":"nt:unstructured","text":"dddd"
                   }
           }
    }


Also, I have difficulties understanding what to do with the

"testing":
           {"jcr:primaryType":"nt:unstructured",

part, since I would somehow like it to be like this;

children:
[
          {
                  title: 'testing',
                  jcr_primaryType: 'nt:unstructured',
                  children:
                  [
                              { title:"test2", sling_resourceType:
"usling/example", jcr_primaryType: "nt:unstructured", text: "Default text of
the test node"},
                               ....
                  ]
          }
]

Hmm. I really think that this would be the correct translation, now that
I've printed it out. The problem was in choosing how to remove the current
"name: {}" structure to move the name into the object (where it is anyway),
like children: [{title: name....}]

Note that children is just a convenient name, and doesn't mean anything
magic. Also, I would feel very much more comfortable not having quotes
around property names. I understand that they're there to escape the ':' ,
which are very magic in js and separates property names from values,
therefore I replaced them with underscores.

What I meant with not finding the source code to the JCR Property class was
that i did a grep . -exec "javax.jcr.Property" {} \;  -print   and every
file listed was one referering to it, not defining it, except for a jar
file, which came from the jcr project. So I kind of gave up on that point :)

Of course, another idea is to write a new JsonWriter from scratch. It can't
be too hard, and there's a lot of code done already.  I'll try the regexp on
client approach again, first though.

Cheers,
PS


On Jan 22, 2008 9:19 AM, Bertrand Delacretaz <bd...@apache.org> wrote:

> Hi Peter,
>
> On Jan 22, 2008 8:00 AM, Peter Svensson <ps...@gmail.com> wrote:
>
> > ...I did manage to checj out and build Sling alst night, and after a
> while
> > realized that the faulty json stuff is probably due to the fact that
> > javax.jcr.Property does not return tru when a property isMultiple(). Or
> has
> > the wrong ideas of what is multiple. That means that arrays never get
> > generates, but instead all herarchical json objects are just objects
> within
> > objects (which I prefer myself as well, but for some reason isn't
> > 'standard')....
>
> Could you given an example of what JSON you'd expect to get for a
> multivalued property?
>
> I don't think this is tested currently in the microsling-core or
> Launchpad tests, but I'll add it once we define what's needed.
>
> > ...But jcr isn't (of course) included in Sling only tha API jar, so now
> I have
> > to maybe checkout jcr as well and deal with those issues....
>
> Not sure what you mean - the Launchpad and microsling-core both use an
> embedded Jackrabbit repository, so it's all in there.
>
> > ..So, what I've done instead is gone back to the client side and try to
> cram
> > more regexp mojo, so that I can transalte it nearer to home. We'll see
> how
> > it goes....
>
> Ok fine - if you find a way to get what you need, we'll see how we can
> make this happen in Sling!
>
> -Bertrand
>

Re: How does one build Sling?

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

On Jan 22, 2008 8:00 AM, Peter Svensson <ps...@gmail.com> wrote:

> ...I did manage to checj out and build Sling alst night, and after a while
> realized that the faulty json stuff is probably due to the fact that
> javax.jcr.Property does not return tru when a property isMultiple(). Or has
> the wrong ideas of what is multiple. That means that arrays never get
> generates, but instead all herarchical json objects are just objects within
> objects (which I prefer myself as well, but for some reason isn't
> 'standard')....

Could you given an example of what JSON you'd expect to get for a
multivalued property?

I don't think this is tested currently in the microsling-core or
Launchpad tests, but I'll add it once we define what's needed.

> ...But jcr isn't (of course) included in Sling only tha API jar, so now I have
> to maybe checkout jcr as well and deal with those issues....

Not sure what you mean - the Launchpad and microsling-core both use an
embedded Jackrabbit repository, so it's all in there.

> ..So, what I've done instead is gone back to the client side and try to cram
> more regexp mojo, so that I can transalte it nearer to home. We'll see how
> it goes....

Ok fine - if you find a way to get what you need, we'll see how we can
make this happen in Sling!

-Bertrand

Re: How does one build Sling?

Posted by Peter Svensson <ps...@gmail.com>.
Thanks for you links. I must admit to being even more disoriented than that,
I'm afraid :)
I'm currently focusing on how to on either side convert the generated json
that describes a hierarchy of JCR nodes to be truly 'json' compliant, so
that I can just plug it in the Dojo Tree in bunkai.

But I haven't so much experience with specifics yet, so I know what it means
to have a Sling with or without Launchpad - i.e. what specific features does
it give.

I did manage to checj out and build Sling alst night, and after a while
realized that the faulty json stuff is probably due to the fact that
javax.jcr.Property does not return tru when a property isMultiple(). Or has
the wrong ideas of what is multiple. That means that arrays never get
generates, but instead all herarchical json objects are just objects within
objects (which I prefer myself as well, but for some reason isn't
'standard').

But jcr isn't (of course) included in Sling only tha API jar, so now I have
to maybe checkout jcr as well and deal with those issues.

So, what I've done instead is gone back to the client side and try to cram
more regexp mojo, so that I can transalte it nearer to home. We'll see how
it goes.

Cheers,
PS

On Jan 21, 2008 9:51 PM, Bertrand Delacretaz <bd...@apache.org> wrote:

> On Jan 21, 2008 6:14 PM, Peter Svensson <ps...@gmail.com> wrote:
> > ...Hmm. I should know by now what Launchpad does, but am I right in
> assuming
> > that that means that esp parsing while be disabled as well?...
>
> Not sure what you mean - the Launchpad works very similarly to
> microsling-core, but instead of being based on distinct code, it runs
> on the core Sling code.
>
> It is not finished, quite a few tests under [1] are disabled (search
> for TODO_FAILS_ in code for more details). So microsling-core is
> probably less risky to experiment with now, until [2] is marked
> resolved.
>
> -Bertrand
>
> [1]
> http://svn.apache.org/repos/asf/incubator/sling/trunk/launchpad/launchpad-webapp/
> [2] https://issues.apache.org/jira/browse/SLING-149
>

Re: How does one build Sling?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Jan 21, 2008 6:14 PM, Peter Svensson <ps...@gmail.com> wrote:
> ...Hmm. I should know by now what Launchpad does, but am I right in assuming
> that that means that esp parsing while be disabled as well?...

Not sure what you mean - the Launchpad works very similarly to
microsling-core, but instead of being based on distinct code, it runs
on the core Sling code.

It is not finished, quite a few tests under [1] are disabled (search
for TODO_FAILS_ in code for more details). So microsling-core is
probably less risky to experiment with now, until [2] is marked
resolved.

-Bertrand

[1] http://svn.apache.org/repos/asf/incubator/sling/trunk/launchpad/launchpad-webapp/
[2] https://issues.apache.org/jira/browse/SLING-149

Re: How does one build Sling?

Posted by Peter Svensson <ps...@gmail.com>.
Hmm. I should know by now what Launchpad does, but am I right in assuming
that that means that esp parsing while be disabled as well?

Cheers,
PS

On Jan 21, 2008 6:06 PM, Bertrand Delacretaz <bd...@apache.org> wrote:

> On Jan 21, 2008 3:55 PM, Bertrand Delacretaz <bd...@apache.org>
> wrote:
>
> > ...Checkout with an svn client from
> > http://svn.apache.org/repos/asf/incubator/sling/trunk/...
>
> Note that the launchpad stuff is broken in the current HEAD revision
> (see SLING-154), if you want to try it before we fix that please use
> revision 613894, i.e:
>
>  svn co -r 613894 http://svn.apache.org/repos/asf/incubator/sling/trunk/sling
>  cd sling
>  and then "mvn clean install" etc...
>
> -Bertrand
>

Re: How does one build Sling?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Jan 21, 2008 3:55 PM, Bertrand Delacretaz <bd...@apache.org> wrote:

> ...Checkout with an svn client from
> http://svn.apache.org/repos/asf/incubator/sling/trunk/...

Note that the launchpad stuff is broken in the current HEAD revision
(see SLING-154), if you want to try it before we fix that please use
revision 613894, i.e:

 svn co -r 613894 http://svn.apache.org/repos/asf/incubator/sling/trunk/ sling
 cd sling
 and then "mvn clean install" etc...

-Bertrand

Re: How does one build Sling?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Jan 21, 2008 3:41 PM, Peter Svensson <ps...@gmail.com> wrote:

> ...I've tried to look in the docs for a checkout and build process, but
> couldn't find one.  COuld someone point me out to some info on this?...

Install a Java 5 JVM and Maven (I use 2.0.7).

Checkout with an svn client from
http://svn.apache.org/repos/asf/incubator/sling/trunk/

Build with "mvn clean install" in trunk (the directory that contains
api, cache, commons, etc.).

See launchpad/launchpad-webapp/README.txt if you want to run the
launchpad (née µsling).

The first mvn build will be much slower than the next ones, as lots of
dependencies will be downloaded to your local Maven "cache".

That should be it!

-Bertrand