You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Guillaume Lucazeau <gl...@gmail.com> on 2015/11/13 14:01:18 UTC

Resource class vs CND

Hello,

I'm currently studying Sling for a project, to store "documents" containing
pages, and components (image, text, maps, graphs etc.)

While it seems to fit our needs perfectly, I'm a bit struggling to learn
some basic stuff before presenting a POC to our team.

My first question would be: on what criteria should I choose to manage my
resources using a class extending AbstractResource or a nodetype definition
in a CND file? Do you have advice on it? I'm tending to use a class to keep
everything in Java, but I'm wondering if it's more/less/equally flexible,
and if it has drawbacks or benefits compared to a CND file.

Thank you for every information you could give me

Regards,
Guillaume

RE: Resource class vs CND

Posted by Olaf <ol...@x100.de>.
Hi Jason,

That sounds interesting! Would you mind providing a bit more detail as to why you would advise against it?

Regards,
Olaf

-----Original Message-----
From: Jason Bailey [mailto:Jason.Bailey@sas.com] 
Sent: Montag, 16. November 2015 17:04
To: users@sling.apache.org
Subject: RE: Resource class vs CND

After spending 6 months working with AEM and MongoDB. I would be hesitant to recommend it as a solution.

-----Original Message-----
From: Olaf [mailto:olaf@x100.de]
Sent: Monday, November 16, 2015 10:49 AM
To: users@sling.apache.org
Subject: RE: Resource class vs CND

Hi Guillaume,

That does sound like use cases well suitable for Sling. I would indeed not opt for custom node types (yet), as simply using sling:resourceType is flexible and allows quickly changing the content structure.

