You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Bruce Edge <br...@nextissuemedia.com> on 2014/11/09 02:04:55 UTC

new sling project noob design questions.

I've committed to a sling/oak stack for a new project because of the object model, wealth of infrastructure, and, well, the price. I'm a bit lost as to where to start, so here's a list of questions on my plate. I'd appreciate any pointers, suggestions, RTFM links etc.
I'm still working my way through the sling docs, but I wanted to throw this out at the same time to possibly save some time going down unproductive paths.

I'm migrating a app that had a sping (roo) based hibernate/jpa persistence back-end. This provided a simple POJO persistence framework. While these object were not the primary reason for using a JCR, it does seem superfluous to hold onto this back-end when the JCR provides similar functionality.
What's the equivalent mechanism in sling for persisting a hierarchy of POJOs?
Similarly, editing such POJOs. The current app uses a JavaScript app to navigate the tree and read/write objects. Sling adds a lot more functionality to the basic servlet container so I'm wondering what client-side frameworks take advantage of this, and is there anything OOTB that provides simple but extensible CRUD functionality?

Where can I find information on the conventions regarding the JCR structure? Some resources indicate content belongs in a JCR_ROOT named /content, but I"m not sure if this is a convention or what the standard internal mapping for the JCR is.

The real reason for this is we have a lot of media files that need to be stored in a hierarchy and referenced by the above POJOs. One of the initial tasks is to create an import mechanism that unpacks a zip and extracts it into the JCR at a particular node path. What's the accepted convention for ingesting bulk data?
One thought I had was to create a new OSGI bundle that exposed a REST API that would accept POSTed content and associated metadata.
Another was to watch a WebDAV drop folder and create an event handler to ingest any files dropped into that folder.

Then there's the issue of users, permissions, change auditing, etc.
Is there an existing mechanism for connecting to an LDAP server?
I'd like to expose all content via WebDAV and allow authenticated users to modify it and track the changes by user, similar to a source control, but with no branching.
What is needed to track user edits, and create change records for edits made by specific users, to a specific tree hierarchy of content, or by other sort criteria?

Content browsing
Aside from WebDAV, are there any standard modules to present a web view of hierarchical content that consists of media files (pdf, text, image, audio, video, html, etc) ?
Do any of these provide any change control functionality, like viewing change history, locking, viewing previous versions etc?

Thanks in advance.

-Bruce

Re: new sling project noob design questions.

Posted by Sandro Boehme <sa...@gmx.de>.
Hi,

>> Similarly, editing such POJOs. The current app uses a JavaScript app to navigate the tree
>> and read/write objects. Sling adds a lot more functionality to the basic servlet container so
>> I'm wondering what client-side frameworks take advantage of this...
>
> Backbone.js comes to mind but I also haven't used it myself
> (infrastructure guy here ;-)
>
> I had some interesting discussions with Sandro Boehme about this at
> adaptTo, where he mentioned the Sling Content Editor that he recently
> contributed could serve as a basis for simple extensible CRUD
> operations. I've long thought that using the Sling resourceType
> mechanism to select or generate editing models would be nice, so maybe
> that's an appropriate extension to that editor.

I second that the Sling Resource Editor (aka/former Sling Content 
Editor) takes advantage of the Sling Get- and POSTServlet for the CRUD 
functionality. It uses the JSTree library for rendering and manipulating 
the node tree. If you have a similar need you may want to have a look at 
that library as well. If it's possible we could even collaborate on the 
Sling Resource Editor to read/write the tree.

To extend to what Bertrand wrote:
I would like to use the Sling resource type (or the node type) as a 
domain/class marker to enhance / change a nodes possible actions, styles 
and property pages. E.g. if you have a node with a node type of 
"sling:folder" it could have a specific style and not a generic 'add 
node' icon but an 'add folder' icon instead and a property page where 
you can drop a list of files.
But first I need to finish the generic actions for the Resource Editor 
before I can work on a domain/class specific API. :-)

Best,

Sandro