Indeed, authentication should not be an issue as well. Even it here was no out of the box support for OpenID, the Sling authentication framework (https://sling.apache.org/documentation/the-sling-engine/authentication/authentication-framework.html) is quite extensible. 

Letting users add data to content (such as comments) is also straightforward - in principle, an authorized user or system can add or alter any content with just a simple POST request (https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html).

Regarding queries, you can search for anything in the repository, including any property, so that should be absolutely no issue. 

Do you intend to store the entire repo in an Oracle DB? IMHO, MongoDB would be a much better fit for the JCR technology and also has better support in that regard, as Adobe AEM  - being one of the leading Sling users - is using it for enterprise deployments.

Finally, here are some pointers to Sling sample applications which may be handy:

https://github.com/nateyolles/publick-sling-blog
https://github.com/dplaton/sightly-blog-sample
https://github.com/unic/publication-javamagazin-sling (my own, still based on Sling 7)


Regards,
Olaf



-----Original Message-----
From: Guillaume Lucazeau [mailto:glucazeau@gmail.com]
Sent: Montag, 16. November 2015 16:09
To: users@sling.apache.org
Subject: Re: Resource class vs CND

Thank you Olaf for your answer.

I have currently little information about the app. What I know is that it will mostly manage documents, organized like this:
- network (a dozen)
-- documents: around 1,500
--- pages: around 15,000 (total)
---- components (graphs, map, picture etc.): 1 to 4 per page, total around
70,000

Adding to this, they want to provide questionnaires and then manage answers. Also make pages and/or component commentable (I was thinking about a mixin to manage that(?)). They want to export those comments periodically (maybe a custom JCR query would be useful here? I have to look if you can query over sling:resourceType or if you can only query jcr:primaryType) We would also have to store content in an Oracle database, which is possible I think with Jackrabbit.

Identification is made through Gmail, I've seen there is an OpenID module even though it seems to be a little bit out-dated. There is currently around 500 users planned.

One of the question I will have to ask them is about what seems to be a
requirements: have skeleton of documents with changes propagated to every document instances (for instance, moving a certain page type to a different position than its current). I don't see how we could do that with the JCR tree.

While I don't know much yet about Sling and the application we have to develop, I have the feeling that Sling is flexible and adapted to this, and could be reusable. I'm just a little afraid of the learning curve, because the documentation and even your answers sometimes seem very abstract and I don't have yet the knowledge to see how we could use it properly. But it still seems more appropriate than a custom database architecture.

Once again, thank you all for your help.


On Fri, Nov 13, 2015 at 10:08 PM, Olaf <ol...@x100.de> wrote:

> Hi Guillaume,
>
> There is no direct relationship between these models and the sling 
> resource type. You can look at these models as views on arbitrary 
> resources. Indeed, you can obtain an instance of a model by adapting 
> to it from an arbitrary resource, for instance:
>
> Resource documentResource =
> resourceResolver.getResource("/path/to/document");
> Document document = documentResource.adaptTo(Document.class)
>
> Note, however, that these models are read-only, i.e. there is 
> currently no support to persist them*.
>
> However, whether you require structured data (specific node types) or 
> unstructured data, sling models or anything else really depends on you 
> use cases. For many cases, storing the data with suitable 
> sling:resourceTypes and rendering it on demand (e.g. using Sightly) is completely sufficient.
>
> Sling differs from other web frameworks in that it does not restrict 
> you to one specific way in which to deal with things, but offers a 
> very vast amount of options. In other words: What is your use case?
> For instance, what is the semantic structure of your data, who shall 
> be using it and what for, how does it change / update, what data volume do you expect etc.
> Following, I'd then look at how these semantics are best expressed in 
> a RESTful architectural style (which is the core concept of Sling).
>
> I'd address the implementation details last, since - contrary to many 
> other web frameworks - those do not dominate the solution design.
>
> Regards,
> Olaf
>
> * Okay, there is JCR OCM, but it's dated / requires some additional work:
> http://www.connectcon.ch/2015/en/speakers/katarzyna-kozlowska.html
>
>
> -----Original Message-----
> From: Guillaume Lucazeau [mailto:glucazeau@gmail.com]
> Sent: Freitag, 13. November 2015 16:10
> To: users@sling.apache.org
> Subject: Re: Resource class vs CND
>
> Thank you for your advice
>
> I got rid of my CND file and created content using sling:resourceType. 
> I had the idea that defining my node structure somewhere would allow 
> me to create form dynamically to add subnodes.
>
> So I've created two classes:
> // Document.java
> @Model(adaptables=Resource.class)
> public class Document {
>
>   @Inject @Named("jcr:title")
>   private String title;
>
>   @Inject
>   private List<Resource> pages;
> }
>
> // Page.java
> @Model(adaptables=Resource.class)
> public class Page {
>
>   @Inject @Named("jcr:title")
>   private String title;
>
>   @Inject
>   private List<Resource> components;
> }
>
> But I don't see how to map them to a sling:resourceType. Is it with
> getResourceType() like in here:
>
> https://svn.apache.org/repos/asf/sling/trunk/launchpad/test-services/s
> rc/main/java/org/apache/sling/launchpad/testservices/resourceprovider/
> PlanetResource.java
> ?
>
> Sling definitely has its own rhythm to it and I'm slow to pick it up
> :)
>
>
>
> On Fri, Nov 13, 2015 at 2:48 PM, Daniel Klco <da...@gmail.com>
> wrote:
>
> > Agreed, I would also highly suggest looking at Sling Models as an 
> > option to make your code more strongly typed without requiring a 
> > rigid node type
> > structure:
> > https://sling.apache.org/documentation/bundles/models.html
> >
> > On Fri, Nov 13, 2015 at 8:37 AM, Jason Bailey <Ja...@sas.com>
> > wrote:
> >
> > > My opinions:
> > >
> > > Sling is really about being able to take a data set and present 
> > > that data in multiple ways. For the vast majority of use cases you 
> > > should use the existing node types and property values and you 
> > > don't need to
> use a CND.
> > >
> > > A custom nodetype is useful if there is a need to perform some 
> > > explicit searching over a large set of data or if you absolutely 
> > > require
> > limitations
> > > on properties that the existing nodetypes don't help with.
> > >
> > > Avoid trying to think of it in terms of other frameworks; Sling 
> > > has its own rhythm to it. You have a request that identifies a 
> > > resource and then that data is handed off to a renderer.  Using as 
> > > much out of the box functionality will give you the greatest flexibility.
> > >
> > >
> > > -Jason
> > >
> > > -----Original Message-----
> > > From: Guillaume Lucazeau [mailto:glucazeau@gmail.com]
> > > Sent: Friday, November 13, 2015 8:01 AM
> > > To: users@sling.apache.org
> > > Subject: Resource class vs CND
> > >
> > > Hello,
> > >
> > > I'm currently studying Sling for a project, to store "documents"
> > > containing pages, and components (image, text, maps, graphs etc.)
> > >
> > > While it seems to fit our needs perfectly, I'm a bit struggling to 
> > > learn some basic stuff before presenting a POC to our team.
> > >
> > > My first question would be: on what criteria should I choose to 
> > > manage my resources using a class extending AbstractResource or a 
> > > nodetype
> > definition
> > > in a CND file? Do you have advice on it? I'm tending to use a 
> > > class to
> > keep
> > > everything in Java, but I'm wondering if it's more/less/equally 
> > > flexible, and if it has drawbacks or benefits compared to a CND file.
> > >
> > > Thank you for every information you could give me
> > >
> > > Regards,
> > > Guillaume
> > >
> >
>
>



RE: Resource class vs CND

Posted by Jason Bailey <Ja...@sas.com>.
After spending 6 months working with AEM and MongoDB. I would be hesitant to recommend it as a solution.

-----Original Message-----
From: Olaf [mailto:olaf@x100.de] 
Sent: Monday, November 16, 2015 10:49 AM
To: users@sling.apache.org
Subject: RE: Resource class vs CND

Hi Guillaume,

That does sound like use cases well suitable for Sling. I would indeed not opt for custom node types (yet), as simply using sling:resourceType is flexible and allows quickly changing the content structure.

Indeed, authentication should not be an issue as well. Even it here was no out of the box support for OpenID, the Sling authentication framework (https://sling.apache.org/documentation/the-sling-engine/authentication/authentication-framework.html) is quite extensible. 

Letting users add data to content (such as comments) is also straightforward - in principle, an authorized user or system can add or alter any content with just a simple POST request (https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html).

Regarding queries, you can search for anything in the repository, including any property, so that should be absolutely no issue. 

Do you intend to store the entire repo in an Oracle DB? IMHO, MongoDB would be a much better fit for the JCR technology and also has better support in that regard, as Adobe AEM  - being one of the leading Sling users - is using it for enterprise deployments.

Finally, here are some pointers to Sling sample applications which may be handy:

https://github.com/nateyolles/publick-sling-blog
https://github.com/dplaton/sightly-blog-sample
https://github.com/unic/publication-javamagazin-sling (my own, still based on Sling 7)


Regards,
Olaf



-----Original Message-----
From: Guillaume Lucazeau [mailto:glucazeau@gmail.com]
Sent: Montag, 16. November 2015 16:09
To: users@sling.apache.org
Subject: Re: Resource class vs CND

Thank you Olaf for your answer.

I have currently little information about the app. What I know is that it will mostly manage documents, organized like this:
- network (a dozen)
-- documents: around 1,500
--- pages: around 15,000 (total)
---- components (graphs, map, picture etc.): 1 to 4 per page, total around
70,000

Adding to this, they want to provide questionnaires and then manage answers. Also make pages and/or component commentable (I was thinking about a mixin to manage that(?)). They want to export those comments periodically (maybe a custom JCR query would be useful here? I have to look if you can query over sling:resourceType or if you can only query jcr:primaryType) We would also have to store content in an Oracle database, which is possible I think with Jackrabbit.

Identification is made through Gmail, I've seen there is an OpenID module even though it seems to be a little bit out-dated. There is currently around 500 users planned.

One of the question I will have to ask them is about what seems to be a
requirements: have skeleton of documents with changes propagated to every document instances (for instance, moving a certain page type to a different position than its current). I don't see how we could do that with the JCR tree.

While I don't know much yet about Sling and the application we have to develop, I have the feeling that Sling is flexible and adapted to this, and could be reusable. I'm just a little afraid of the learning curve, because the documentation and even your answers sometimes seem very abstract and I don't have yet the knowledge to see how we could use it properly. But it still seems more appropriate than a custom database architecture.

Once again, thank you all for your help.


On Fri, Nov 13, 2015 at 10:08 PM, Olaf <ol...@x100.de> wrote:

> Hi Guillaume,
>
> There is no direct relationship between these models and the sling 
> resource type. You can look at these models as views on arbitrary 
> resources. Indeed, you can obtain an instance of a model by adapting 
> to it from an arbitrary resource, for instance:
>
> Resource documentResource =
> resourceResolver.getResource("/path/to/document");
> Document document = documentResource.adaptTo(Document.class)
>
> Note, however, that these models are read-only, i.e. there is 
> currently no support to persist them*.
>
> However, whether you require structured data (specific node types) or 
> unstructured data, sling models or anything else really depends on you 
> use cases. For many cases, storing the data with suitable 
> sling:resourceTypes and rendering it on demand (e.g. using Sightly) is completely sufficient.
>
> Sling differs from other web frameworks in that it does not restrict 
> you to one specific way in which to deal with things, but offers a 
> very vast amount of options. In other words: What is your use case?
> For instance, what is the semantic structure of your data, who shall 
> be using it and what for, how does it change / update, what data volume do you expect etc.
> Following, I'd then look at how these semantics are best expressed in 
> a RESTful architectural style (which is the core concept of Sling).
>
> I'd address the implementation details last, since - contrary to many 
> other web frameworks - those do not dominate the solution design.
>
> Regards,
> Olaf
>
> * Okay, there is JCR OCM, but it's dated / requires some additional work:
> http://www.connectcon.ch/2015/en/speakers/katarzyna-kozlowska.html
>
>
> -----Original Message-----
> From: Guillaume Lucazeau [mailto:glucazeau@gmail.com]
> Sent: Freitag, 13. November 2015 16:10
> To: users@sling.apache.org
> Subject: Re: Resource class vs CND
>
> Thank you for your advice
>
> I got rid of my CND file and created content using sling:resourceType. 
> I had the idea that defining my node structure somewhere would allow 
> me to create form dynamically to add subnodes.
>
> So I've created two classes:
> // Document.java
> @Model(adaptables=Resource.class)
> public class Document {
>
>   @Inject @Named("jcr:title")
>   private String title;
>
>   @Inject
>   private List<Resource> pages;
> }
>
> // Page.java
> @Model(adaptables=Resource.class)
> public class Page {
>
>   @Inject @Named("jcr:title")
>   private String title;
>
>   @Inject
>   private List<Resource> components;
> }
>
> But I don't see how to map them to a sling:resourceType. Is it with
> getResourceType() like in here:
>
> https://svn.apache.org/repos/asf/sling/trunk/launchpad/test-services/s
> rc/main/java/org/apache/sling/launchpad/testservices/resourceprovider/
> PlanetResource.java
> ?
>
> Sling definitely has its own rhythm to it and I'm slow to pick it up
> :)
>
>
>
> On Fri, Nov 13, 2015 at 2:48 PM, Daniel Klco <da...@gmail.com>
> wrote:
>
> > Agreed, I would also highly suggest looking at Sling Models as an 
> > option to make your code more strongly typed without requiring a 
> > rigid node type
> > structure:
> > https://sling.apache.org/documentation/bundles/models.html
> >
> > On Fri, Nov 13, 2015 at 8:37 AM, Jason Bailey <Ja...@sas.com>
> > wrote:
> >
> > > My opinions:
> > >
> > > Sling is really about being able to take a data set and present 
> > > that data in multiple ways. For the vast majority of use cases you 
> > > should use the existing node types and property values and you 
> > > don't need to
> use a CND.
> > >
> > > A custom nodetype is useful if there is a need to perform some 
> > > explicit searching over a large set of data or if you absolutely 
> > > require
> > limitations
> > > on properties that the existing nodetypes don't help with.
> > >
> > > Avoid trying to think of it in terms of other frameworks; Sling 
> > > has its own rhythm to it. You have a request that identifies a 
> > > resource and then that data is handed off to a renderer.  Using as 
> > > much out of the box functionality will give you the greatest flexibility.
> > >
> > >
> > > -Jason
> > >
> > > -----Original Message-----
> > > From: Guillaume Lucazeau [mailto:glucazeau@gmail.com]
> > > Sent: Friday, November 13, 2015 8:01 AM
> > > To: users@sling.apache.org
> > > Subject: Resource class vs CND
> > >
> > > Hello,
> > >
> > > I'm currently studying Sling for a project, to store "documents"
> > > containing pages, and components (image, text, maps, graphs etc.)
> > >
> > > While it seems to fit our needs perfectly, I'm a bit struggling to 
> > > learn some basic stuff before presenting a POC to our team.
> > >
> > > My first question would be: on what criteria should I choose to 
> > > manage my resources using a class extending AbstractResource or a 
> > > nodetype
> > definition
> > > in a CND file? Do you have advice on it? I'm tending to use a 
> > > class to
> > keep
> > > everything in Java, but I'm wondering if it's more/less/equally 
> > > flexible, and if it has drawbacks or benefits compared to a CND file.
> > >
> > > Thank you for every information you could give me
> > >
> > > Regards,
> > > Guillaume
> > >
> >
>
>