Re: new sling project noob design questions.

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

On Sun, Nov 9, 2014 at 2:04 AM, Bruce Edge
<br...@nextissuemedia.com> wrote:
> ...What's the equivalent mechanism in sling for persisting a hierarchy of POJOs?...

I'd say Sling Models, though I haven't used them myself much so far.
You might want to ask more specific questions if you try them.

Some object-to-JCR mapping libraries have been created but we don't
recommend using them, see http://markmail.org/message/wmqggzrxwxearmyh
for discussions.

> Similarly, editing such POJOs. The current app uses a JavaScript app to navigate the tree
> and read/write objects. Sling adds a lot more functionality to the basic servlet container so
> I'm wondering what client-side frameworks take advantage of this...

Backbone.js comes to mind but I also haven't used it myself
(infrastructure guy here ;-)

I had some interesting discussions with Sandro Boehme about this at
adaptTo, where he mentioned the Sling Content Editor that he recently
contributed could serve as a basis for simple extensible CRUD
operations. I've long thought that using the Sling resourceType
mechanism to select or generate editing models would be nice, so maybe
that's an appropriate extension to that editor.

>
> Where can I find information on the conventions regarding the JCR structure? Some resources indicate
> content belongs in a JCR_ROOT named /content, but I"m not sure if this is a convention or what
> the standard internal mapping for the JCR is....

That's just a convention - there's some guidance at
http://wiki.apache.org/jackrabbit/DavidsModel and I have a
presentation on typical content models at
http://www.slideshare.net/bdelacretaz/a-jcr-view-of-the-world-everything-is-content-everything-is-a-tree
(video at http://vimeo.com/44298693) - JCR doesn't force anything here
which is good and bad as you need to find you way, in general starting
with "how would I do that in a filesystem" is a good idea.

Finding out about what granularity to use was one of my big hurdles
when starting with JCR, but once you've done a few content models that
should be much easier and the benefits of getting a good model are
huge, so feel free to discuss your suggested content models here!

>
> ...The real reason for this is we have a lot of media files that need to be stored in a
> hierarchy and referenced by the above POJOs. One of the initial tasks is to create an
> import mechanism that unpacks a zip and extracts it into the JCR at a particular node path.
> What's the accepted convention for ingesting bulk data?...

You might create a custom POST servlet that gets the zip stream,
unpacks it (ideally streaming) and creates the corresponding nodes. Or
if it's relatively small zips, copy them in an "incoming" folder in
the repository via WebDAV or PUT requests and use observation to
detect and process them. Which is the two options that you suggested
;-)

> ...Then there's the issue of users, permissions, change auditing, etc.
> Is there an existing mechanism for connecting to an LDAP server?...

Sling delegates this to the JCR repository, I'm not sure if there are
out-of-the box LDAP modules for Jackrabbit or Oak but that would be
the places to look at.

> ...What is needed to track user edits, and create change records for edits made by specific users,
> to a specific tree hierarchy of content, or by other sort criteria?...

You can use observation to watch that tree and create audit content.

Hope this helps,
-Bertrand

Re: new sling project noob design questions.

Posted by Sandro Boehme <sa...@gmx.de>.
Hi Bruce,

> Content browsing
> Aside from WebDAV, are there any standard modules to present a web view of hierarchical content that consists of media files (pdf, text, image, audio, video, html, etc) ?
> Do any of these provide any change control functionality, like viewing change history, locking, viewing previous versions etc?
For content browsing you can either use the preinstalled Sling Explorer 
that you find at /.explorer.html of your Sling installation or you can 
install the Resource Editor [1]. To do the latter you have to:
o navigate to "OSGi"==>"OSGi Repository"
o add http://www.jcrbrowser.org/sling/obr/repository.xml to the list of 
the repositories
o refresh the page after the new repository appears
o navigate to "Apache Sling Resource Editor" and deploy and start it
Enjoy!

[1] - 
http://svn.apache.org/viewvc/sling/trunk/contrib/explorers/resourceeditor/

Best,
Sandro