RE: Resource class vs CND

Posted by Olaf <ol...@x100.de>.
Hi Guillaume,

That does sound like use cases well suitable for Sling. I would indeed not opt for custom node types (yet), as simply using sling:resourceType is flexible and allows quickly changing the content structure.

Indeed, authentication should not be an issue as well. Even it here was no out of the box support for OpenID, the Sling authentication framework (https://sling.apache.org/documentation/the-sling-engine/authentication/authentication-framework.html) is quite extensible. 

Letting users add data to content (such as comments) is also straightforward - in principle, an authorized user or system can add or alter any content with just a simple POST request (https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html).

Regarding queries, you can search for anything in the repository, including any property, so that should be absolutely no issue. 

Do you intend to store the entire repo in an Oracle DB? IMHO, MongoDB would be a much better fit for the JCR technology and also has better support in that regard, as Adobe AEM  - being one of the leading Sling users - is using it for enterprise deployments.

Finally, here are some pointers to Sling sample applications which may be handy:

https://github.com/nateyolles/publick-sling-blog
https://github.com/dplaton/sightly-blog-sample
https://github.com/unic/publication-javamagazin-sling (my own, still based on Sling 7)


Regards,
Olaf



-----Original Message-----
From: Guillaume Lucazeau [mailto:glucazeau@gmail.com] 
Sent: Montag, 16. November 2015 16:09
To: users@sling.apache.org
Subject: Re: Resource class vs CND

Thank you Olaf for your answer.

I have currently little information about the app. What I know is that it will mostly manage documents, organized like this:
- network (a dozen)
-- documents: around 1,500
--- pages: around 15,000 (total)
---- components (graphs, map, picture etc.): 1 to 4 per page, total around
70,000

Adding to this, they want to provide questionnaires and then manage answers. Also make pages and/or component commentable (I was thinking about a mixin to manage that(?)). They want to export those comments periodically (maybe a custom JCR query would be useful here? I have to look if you can query over sling:resourceType or if you can only query jcr:primaryType) We would also have to store content in an Oracle database, which is possible I think with Jackrabbit.

Identification is made through Gmail, I've seen there is an OpenID module even though it seems to be a little bit out-dated. There is currently around 500 users planned.

One of the question I will have to ask them is about what seems to be a
requirements: have skeleton of documents with changes propagated to every document instances (for instance, moving a certain page type to a different position than its current). I don't see how we could do that with the JCR tree.

While I don't know much yet about Sling and the application we have to develop, I have the feeling that Sling is flexible and adapted to this, and could be reusable. I'm just a little afraid of the learning curve, because the documentation and even your answers sometimes seem very abstract and I don't have yet the knowledge to see how we could use it properly. But it still seems more appropriate than a custom database architecture.

Once again, thank you all for your help.


On Fri, Nov 13, 2015 at 10:08 PM, Olaf <ol...@x100.de> wrote:

> Hi Guillaume,
>
> There is no direct relationship between these models and the sling 
> resource type. You can look at these models as views on arbitrary 
> resources. Indeed, you can obtain an instance of a model by adapting 
> to it from an arbitrary resource, for instance:
>
> Resource documentResource =
> resourceResolver.getResource("/path/to/document");
> Document document = documentResource.adaptTo(Document.class)
>
> Note, however, that these models are read-only, i.e. there is 
> currently no support to persist them*.
>
> However, whether you require structured data (specific node types) or 
> unstructured data, sling models or anything else really depends on you 
> use cases. For many cases, storing the data with suitable 
> sling:resourceTypes and rendering it on demand (e.g. using Sightly) is completely sufficient.
>
> Sling differs from other web frameworks in that it does not restrict 
> you to one specific way in which to deal with things, but offers a 
> very vast amount of options. In other words: What is your use case? 
> For instance, what is the semantic structure of your data, who shall 
> be using it and what for, how does it change / update, what data volume do you expect etc.
> Following, I'd then look at how these semantics are best expressed in 
> a RESTful architectural style (which is the core concept of Sling).
>
> I'd address the implementation details last, since - contrary to many 
> other web frameworks - those do not dominate the solution design.
>
> Regards,
> Olaf
>
> * Okay, there is JCR OCM, but it's dated / requires some additional work:
> http://www.connectcon.ch/2015/en/speakers/katarzyna-kozlowska.html
>
>
> -----Original Message-----
> From: Guillaume Lucazeau [mailto:glucazeau@gmail.com]
> Sent: Freitag, 13. November 2015 16:10
> To: users@sling.apache.org
> Subject: Re: Resource class vs CND
>
> Thank you for your advice
>
> I got rid of my CND file and created content using sling:resourceType. 
> I had the idea that defining my node structure somewhere would allow 
> me to create form dynamically to add subnodes.
>
> So I've created two classes:
> // Document.java
> @Model(adaptables=Resource.class)
> public class Document {
>
>   @Inject @Named("jcr:title")
>   private String title;
>
>   @Inject
>   private List<Resource> pages;
> }
>
> // Page.java
> @Model(adaptables=Resource.class)
> public class Page {
>
>   @Inject @Named("jcr:title")
>   private String title;
>
>   @Inject
>   private List<Resource> components;
> }
>
> But I don't see how to map them to a sling:resourceType. Is it with
> getResourceType() like in here:
>
> https://svn.apache.org/repos/asf/sling/trunk/launchpad/test-services/s
> rc/main/java/org/apache/sling/launchpad/testservices/resourceprovider/
> PlanetResource.java
> ?
>
> Sling definitely has its own rhythm to it and I'm slow to pick it up 
> :)
>
>
>
> On Fri, Nov 13, 2015 at 2:48 PM, Daniel Klco <da...@gmail.com>
> wrote:
>
> > Agreed, I would also highly suggest looking at Sling Models as an 
> > option to make your code more strongly typed without requiring a 
> > rigid node type
> > structure:
> > https://sling.apache.org/documentation/bundles/models.html
> >
> > On Fri, Nov 13, 2015 at 8:37 AM, Jason Bailey <Ja...@sas.com>
> > wrote:
> >
> > > My opinions:
> > >
> > > Sling is really about being able to take a data set and present 
> > > that data in multiple ways. For the vast majority of use cases you 
> > > should use the existing node types and property values and you 
> > > don't need to
> use a CND.
> > >
> > > A custom nodetype is useful if there is a need to perform some 
> > > explicit searching over a large set of data or if you absolutely 
> > > require
> > limitations
> > > on properties that the existing nodetypes don't help with.
> > >
> > > Avoid trying to think of it in terms of other frameworks; Sling 
> > > has its own rhythm to it. You have a request that identifies a 
> > > resource and then that data is handed off to a renderer.  Using as 
> > > much out of the box functionality will give you the greatest flexibility.
> > >
> > >
> > > -Jason
> > >
> > > -----Original Message-----
> > > From: Guillaume Lucazeau [mailto:glucazeau@gmail.com]
> > > Sent: Friday, November 13, 2015 8:01 AM
> > > To: users@sling.apache.org
> > > Subject: Resource class vs CND
> > >
> > > Hello,
> > >
> > > I'm currently studying Sling for a project, to store "documents"
> > > containing pages, and components (image, text, maps, graphs etc.)
> > >
> > > While it seems to fit our needs perfectly, I'm a bit struggling to 
> > > learn some basic stuff before presenting a POC to our team.
> > >
> > > My first question would be: on what criteria should I choose to 
> > > manage my resources using a class extending AbstractResource or a 
> > > nodetype
> > definition
> > > in a CND file? Do you have advice on it? I'm tending to use a 
> > > class to
> > keep
> > > everything in Java, but I'm wondering if it's more/less/equally 
> > > flexible, and if it has drawbacks or benefits compared to a CND file.
> > >
> > > Thank you for every information you could give me
> > >
> > > Regards,
> > > Guillaume
> > >
> >
>
>


Re: Resource class vs CND

Posted by Guillaume Lucazeau <gl...@gmail.com>.
Thank you Olaf for your answer.

I have currently little information about the app. What I know is that it
will mostly manage documents, organized like this:
- network (a dozen)
-- documents: around 1,500
--- pages: around 15,000 (total)
---- components (graphs, map, picture etc.): 1 to 4 per page, total around
70,000

Adding to this, they want to provide questionnaires and then manage
answers. Also make pages and/or component commentable (I was thinking about
a mixin to manage that(?)). They want to export those comments periodically
(maybe a custom JCR query would be useful here? I have to look if you can
query over sling:resourceType or if you can only query jcr:primaryType)
We would also have to store content in an Oracle database, which is
possible I think with Jackrabbit.

Identification is made through Gmail, I've seen there is an OpenID module
even though it seems to be a little bit out-dated. There is currently
around 500 users planned.

One of the question I will have to ask them is about what seems to be a
requirements: have skeleton of documents with changes propagated to every
document instances (for instance, moving a certain page type to a different
position than its current). I don't see how we could do that with the JCR
tree.

While I don't know much yet about Sling and the application we have to
develop, I have the feeling that Sling is flexible and adapted to this, and
could be reusable. I'm just a little afraid of the learning curve, because
the documentation and even your answers sometimes seem very abstract and I
don't have yet the knowledge to see how we could use it properly. But it
still seems more appropriate than a custom database architecture.

Once again, thank you all for your help.


On Fri, Nov 13, 2015 at 10:08 PM, Olaf <ol...@x100.de> wrote:

> Hi Guillaume,
>
> There is no direct relationship between these models and the sling
> resource type. You can look at these models as views on arbitrary
> resources. Indeed, you can obtain an instance of a model by adapting to it
> from an arbitrary resource, for instance:
>
> Resource documentResource =
> resourceResolver.getResource("/path/to/document");
> Document document = documentResource.adaptTo(Document.class)
>
> Note, however, that these models are read-only, i.e. there is currently no
> support to persist them*.
>
> However, whether you require structured data (specific node types) or
> unstructured data, sling models or anything else really depends on you use
> cases. For many cases, storing the data with suitable sling:resourceTypes
> and rendering it on demand (e.g. using Sightly) is completely sufficient.
>
> Sling differs from other web frameworks in that it does not restrict you
> to one specific way in which to deal with things, but offers a very vast
> amount of options. In other words: What is your use case? For instance,
> what is the semantic structure of your data, who shall be using it and what
> for, how does it change / update, what data volume do you expect etc.
> Following, I'd then look at how these semantics are best expressed in a
> RESTful architectural style (which is the core concept of Sling).
>
> I'd address the implementation details last, since - contrary to many
> other web frameworks - those do not dominate the solution design.
>
> Regards,
> Olaf
>
> * Okay, there is JCR OCM, but it's dated / requires some additional work:
> http://www.connectcon.ch/2015/en/speakers/katarzyna-kozlowska.html
>
>
> -----Original Message-----
> From: Guillaume Lucazeau [mailto:glucazeau@gmail.com]
> Sent: Freitag, 13. November 2015 16:10
> To: users@sling.apache.org
> Subject: Re: Resource class vs CND
>
> Thank you for your advice
>
> I got rid of my CND file and created content using sling:resourceType. I
> had the idea that defining my node structure somewhere would allow me to
> create form dynamically to add subnodes.
>
> So I've created two classes:
> // Document.java
> @Model(adaptables=Resource.class)
> public class Document {
>
>   @Inject @Named("jcr:title")
>   private String title;
>
>   @Inject
>   private List<Resource> pages;
> }
>
> // Page.java
> @Model(adaptables=Resource.class)
> public class Page {
>
>   @Inject @Named("jcr:title")
>   private String title;
>
>   @Inject
>   private List<Resource> components;
> }
>
> But I don't see how to map them to a sling:resourceType. Is it with
> getResourceType() like in here:
>
> https://svn.apache.org/repos/asf/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/resourceprovider/PlanetResource.java
> ?
>
> Sling definitely has its own rhythm to it and I'm slow to pick it up :)
>
>
>
> On Fri, Nov 13, 2015 at 2:48 PM, Daniel Klco <da...@gmail.com>
> wrote:
>
> > Agreed, I would also highly suggest looking at Sling Models as an
> > option to make your code more strongly typed without requiring a rigid
> > node type
> > structure:
> > https://sling.apache.org/documentation/bundles/models.html
> >
> > On Fri, Nov 13, 2015 at 8:37 AM, Jason Bailey <Ja...@sas.com>
> > wrote:
> >
> > > My opinions:
> > >
> > > Sling is really about being able to take a data set and present that
> > > data in multiple ways. For the vast majority of use cases you should
> > > use the existing node types and property values and you don't need to
> use a CND.
> > >
> > > A custom nodetype is useful if there is a need to perform some
> > > explicit searching over a large set of data or if you absolutely
> > > require
> > limitations
> > > on properties that the existing nodetypes don't help with.
> > >
> > > Avoid trying to think of it in terms of other frameworks; Sling has
> > > its own rhythm to it. You have a request that identifies a resource
> > > and then that data is handed off to a renderer.  Using as much out
> > > of the box functionality will give you the greatest flexibility.
> > >
> > >
> > > -Jason
> > >
> > > -----Original Message-----
> > > From: Guillaume Lucazeau [mailto:glucazeau@gmail.com]
> > > Sent: Friday, November 13, 2015 8:01 AM
> > > To: users@sling.apache.org
> > > Subject: Resource class vs CND
> > >
> > > Hello,
> > >
> > > I'm currently studying Sling for a project, to store "documents"
> > > containing pages, and components (image, text, maps, graphs etc.)
> > >
> > > While it seems to fit our needs perfectly, I'm a bit struggling to
> > > learn some basic stuff before presenting a POC to our team.
> > >
> > > My first question would be: on what criteria should I choose to
> > > manage my resources using a class extending AbstractResource or a
> > > nodetype
> > definition
> > > in a CND file? Do you have advice on it? I'm tending to use a class
> > > to
> > keep
> > > everything in Java, but I'm wondering if it's more/less/equally
> > > flexible, and if it has drawbacks or benefits compared to a CND file.
> > >
> > > Thank you for every information you could give me
> > >
> > > Regards,
> > > Guillaume
> > >
> >
>
>

RE: Resource class vs CND

Posted by Olaf <ol...@x100.de>.
Hi Guillaume,

There is no direct relationship between these models and the sling resource type. You can look at these models as views on arbitrary resources. Indeed, you can obtain an instance of a model by adapting to it from an arbitrary resource, for instance:

Resource documentResource = resourceResolver.getResource("/path/to/document");
Document document = documentResource.adaptTo(Document.class)

Note, however, that these models are read-only, i.e. there is currently no support to persist them*.

However, whether you require structured data (specific node types) or unstructured data, sling models or anything else really depends on you use cases. For many cases, storing the data with suitable sling:resourceTypes and rendering it on demand (e.g. using Sightly) is completely sufficient. 

Sling differs from other web frameworks in that it does not restrict you to one specific way in which to deal with things, but offers a very vast amount of options. In other words: What is your use case? For instance, what is the semantic structure of your data, who shall be using it and what for, how does it change / update, what data volume do you expect etc. Following, I'd then look at how these semantics are best expressed in a RESTful architectural style (which is the core concept of Sling). 

I'd address the implementation details last, since - contrary to many other web frameworks - those do not dominate the solution design.

Regards,
Olaf

* Okay, there is JCR OCM, but it's dated / requires some additional work: http://www.connectcon.ch/2015/en/speakers/katarzyna-kozlowska.html
 

-----Original Message-----
From: Guillaume Lucazeau [mailto:glucazeau@gmail.com] 
Sent: Freitag, 13. November 2015 16:10
To: users@sling.apache.org
Subject: Re: Resource class vs CND

Thank you for your advice

I got rid of my CND file and created content using sling:resourceType. I had the idea that defining my node structure somewhere would allow me to create form dynamically to add subnodes.

So I've created two classes:
// Document.java
@Model(adaptables=Resource.class)
public class Document {

  @Inject @Named("jcr:title")
  private String title;

  @Inject
  private List<Resource> pages;
}

// Page.java
@Model(adaptables=Resource.class)
public class Page {

  @Inject @Named("jcr:title")
  private String title;

  @Inject
  private List<Resource> components;
}

But I don't see how to map them to a sling:resourceType. Is it with
getResourceType() like in here:
https://svn.apache.org/repos/asf/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/resourceprovider/PlanetResource.java
?

Sling definitely has its own rhythm to it and I'm slow to pick it up :)



On Fri, Nov 13, 2015 at 2:48 PM, Daniel Klco <da...@gmail.com> wrote:

> Agreed, I would also highly suggest looking at Sling Models as an 
> option to make your code more strongly typed without requiring a rigid 
> node type
> structure:
> https://sling.apache.org/documentation/bundles/models.html
>
> On Fri, Nov 13, 2015 at 8:37 AM, Jason Bailey <Ja...@sas.com>
> wrote:
>
> > My opinions:
> >
> > Sling is really about being able to take a data set and present that 
> > data in multiple ways. For the vast majority of use cases you should 
> > use the existing node types and property values and you don't need to  use a CND.
> >
> > A custom nodetype is useful if there is a need to perform some 
> > explicit searching over a large set of data or if you absolutely 
> > require
> limitations
> > on properties that the existing nodetypes don't help with.
> >
> > Avoid trying to think of it in terms of other frameworks; Sling has 
> > its own rhythm to it. You have a request that identifies a resource 
> > and then that data is handed off to a renderer.  Using as much out 
> > of the box functionality will give you the greatest flexibility.
> >
> >
> > -Jason
> >
> > -----Original Message-----
> > From: Guillaume Lucazeau [mailto:glucazeau@gmail.com]
> > Sent: Friday, November 13, 2015 8:01 AM
> > To: users@sling.apache.org
> > Subject: Resource class vs CND
> >
> > Hello,
> >
> > I'm currently studying Sling for a project, to store "documents"
> > containing pages, and components (image, text, maps, graphs etc.)
> >
> > While it seems to fit our needs perfectly, I'm a bit struggling to 
> > learn some basic stuff before presenting a POC to our team.
> >
> > My first question would be: on what criteria should I choose to 
> > manage my resources using a class extending AbstractResource or a 
> > nodetype
> definition
> > in a CND file? Do you have advice on it? I'm tending to use a class 
> > to
> keep
> > everything in Java, but I'm wondering if it's more/less/equally 
> > flexible, and if it has drawbacks or benefits compared to a CND file.
> >
> > Thank you for every information you could give me
> >
> > Regards,
> > Guillaume
> >
>


Re: Resource class vs CND

Posted by Guillaume Lucazeau <gl...@gmail.com>.
Thank you for your advice

I got rid of my CND file and created content using sling:resourceType. I
had the idea that defining my node structure somewhere would allow me to
create form dynamically to add subnodes.

So I've created two classes:
// Document.java
@Model(adaptables=Resource.class)
public class Document {

  @Inject @Named("jcr:title")
  private String title;

  @Inject
  private List<Resource> pages;
}

// Page.java
@Model(adaptables=Resource.class)
public class Page {

  @Inject @Named("jcr:title")
  private String title;

  @Inject
  private List<Resource> components;
}

But I don't see how to map them to a sling:resourceType. Is it with
getResourceType() like in here:
https://svn.apache.org/repos/asf/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/resourceprovider/PlanetResource.java
?

Sling definitely has its own rhythm to it and I'm slow to pick it up :)



On Fri, Nov 13, 2015 at 2:48 PM, Daniel Klco <da...@gmail.com> wrote:

> Agreed, I would also highly suggest looking at Sling Models as an option to
> make your code more strongly typed without requiring a rigid node type
> structure:
> https://sling.apache.org/documentation/bundles/models.html
>
> On Fri, Nov 13, 2015 at 8:37 AM, Jason Bailey <Ja...@sas.com>
> wrote:
>
> > My opinions:
> >
> > Sling is really about being able to take a data set and present that data
> > in multiple ways. For the vast majority of use cases you should use the
> > existing node types and property values and you don't need to  use a CND.
> >
> > A custom nodetype is useful if there is a need to perform some explicit
> > searching over a large set of data or if you absolutely require
> limitations
> > on properties that the existing nodetypes don't help with.
> >
> > Avoid trying to think of it in terms of other frameworks; Sling has its
> > own rhythm to it. You have a request that identifies a resource and then
> > that data is handed off to a renderer.  Using as much out of the box
> > functionality will give you the greatest flexibility.
> >
> >
> > -Jason
> >
> > -----Original Message-----
> > From: Guillaume Lucazeau [mailto:glucazeau@gmail.com]
> > Sent: Friday, November 13, 2015 8:01 AM
> > To: users@sling.apache.org
> > Subject: Resource class vs CND
> >
> > Hello,
> >
> > I'm currently studying Sling for a project, to store "documents"
> > containing pages, and components (image, text, maps, graphs etc.)
> >
> > While it seems to fit our needs perfectly, I'm a bit struggling to learn
> > some basic stuff before presenting a POC to our team.
> >
> > My first question would be: on what criteria should I choose to manage my
> > resources using a class extending AbstractResource or a nodetype
> definition
> > in a CND file? Do you have advice on it? I'm tending to use a class to
> keep
> > everything in Java, but I'm wondering if it's more/less/equally flexible,
> > and if it has drawbacks or benefits compared to a CND file.
> >
> > Thank you for every information you could give me
> >
> > Regards,
> > Guillaume
> >
>

Re: Resource class vs CND

Posted by Daniel Klco <da...@gmail.com>.
Agreed, I would also highly suggest looking at Sling Models as an option to
make your code more strongly typed without requiring a rigid node type
structure:
https://sling.apache.org/documentation/bundles/models.html

On Fri, Nov 13, 2015 at 8:37 AM, Jason Bailey <Ja...@sas.com> wrote:

> My opinions:
>
> Sling is really about being able to take a data set and present that data
> in multiple ways. For the vast majority of use cases you should use the
> existing node types and property values and you don't need to  use a CND.
>
> A custom nodetype is useful if there is a need to perform some explicit
> searching over a large set of data or if you absolutely require limitations
> on properties that the existing nodetypes don't help with.
>
> Avoid trying to think of it in terms of other frameworks; Sling has its
> own rhythm to it. You have a request that identifies a resource and then
> that data is handed off to a renderer.  Using as much out of the box
> functionality will give you the greatest flexibility.
>
>
> -Jason
>
> -----Original Message-----
> From: Guillaume Lucazeau [mailto:glucazeau@gmail.com]
> Sent: Friday, November 13, 2015 8:01 AM
> To: users@sling.apache.org
> Subject: Resource class vs CND
>
> Hello,
>
> I'm currently studying Sling for a project, to store "documents"
> containing pages, and components (image, text, maps, graphs etc.)
>
> While it seems to fit our needs perfectly, I'm a bit struggling to learn
> some basic stuff before presenting a POC to our team.
>
> My first question would be: on what criteria should I choose to manage my
> resources using a class extending AbstractResource or a nodetype definition
> in a CND file? Do you have advice on it? I'm tending to use a class to keep
> everything in Java, but I'm wondering if it's more/less/equally flexible,
> and if it has drawbacks or benefits compared to a CND file.
>
> Thank you for every information you could give me
>
> Regards,
> Guillaume
>

RE: Resource class vs CND

Posted by Jason Bailey <Ja...@sas.com>.
My opinions:

Sling is really about being able to take a data set and present that data in multiple ways. For the vast majority of use cases you should use the existing node types and property values and you don't need to  use a CND.

A custom nodetype is useful if there is a need to perform some explicit searching over a large set of data or if you absolutely require limitations on properties that the existing nodetypes don't help with.

Avoid trying to think of it in terms of other frameworks; Sling has its own rhythm to it. You have a request that identifies a resource and then that data is handed off to a renderer.  Using as much out of the box functionality will give you the greatest flexibility.


-Jason

-----Original Message-----
From: Guillaume Lucazeau [mailto:glucazeau@gmail.com] 
Sent: Friday, November 13, 2015 8:01 AM
To: users@sling.apache.org
Subject: Resource class vs CND

Hello,

I'm currently studying Sling for a project, to store "documents" containing pages, and components (image, text, maps, graphs etc.)

While it seems to fit our needs perfectly, I'm a bit struggling to learn some basic stuff before presenting a POC to our team.

My first question would be: on what criteria should I choose to manage my resources using a class extending AbstractResource or a nodetype definition in a CND file? Do you have advice on it? I'm tending to use a class to keep everything in Java, but I'm wondering if it's more/less/equally flexible, and if it has drawbacks or benefits compared to a CND file.

Thank you for every information you could give me

Regards,
Guillaume