Differences between type responses for node and resource

2014-09-10 Thread Jason E Bailey
Lets say I have a node of type sling:Folder.



Calling

node.isNodeType(nt:folder)

will return true, since sling:Folder extends nt:folder



However

resource.isResourceType(nt:folder)

will return false. I'm assuming since it's attempting to
resolve up the resource heirarchy(?)



My question, is there a Foo utility to determine if a given
resource is of a particular type via the node definition?



TIA.

--
Jason E Bailey


Re: Differences between type responses for node and resource

2014-09-11 Thread Jason E Bailey
I understand the difference between the Sling Resource Type and the JCR
Node type. However the resource.isResourceType is not specifically
dealing with one or the other. If I had a resource of a node with a
primaryNodeType of nt:file then doing resource.isResourceType(nt:file)
would return true. 

I had to dig through the code to see what was going on. 

The basic idea is that calling resource.getResourceType() will return
the sling:resourceType and if that's not there then it will return the
jcr:primaryType. When calling isResourceType it will compare against
the resource.getResourceType() and if that's not a match will march of
the chain of getSuperResourceType looking for a match, and that matches
only against the sling:resourceType.

I can sorta see where that's useful from a script resolution point of
view. I find it odd overall as it's missing out on a section of
inheritance. It's like having a java instanceof operator ignoring
interfaces. 

-- 
  Jason

On Wed, Sep 10, 2014, at 01:13 PM, Paul McMahon wrote:
 There isn't necessarily a mapping between Sling Resource Type and the JCR
 Node type. The sling resource type is determined based on the value or
 the sling:resourceType property on the node, where as the JCR Node type
 is determined based on jcr:primaryType value. In most cases nodes of
 sling:resourceType will always be the same jcr:primaryType, but technical
 that isn't a requirement. In  reality there are most jcr:primaryTypes map
 to many different sling:resourceType (or no sling resource type). 
 
 
 Paul McMahon
 Acquity Group, Part of Accenture Interactive
 
 
 On Wednesday, September 10, 2014 9:56 AM, Jason E Bailey
 jason.bai...@24601.org wrote:
  
 
 
 Lets say I have a node of type sling:Folder.
 
 
 
 Calling
 
 node.isNodeType(nt:folder)
 
 will return true, since sling:Folder extends nt:folder
 
 
 
 However
 
 resource.isResourceType(nt:folder)
 
 will return false. I'm assuming since it's attempting to
 resolve up the resource heirarchy(?)
 
 
 
 My question, is there a Foo utility to determine if a given
 resource is of a particular type via the node definition?
 
 
 
 TIA.
 
 --
 Jason E Bailey


Re: Differences between type responses for node and resource

2014-09-12 Thread Jason E Bailey
Alexander,

I have a hard time understanding how there would be added complexity by
incorporating the nodeType hierarchy into a determination as to whether
a specific resource is of a specific type. Multiple hierarchies are
fairly common in programming languages, like the instanceof I mentioned
that does both the class hierarchy and the interface hierarchy.  I also
don't see much confusion occurring from implementing this. If I am
attempting to validate a whether something is inherited from nt:base I
clearly have a need in mind that would be separate from desire to know
if it's a sling component that inherits from foundation/list

I would like to use resources as much as possible :) The flexibility
however ends when I need to validate an associated nodeType,

-- 
Jason

On Thu, Sep 11, 2014, at 03:09 PM, Alexander Klimetschek wrote:
 Sling resource types have their own super type hierarchy. Using jcr node
 types if no sling:resourceType is specified was added as a fallback for
 cases where it is impractical to set a sling:resourceType. But it does
 not take into account the node type hierarchy, I think because it would
 simply be too complex, since you then have to look at two hierarchies.
 
 I would use sling resource types as much as possible over node types,
 since they are a lot more flexible.
 
 HTH,
 Alex
 
 On 11.09.2014, at 14:54, Jason E Bailey jason.bai...@24601.org wrote:
 
  I understand the difference between the Sling Resource Type and the JCR
  Node type. However the resource.isResourceType is not specifically
  dealing with one or the other. If I had a resource of a node with a
  primaryNodeType of nt:file then doing resource.isResourceType(nt:file)
  would return true. 
  
  I had to dig through the code to see what was going on. 
  
  The basic idea is that calling resource.getResourceType() will return
  the sling:resourceType and if that's not there then it will return the
  jcr:primaryType. When calling isResourceType it will compare against
  the resource.getResourceType() and if that's not a match will march of
  the chain of getSuperResourceType looking for a match, and that matches
  only against the sling:resourceType.
  
  I can sorta see where that's useful from a script resolution point of
  view. I find it odd overall as it's missing out on a section of
  inheritance. It's like having a java instanceof operator ignoring
  interfaces. 
  
  -- 
   Jason
  
  On Wed, Sep 10, 2014, at 01:13 PM, Paul McMahon wrote:
  There isn't necessarily a mapping between Sling Resource Type and the JCR
  Node type. The sling resource type is determined based on the value or
  the sling:resourceType property on the node, where as the JCR Node type
  is determined based on jcr:primaryType value. In most cases nodes of
  sling:resourceType will always be the same jcr:primaryType, but technical
  that isn't a requirement. In  reality there are most jcr:primaryTypes map
  to many different sling:resourceType (or no sling resource type). 
  
  
  Paul McMahon
  Acquity Group, Part of Accenture Interactive
  
  
  On Wednesday, September 10, 2014 9:56 AM, Jason E Bailey
  jason.bai...@24601.org wrote:
  
  
  
  Lets say I have a node of type sling:Folder.
  
  
  
  Calling
  
  node.isNodeType(nt:folder)
  
  will return true, since sling:Folder extends nt:folder
  
  
  
  However
  
  resource.isResourceType(nt:folder)
  
  will return false. I'm assuming since it's attempting to
  resolve up the resource heirarchy(?)
  
  
  
  My question, is there a Foo utility to determine if a given
  resource is of a particular type via the node definition?
  
  
  
  TIA.
  
  --
  Jason E Bailey
 


Re: Reg - Clustering

2014-09-17 Thread Jason E Bailey
http://sling.apache.org/documentation/bundles/discovery-api-and-impl.html

Sling supports clustering of the underlying content repository.
Sling , being a REST based platform, doesn't recommend stateful content
on the server. So it's not recommended to use HttpSessions. 

-- 
Jason

On Wed, Sep 17, 2014, at 07:52 AM, Mallampalli, Bhagyaraj wrote:
 Hi,
 
 Could you please help me out on the following questions:
 
 1. Is apache sling supports clustering and session replications between
 the nodes?
 2. Is it recommended to use the HttpSessions in my project if I use the
 Apache Sling server?
 
 If yes, please share the me the documentation. Thanks in advance.
 
 Regards,
 Bhagyaraj,
 +31 652622234


launchpad 7 from github

2014-10-13 Thread Jason E Bailey
Not sure if I'm missing a step or what. I went to pull down the
launchpad for 7, with the tag org.apache.sling.launchpad-7, and
that tag doesn't exist over there as far as I can see.



--
Jason


Re: Route mapping for dynamic resources in Sling

2015-03-06 Thread Jason E Bailey
So I can get a clear picture of the request, a typical request would be
for?

/host/whitepaper.pdf/host/true/version-1/host/-/users/john123


-- 
Jason

On Fri, Mar 6, 2015, at 09:50 AM, Duy Nguyen wrote:
  Hello,
 
 I'm bringing here a use case in Sling and look forward to receiving some
 opinions from the community.
 
 I need to write a server-side app that serves customized RESTful APIs for
 a
 client app (which is stable and the set of APIs is fixed). The problem
 comes from ugly API urls that can hardly be mapped into the resource
 model of Sling, for example:
 
 */myhost/{documentName}/myhost/{**documentName*
 *}/{hasRevision}/{revisionID}/myhost/-/users/{userName}*
 
 Especially properties like “documentName, “revisionID and userName
 are
 not necessarily stored in jcr resources, but can also be from external
 sources. The flag “hasRevision” is either true or false value, to check
 if
 the document has revision to be returned. So there must be some
 middleware
 that handles the requests coming to each of those paths (to determine if
 the needed resource can be retrieved from jcr or external sources, and
 revision to be taken into account).
 
 Thinking in the implementation of some regular web frameworks (Django,
 Sinatra, etc.), it can be done by route mapping, such as:
 *get(/myhost/:**documentName*
 */:hasRevision?/:revisionID?) function()
 {…}get(/myhost/-/users/:userName) function() {…}*
 
 Initially I have come up with two solutions in Sling:
 
 1- Write a global SlingServlet for /myhost/, and then the rest of the
 url are params that will be analyzed in the servlet to handle different
 request patterns. However I don't think this is a very elegant solution,
 because this only one servlet is responsible for all requests following
 the
 path.
 
 2- Use Sling Resource Mappings
 http://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html
 to
 redirect the requests (categorized by reg-ex) to different resources, and
 then write separate SlingServlet for each of those resources. I still
 have
 some doubt if this is feasible.
 
 Do you have some suggestions?
 
 Thanks,
 Duy


Re: sling without a jcrResourceProvider

2016-06-16 Thread Jason E Bailey
Looking at the API I actually have something similar already written
that uses a resource as a starting point and iterates down through the
child resources to perform the query. 

In that manner it's agnostic as to what's providing the resource,  as
long as we are able to obtain the children of a resource.

Since it's possible for the children of a resource to be provided by
multiple resource providers, handing off the queries to be handled by
multiple resource providers may improve the speed of the query.
Additionally, you mentioned each resource provider may optionally cache
the internal results,  however you would then still need to consolidate
that set of data and apply ranges and limits, which I don't believe
could be done effectively from within the resource provider itself.

Alternatively, since I've had the same experience that Steve has had
with iterative searching, an external iteration  does not require that
the resource provider do anything more than what it currently does which
is to identify a resource and it's children. 


--
Jason

On Thu, Jun 16, 2016, at 10:50 AM, Carsten Ziegeler wrote:
> Steven Walters wrote
> > I've seen this API (mentioned) before, and I don't understand why it
> > has to get passed onto the ResourceProvider to handle the logic.
> > It could instead be ResourceProvider agnostic, so always
> > available/functioning no matter what providers are around/in use.
> 
> Really? How?
> 
> Carsten
> 
> > 
> > Continuing to depend on ResourceProviders for such functionality
> > (especially a query language this basic that could just be done
> > through standard Sling resource visitation/navigation/iteration)
> > doesn't seem all that beneficial, it just seems to add more complexity
> > to the ResourceProviders that already have enough complexity as they
> > are.
> > 
> 
> 
> 
>  
> -- 
> Carsten Ziegeler
> Adobe Research Switzerland
> cziege...@apache.org


Re: Querying vs iterating

2016-06-20 Thread Jason E Bailey
I have seen significant gains in obtaining a list of results, and the
speed of my services, by doing an iteration versus a query. I have had a
query looking for an indexed node type, going from 10 minutes to 1 and a
half minute.

I should point out that  that makes no sense.

When it was first suggested to me that I iterate rather than use a
query. I looked at the person in question as if they had never studied
computers. It has historically been beaten into my head for close to 2
decades that if you want performance from a data store, you use a query
and you create indexes.  Doing an iteration struck me as something that
only someone who didn't know what they were doing would suggest or that
they had done something wrong in their setup i.e. failed to set up an
index.

I was wrong.

Maybe I should file a bug report. "Hey why is it that I can iterate and
get results faster than doing an indexed query?" I'm also sure that
indexing and running a query is the right way to address some needs.
However, right now, every time I've done a comparison between executing
a query and just going to the source and checking myself.  The iteration
style has been significantly faster.

--
Jason

On Mon, Jun 20, 2016, at 10:01 AM, Julian Sedding wrote:
> Hi Roy
> 
> Yes, I would expect that you cannot measure any meaningful difference.
> Using a query may be marginally faster, because it can traverse using
> internal Oak APIs. On the other hand it may be slightly slower,
> because of possible QueryEngine overhead.
> 
> Personally I would test whether it works sufficiently well with a
> query, because it is less code.
> 
> Note also that Sling Query
> (https://sling.apache.org/documentation/bundles/sling-query.html)
> allows you to express a query and choose traversal vs query as a
> strategy. This may or may not help.
> 
> Regards
> Julian
> 
> 
> On Mon, Jun 20, 2016 at 3:52 PM, Roy Teeuwen  wrote:
> > Hey Julian,
> >
> > Ok cool, for me the context is querying on a page in AEM, so I am creating 
> > a query for one cq:Page node, so that will be most of the times max like 
> > 10-20 nodes.
> > So what you are saying then is that it shouldn’t really matter in 
> > performance to choose either for manually traverse myself or doing a query 
> > when looking to see if a specific property name exists on the page,
> > because behind the scene it will most likely traverse itself then anyway, 
> > right?
> >
> > Thanks!
> > Roy
> >> On 20 Jun 2016, at 15:43, Julian Sedding  wrote:
> >>
> >> Hi Roy
> >>
> >> From you question ("hard to put an index to it") I assume that you are
> >> running on an Oak repository. If that is incorrect, my answer does not
> >> apply.
> >>
> >> Oak will always consider traversal as an alternative to existing
> >> indexes. For most queries the cost of traversal is so high that an
> >> index is chosen. However, if no suitable index exists (and
> >> theoretically also if the traversal is cheaper than a lookup in a
> >> matching index), it will do a traversal behind the scenes. Note that
> >> traversal logs a warning every 1 traversed nodes. So if you plan
> >> to traverse more than that you should really consider creating an
> >> index.
> >>
> >> In short: with Oak using a query on a small subtree should give you
> >> what you want, even without an index.
> >>
> >> Regards
> >> Julian
> >>
> >>
> >> On Thu, Jun 16, 2016 at 4:44 PM, Steven Walters  wrote:
> >>> Hopefully other people chime in here, I've only had bad experiences
> >>> with utilizing queries and have often resulted in personally never
> >>> using them - so I always end up iterating/navigating myself.
> >>>
> >>> Theoretically if you have a REALLY GOOD index then you may get some
> >>> similar performances, but if your index(es) are inefficient, then it's
> >>> just wasted CPU cycles (you'd wish those CPU cycles were going to a
> >>> good cause, but they're not).
> >>>
> >>> the transition of Sling (and AEM) to Oak from Jackrabbit 2.x made this
> >>> experience worse with the awkward indexing policies/process in Oak,
> >>> and the fact that Oak never seemed to ever use multiple indexes.
> >>> Oak always seemed to calculates the costs of the entire query against
> >>> all the available indexes and only chooses the ONE best index.
> >>> This sounds like a good idea in theory, but then most DBMS I've used
> >>> in the past utilize ALL the indexes they can - not just one.
> >>>
> >>> So basically i guess this comes to be "If you have a good index (in
> >>> that it can apply to ALL the conditions/attributes/properties of your
> >>> query) then using a query should be fine, otherwise iterate yourself"
> >>> having any condition missing from the index can be fatal in
> >>> performance, such as lacking the evaluatePathRestrictions = true,
> >>> which without it is basically death of the system if you have a lot of
> >>> content.
> >>>
> >>> But really, I hope some other people with more 

Re: sling without a jcrResourceProvider

2016-06-16 Thread Jason E Bailey
Which api proposal is that?
 
--
Jason
 
 
 
On Thu, Jun 16, 2016, at 01:14 AM, Carsten Ziegeler wrote:
> Steven Walters wrote
> > The other providers sling manages in its codebase don't appear to
> > get much
> > TLC, such as that they're all still using the older deprecated
> > ResourceProvider system, instead of the new one (which the JCR
> > ResourceProvider does use).
> >
> > Also, it appears that a number of the sling
> > components/functionalities
> > still require the JCR, such as
> > * Eventing/Jobs, by mandating node types and using JCR queries to
> >   retrieve
> > them.
> > * Generic Sling Post Servlet functionality, in that the
> > import/contentloader functionality of it still utilizes the JCR
> > APIs for
> > the creation of data.
> >
> > This is just some things I've seen so far from working on my own
> > ResourceProvider as well.
> >
> > So some portions of Sling can work without JCR but it still
> > remains that
> > some portions of functionality still cannot work without JCR
> > currently.
> >
> > The Sling Post functionality will be on the easier side to alter to
> > be JCR
> > independent, but Eventing will require more thought as to what to
> > do about
> > the queries.
> >
>
> We have a proposal for an API extension to solve that problem. Only
> thing missing is someone implementing it :)
>
> Carsten
>
> --
> Carsten Ziegeler
> Adobe Research Switzerland
> cziege...@apache.org
 


Re: One Resource to multiple views in different locations

2016-07-12 Thread Jason E Bailey
My understanding of this is slightly different.

1.  The url specifies the resource.
2.  The extension defines which rendering engine handles this request
3.  It's the extension that uses the information in the resource to
determine the script/scripts to be executed, with the default html
engine utilizing the sling:resourceType to determine the execution
script

When discussing different views for a resource, the key thing is that a
URL should define one view. If you want a resource to be displayed in
different ways, you want to modify the URL to be different. Either by
extension or selector.

--
Jason

On Mon, Jul 11, 2016, at 01:20 PM, vkum14 wrote:
> I guess what Shivika is referring to as view is actually Script:
> In sling request, first resource is resolved and sling:resourceType
> property
> in that node is using by ServletResolver to identify the best script in
> the
> folder on path of sling:resourceType property value. Which actually
> results
> into one to one mapping between a component and the folder which contains
> the script. Is there a way where-in sling:resourceType can be an array in
> defined sequence of folders to be used by ServletResolver to find the
> script? Or any other idea might be ResourceMerger?
> 
> Hope that helps!
> 
> 
> 
> --
> View this message in context:
> http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062395.html
> Sent from the Sling - Users mailing list archive at Nabble.com.


Re: One Resource to multiple views in different locations

2016-07-12 Thread Jason E Bailey
You have two distinct paths defined

/content/site1/en/home/breadcrumb.mobile.html
/content/site2/en/home/breadcrumb.mobile.html

I'm assuming that the output of the breadcrumb for these sites need to
be structurally different.

If you are building each site from scratch, or can modify the structure
of that site. Just use a different breadcrumb for what you want it to
do.

If you are using a stock or copied site  then I would suggest having the
component render itself differently depending on which site it's in and
then decide on a way to pass that information to the component.

Here are the ways that I know of getting that information to the
component without directly modifying the component.

1. The component scans up the page structure to look for the node
directly under content and  uses the site name (site1, site2) as the key
to the rendering. 
2. In AEM you would obtain the information from a design and set the
design for the site at the top level page ( site1, site2)
3. You would set a property on the top level site node (site1,site2) so
that you could use an InheritanceValueMap and locate the value that
determines the rendering style.

--
Jason


Re: How to create Rest APIs for non-JCR data in Sling 8??

2017-01-28 Thread Jason E Bailey

Its my understanding that the question on ACL's depends on where it is
inheriting the ACL from. Taking your code as literal, you've declared
that you own everything under /things and it would inherit the ACL of /.
So if you put your ROOT as /content/remote/things You could set JCR ACLs
on /content/remote.

Theoretically I assume that your resource could provide an ACL as the
ACL is just a resource in the tree.

As others suggested using a resource provider in this way may not be the
best solution. As the whole point of Sling is to manage content and
splitting it into different pieces can be awkward.

I'm assuming that you don't need to do POST operations, and that using
Oak with an S3 file storage configuration is out.

If you can tell Sling what's on the remote store, you could just use a
reference to the data. In the same way that in AEM, an image component
doesn't necessarily have the image, rather it can have a pointer to the
image.  So your renderer can just go out and retrieve the image and
return it.

Or, the Sling Resource Merger
https://sling.apache.org/documentation/bundles/resource-merger.html

In this case you can merge your resource provider with a JCR Path. So
that your resource provider provides the remote content while the
associated meta data can be stored in the JCR. Haven't tried this myself
though.









--
Jason

On Fri, Jan 27, 2017, at 04:27 PM, lancedolan wrote:
> Hi friends,
> 
> I've tried routing questions through stackoverflow to cut down my mails
> to
> this list. I'm losing lots of time on this one, though, and am stuck.
> 
> I need to create APIs which don't represent Sling Resources. Example:
> /services/images/123123123
> that image will exist somewhere else.
> 
> Bertrand suggests creating a ResourceProvider, as in the example here
> [1].
> However, that uses the spi package which is not in version 2.9.0 of
> org.apache.sling.api, and thus, not available to me in Sling 8.
> 
> I did find a ResourceProvider interface to implement though, and created
> this code:
> 
> /**
>  * Created by lancedolan on 1/27/17.
>  */
> @Component
> @Service(value=ResourceProvider.class)
> @Properties({
> @Property(name = ResourceProvider.ROOTS, value = "things"),
> @Property(name = ResourceProvider.OWNS_ROOTS, value = "true")
> })
> public class ImageResourceProvider implements ResourceProvider {
> 
> /** If this provider required a context this would be more elaborate,
>  *  but for this simple example we don't need one.
>  */
> public static class DoesNotNeedAContext {
> };
> 
> @Override
> public Resource getResource(ResourceResolver resourceResolver, String
> path) {
> Resource returnResource = new SyntheticResource(resourceResolver,
> path, "edlio/microservice/image");
> returnResource.getValueMap().put("myProp" , "myValue");
> return returnResource;
> }
> 
> @Override
> public Resource getResource(ResourceResolver resourceResolver,
> HttpServletRequest httpServletRequest, String path) {
> return getResource(resourceResolver , path);
> }
> 
> @Override
> public Iterator listChildren(Resource resource) {
> return null;
> }
> }
> 
> 
> The result is that I get a 403 response. How do I control the
> authentication
> for resources that don't actually exist? The fact that I'm not getting
> 404
> means that my ResourceProvider is at least registering successfully. 
> 
> Finally, I'd much prefer to use Jersey if possible... Anybody have
> success
> getting Jersey to work in Sling 8? I dumped a bunch of time into it and
> gave
> up after class not found errors for classes that should be found [2].
> 
> The ultimate goal is just to provide a restful API in Sling 8 and the
> static-path-declaration of SlingSafeMethodsServlet just doesn't cut it.
> 
> Thanks a million guys...
> 


Re: How to create Rest APIs for non-JCR data in Sling 8??

2017-01-29 Thread Jason E Bailey

In general I agree with you, that's the simplest 

OP had a dual need. which is storing information about the asset in the
JCR at the same time, which I don't see how your solution handles.

--
Jason

On Sat, Jan 28, 2017, at 02:08 PM, Henry Saginor wrote:
> In my opinion Sling is first and foremost a REST framework specifically
> designed for this kind of thing. It’s not only to serve JCR content.
> The paradigm Steven described earlier in this thread is EXACTLY the way
> to implement it. In the Sling world the resource IS the RESTful object
> addressable via a URI. The only thing I can add, as I wrote before, is
> that it’s not necessary to implement a custom resource provider.
> You can simply create JCR nodes/resources to map to your resource type
> via sling:resourceType. And what your servlet returns is up to you and
> your requirements. That works in most cases. 
> You can easily integrate your servlet with existing OSGi service via
> declarative services and use any framework/library you need internally
> (provided you can make it available in OSGi container) to integrate with
> your data where it adds value.
> But in my opinion it does not make sense integrating Sling with other
> framework, such as Spring, which follow different paradigms to do the
> same things as Sling + Declarative Services. It increases complexity and
> does not add value.
> 
> My advice is don’t shoot yourself in the foot and keep things as simple
> as possible. Just implement a servlet, integrate with existing service
> via DS if needed, and format and return the response based on your
> requirements. Then create a resource (JCR or custom ResourceProvider),
> map it to your servlet via sling:resourceType. This is how I have always
> implemented RESTful services in Sling without many limitations. The
> framework is specifically designed for this.
> 
> Henry  
>  
> > On Jan 28, 2017, at 7:57 AM, Jason E Bailey <jason.bai...@24601.org> wrote:
> > 
> > 
> > Its my understanding that the question on ACL's depends on where it is
> > inheriting the ACL from. Taking your code as literal, you've declared
> > that you own everything under /things and it would inherit the ACL of /.
> > So if you put your ROOT as /content/remote/things You could set JCR ACLs
> > on /content/remote.



Re: How to create Rest APIs for non-JCR data in Sling 8??

2017-01-29 Thread Jason E Bailey
I'm not sure how to correctly convey my confusion over your statement :)
There may be some bias here, since I've been doing this for a while, but
this is an incredibly easy platform for REST and I haven't ran across
another that gives me the same flexibility.

--
Jason

On Sat, Jan 28, 2017, at 05:27 PM, Ben Fortuna wrote:
> Hi Henry,
> 
> I agree with what you say about keeping it simple and using a servlet.
> However there are many frameworks and platforms today geared towards
> making
> it easier to implement REST APIs, and I think non-trivial APIs would
> probably benefit from using one.
> 
> As such, to me an API should live outside the Sling process and use sling
> as a data/content source.
> 
> Regards,
> Ben
> 



Re: Creating lots of nodes

2016-10-30 Thread Jason E Bailey
Additionally, if you are creating child nodes, you want them to be using
a non ordered structure. If you're using an ordered parent I could see
it creating a significant impact after a while.

Also, indexing. If you've got indexing going on that includes what
you're inserting that may have an impact as well.

--
Jason

On Sat, Oct 29, 2016, at 02:27 PM, Steven Walters wrote:
> On Fri, Oct 28, 2016 at 11:55 PM, Christoph Thodte
>  wrote:
> > Hello!
> >
> > What is the best and fast way to create a lot of resources in Sling? I 
> > import 200.000 data rows in jcr. My importer is very fast for the 30.000 
> > nodes than it will be very slow down. I commit my resourceresolver ervery 
> > 100 resources. The committing is fine but the time for creation of the 
> > resource is increased very fast. After 40.000 nodes the time is around 
> > 20min for creation of 100 nodes.
> >
> > What is the problem? How can I speed up. Can anyone support or explain this?
> > As datastore I use the mongodb. With tar it's slower than mongo. I use 
> > Sling API not the JCR Api. That's the problem?
> 
> I've not seen any particular performance difference in the past
> between using the Sling API vs the JCR API for massive data creation
> like this.
> 
> Can you elaborate a bit more on how you're organizing the data that
> you're creating within Sling?
> 
> That is, in the past there have been known performance problems with
> having a large number of direct children nodes/resources under a
> single parent within the JCR.
> So just wondering how you're structuring the data as you're creating
> it within Sling.
> Without such information, it's mostly grabbing at straws to guess what
> your problem may be.


Re: Architecting a heterogeneous Sling + Java EE application

2017-08-29 Thread Jason E Bailey

> > Pros:
> > 
> > - to work with the underlying repository, we can use JCR API directly
> > (can we?)
> 
> If you want to access the JCR API directly from the non-Sling part, you
> will be able to do so if the non-Sling part is part of the same OSGi
> runtime.
> 

It's been a while but I've used remote access to the JCR before. 
https://wiki.apache.org/jackrabbit/RemoteAccess

On a personal note, I would avoid JCR level manipulations and if
possible stick to the Sling API. You'll discover that that you'll be
writing a lot of boiler plate only to find that the Sling has come up
with a graceful way of handling it already.


--
Jason



Re: Maven plugin to set property on a resource

2017-12-19 Thread Jason E Bailey
Maybe something like maven exec or maven antrun to perform a curl command?

--
Jason

On Tue, Dec 19, 2017, at 1:04 PM, Roy Teeuwen wrote:
> Hey all,
> 
> I am searching for the fastest way to set and delete a property on a 
> resource of a specific path. I could use the gmaven-plugin and write a 
> groovy script to do this, but maybe there is already someone with a 
> better plugin for this and I don't have to write an ugly script for it 
> in my pom.xml.
> 
> Just for the people who want to know what I want to achieve: I am 
> installing my content package with test content(filevault xmls) and 
> images inside, but before I want to install it, I would like to disable 
> a workflow (more specifically the update dam asset workflow) because the 
> renditions are already in the test-content and it slows down the system 
> because of the heavy workflow/jobs triggering.
> 
> Greets,
> Roy
> Email had 1 attachment:
> + signature.asc
>   1k (application/pgp-signature)


Re: SlingHttpServletRequestWrapper Example?

2018-06-26 Thread Jason E Bailey
I answered there as well.

The problem with your existing attempt is that you are attempting to access the 
input stream after it has been opened. The parameters already exist when you're 
wrapping it and you just need to make sure your additional parameters are 
accessible as well. 

- Jason

On Mon, Jun 25, 2018, at 3:55 PM, Cris Rockwell wrote:
> Hello!
> 
> I posted a question to StackOverflow 
> 
>  
> about some issue I’m facing. I would like to add a POST parameter in a 
> Sling Filter using SlingHttpServletRequestWrapper 
> .
>  
> I would appreciate any ideas or suggestions. 
> 
> Thanks!
> Cris Rockwell
> 
> 
> 
> 
> 


RMI based ResourceProvider

2018-06-27 Thread Jason E Bailey
I don't have any legitimate use case for this, I just like to see if I
can make things work in a certain way.
I was thinking, wouldn't it be cool if I had a ResourceProvider which
was a connected via RMI to a JCR Resource Provider for a specific path.
I could then have one instance dedicated to being the source of record
for content, but the processing of this content, indexing, generating
pages, etc.  Would be on the individual servers.
Would appreciate feedback from anyone whose done this.

- Jason




SQL Resource Provider?

2018-05-01 Thread Jason E Bailey
Has anyone ever used a SQL resource provider or know where I can find such a 
thing?

- Jason


Re: SQL Resource Provider?

2018-05-02 Thread Jason E Bailey
Thought that would be the answer. I'll check out the prototype, thanks. 

It'll be fun to write a ResourceProvider for this but it's going to have to go 
to the bottom of my current list of things to get done in 
Sling. 

- Jason

On Wed, May 2, 2018, at 6:08 AM, Stefan Seifert wrote:
> hello jason.
> 
> if you are using oak you might try the RDBDocumentStore [1] and 
> RDBBlobStore [2] implementation (i've never used them myself).
> 
> for using a lightweight approach accessing a RDBMS directly from a 
> resource provider the is no support currently afaik.
> if you are looking for a generic storage of resource data in RDBMS the 
> generic nosql support [3] might be a good starting point (although that 
> is a bit outdated as well and I assume not much used in practice). if 
> you want to write a specific resource provider for a "real data model" 
> stored in RDBMS i did a very rough prototype some years ago, but never 
> used it in real life [4].
> 
> stefan
> 
> [1] 
> http://jackrabbit.apache.org/oak/docs/apidocs/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.html
> [2] 
> http://jackrabbit.apache.org/oak/docs/apidocs/org/apache/jackrabbit/oak/plugins/document/rdb/RDBBlobStore.html
> [3] 
> https://sling.apache.org/documentation/bundles/nosql-resource-providers.html
> [4] https://adapt.to/2012/en/schedule/apache-sling-rdbms-mapping.html
> 
> 
> >-Original Message-
> >From: Jason E Bailey [mailto:j...@apache.org]
> >Sent: Tuesday, May 1, 2018 9:48 PM
> >To: users@sling.apache.org
> >Subject: SQL Resource Provider?
> >
> >Has anyone ever used a SQL resource provider or know where I can find such
> >a thing?
> >
> >- Jason
> 


Re: SQL Resource Provider?

2018-05-03 Thread Jason E Bailey
I'd be in a little bit of a better situation.  My team would be the ones 
creating the widgets that interact with it. Have to say, over the last couple 
of years there's been an attempt to abstract the JCR part of the 
ResourceProvider out and focus more on resources which I take as a good sign

- Jason

On Wed, May 2, 2018, at 4:02 PM, Daniel Klco wrote:
> I've been down the path BTW Jason, fun may not be the best description ;-)
> Granted this was about 4 years ago now so who knows what has changed. The
> biggest problem I had, by far, was that the proprietary API I needed to use
> was based on the assumption that it was dealing with JCR backed resources.
> 
> On Wed, May 2, 2018 at 8:33 AM, Jason E Bailey <j...@apache.org> wrote:
> 
> > Thought that would be the answer. I'll check out the prototype, thanks.
> >
> > It'll be fun to write a ResourceProvider for this but it's going to have
> > to go to the bottom of my current list of things to get done in
> > Sling.
> >
> > - Jason
> >
> > On Wed, May 2, 2018, at 6:08 AM, Stefan Seifert wrote:
> > > hello jason.
> > >
> > > if you are using oak you might try the RDBDocumentStore [1] and
> > > RDBBlobStore [2] implementation (i've never used them myself).
> > >
> > > for using a lightweight approach accessing a RDBMS directly from a
> > > resource provider the is no support currently afaik.
> > > if you are looking for a generic storage of resource data in RDBMS the
> > > generic nosql support [3] might be a good starting point (although that
> > > is a bit outdated as well and I assume not much used in practice). if
> > > you want to write a specific resource provider for a "real data model"
> > > stored in RDBMS i did a very rough prototype some years ago, but never
> > > used it in real life [4].
> > >
> > > stefan
> > >
> > > [1]
> > > http://jackrabbit.apache.org/oak/docs/apidocs/org/apache/jac
> > krabbit/oak/plugins/document/rdb/RDBDocumentStore.html
> > > [2]
> > > http://jackrabbit.apache.org/oak/docs/apidocs/org/apache/jac
> > krabbit/oak/plugins/document/rdb/RDBBlobStore.html
> > > [3]
> > > https://sling.apache.org/documentation/bundles/nosql-resourc
> > e-providers.html
> > > [4] https://adapt.to/2012/en/schedule/apache-sling-rdbms-mapping.html
> > >
> > >
> > > >-Original Message-
> > > >From: Jason E Bailey [mailto:j...@apache.org]
> > > >Sent: Tuesday, May 1, 2018 9:48 PM
> > > >To: users@sling.apache.org
> > > >Subject: SQL Resource Provider?
> > > >
> > > >Has anyone ever used a SQL resource provider or know where I can find
> > such
> > > >a thing?
> > > >
> > > >- Jason
> > >
> >


Re: Detecting whether a job has been stopped by the user but JobExecutor hasn't terminated yet?

2018-08-18 Thread Jason E Bailey
I believe I understand what you are looking for. It's an event that you are  
look for that will indicate that the job has been requested to stop, but not 
necessarily stopped.

I haven't looked at the code in question but a job should be persisting it's 
state in the JCR. Whenever a change to the JOB STATUS occurs there's an OSGi 
event triggered because a property has been modified. 

If there was  a status change to indicate that the job is in the process of 
stopping that would provide two avenues of reporting. The first would be the 
ability to monitor for an event that that state has been initiated, the other 
would be generating a view of the jobs where it would be clear that a JOB is in 
a stopping, and not yet stopped, state and you could see how long it was in 
that state by the last modified time.

- Jason

On Tue, Aug 14, 2018, at 4:02 PM, John Logan wrote:
> 
> 
> Hi,
> 
> In essence I'm trying to detect the in-progress state of a job being stopped.
> 
> I see in the sling-event implementation that calling 
> jobHandler.stopJobById() eventually works its way down to calling 
> jobHandler.stop(), setting a flag in the JobHandler.
> 
> The JobExecutor is responsible for calling 
> jobExecutionContext.isStopped(), and if it returns true, the JobExecutor 
> should clean up, call  and exit.
> 
> There might be some time elapsed between the request to stop and the 
> JobExecutor returning the JobExecutionResult that updates job state.  Is 
> there a way to detect this interim condition via sling-event-api?  I had 
> a look at the code and didn't see anything obvious.
> 
> What I'm trying to do is indicate in my UI that a job is being 
> cancelled, but cancellation isn't complete yet.
> 
> Thanks!  John


Re: RMI based ResourceProvider

2018-06-29 Thread Jason E Bailey
I understand what you're saying, it would be problematic to execute an RMI call 
for every request of a property :(  you're talking the same type of batching 
that the filevault uses. I could implement a custom ResourceProvider to do this 
but not all ResourceProviders are equal and it would be great to do this via a 
JCR implementation.



- Jason

On Thu, Jun 28, 2018, at 5:18 AM, Bertrand Delacretaz wrote:
> Hi Jason,
> 
> On Wed, Jun 27, 2018 at 11:57 PM Jason E Bailey  wrote:
> > ...I was thinking, wouldn't it be cool if I had a ResourceProvider which
> > was a connected via RMI to a JCR Resource Provider for a specific path...
> 
> I'm not sure if Oak still provides an RMI interface, but Jackrabbit did.
> 
> In general, the problem with RMI access to JCR is that it's very
> chatty due to the low granularity of JCR, which can hinder
> performance.
> 
> I've been thinking for a while that a remote ResourceProvider that
> aggregates Resources in larger chunks might be useful, using
> micro-trees that can represent a website page for example, based on
> the properties and resource types that define the micro-tree
> boundaries. In this way you'd reduce the granularity to improve
> performance.
> 
> That's probably much more complicated than what you are after though,
> just wanted to mention it as food for thought.
> 
> -Bertrand


Re: [question] 2 sling instances behind one apache server sharing 1 session

2018-12-11 Thread Jason E Bailey
I'm going to start talking and saying things, and if I come across like I'm 
being pedantic I apologize in advance :)

First, when we talk about logging in, we're talking about cookies. A cookie is 
used to identify a Session or store user credentials. You can't have a server 
side session or login without some form of cookie.

In the case that you are describing a cookie that is assigned to the URL will 
be accessible by both servers, because regardless of the number of servers 
being used, the client see's only one end point.  So putting a cookie on 
cms.example.org will be accessible from all instances that are serving content 
for that URL.

So a SSO solution is overkill in this scenario. Single Sign On is good for 
logging into multiple URL's at once where once cookies have to be created 
multiple times.

It comes back to what the multiple instances know. 

What I mean by that, does the content server know the user's and groups 
associated with the users? Does it do fine grain permission? Or does it really 
need to know is that this request is a logged in user or not?

Scenario:
Content server only needs to know that the request is a logged in user or not - 
When the user Logs in he get's a cookie that contains an encrypted string with 
an expiration date,  maybe an IP address. There is then a common secret key 
used between the back end servers that the content server only needs to check 
to see that the cookie is a valid cookie.

Scenario
Content server not only needs to know that it's a valid cookie, but that the 
user is Joe and Joe is part of the User group and the user group is only 
permitted to know certain sections of the site. In that case you have the 
option of encoding additional information into the encrypted cookie or you have 
the cookie be a UUID that can reference another backend service that actually 
provides the details that I just mentioned. Which could then be cached for the 
life of the login.

Does any of that help?
- Jason

On Sun, Dec 9, 2018, at 9:41 AM, Ruben Reusser wrote:
> Jason,
> 
> sorry, I should have been clear about what I am looking for
> 
> 1 apache server, 1 domain name (say cms.example.org)
> 2 sling instances (either on 2 servers or 2 different ports)
> 
> from a user point of view I'd like to log in to cms.example.org and be 
> fully logged in to both sling instances (eg same full sling user on both 
> systems)
> 
> one way of course would be to use an sso solution
> another one would be that the authentication session in sling can be 
> shared between multiple instances
> 
> what I am trying to get to is the following:
> 
> - my cms uses one instance for the admin shell
> - we use client side rendering for the admin shell
> - content is stored in another instance
> 
> This approach should allow me to upgrade my admin shell (the whole admin 
> UI) without having to upgrade the instance containing the customer 
> content. It also would isolate each customer (or tenant) onto their own 
> (smaller) sling instance with their own JVM and hence allow for better 
> vertical or horizontal scaling
> 
> Ruben
> 
> 
> Hi Ruben,
> 
> Can you clarify some, when you say two tenants, is this two separate 
> domains ? And when you talk about being logged in, are yu controlling 
> access or just validating that someone is logged in or not, i.e. being 
> able to access information based on a user id.
> 
> - Jason
> [show/hide original text]
> On Sun, Dec 2, 2018, at 10:04 AM, Ruben Reusser wrote: > hi there, > > I 
> have been trying to do the following: 1 apache http server, 2 sling > 
> instances. /tenant1 goes to sling instance number 1, tenant 2 goes to > 
> sling instance number 2. If I log in I'd love to be logged in to all > 
> sling instances, preferably not with a cookie for each tenant. Would > 
> love to hear suggestions in what direction I should concentrate my > 
> effort to achieve my goal here! > > thank you > > Ruben >
> 


Re: [question] 2 sling instances behind one apache server sharing 1 session

2018-12-04 Thread Jason E Bailey
Hi Ruben,

Can you clarify some, when you say two tenants, is this two separate domains ? 
And when you talk about being logged in, are yu controlling access or just 
validating that someone is logged in or not, i.e. being able to access 
information based on a user id.

- Jason

On Sun, Dec 2, 2018, at 10:04 AM, Ruben Reusser wrote:
> hi there,
> 
> I have been trying to do the following: 1 apache http server, 2 sling 
> instances. /tenant1 goes to sling instance number 1, tenant 2 goes to 
> sling instance number 2. If I log in I'd love to be logged in to all 
> sling instances, preferably not with a cookie for each tenant. Would 
> love to hear suggestions in what direction I should concentrate my 
> effort to achieve my goal here!
> 
> thank you
> 
> Ruben
> 


Re: ContentLoader Import problem

2018-12-07 Thread Jason E Bailey
That would be a great addition.  It may be hard to change the existing options 
as that could break downstream use cases but I'm sure there's ways of updating 
this. I took a look at the code and I'm not familiar enough with oak in this 
use case to make that change. 



- Jason

On Thu, Dec 6, 2018, at 2:43 PM, Eric Norman wrote:
> Hi Jason,
> 
> I would think the ContentLoader could be enhanced to provide more granular
> import logic than the "overwrite" and "overwriteProperties" directives
> provide.
> 
> For a point of comparison, in a previous (non-sling) project I worked on we
> had a similar mechanism for importing content into a taxonomy.  The
> solution we ended up with for this kind of problem was to have a mechanism
> to specify an import sync mode that changed how the new information was
> interpreted.
> 
> For example, the import "sync mode" could be set to something like this
> with a directive (or with a special tag within the content itself):
> 
>- default - merge the new content into the existing taxonomy overwriting
>anything existing at the same location
>- update - merge the new content into the existing taxonomy by
>overwriting/updating existing content but don't create anything that
>doesn't already exist
>- add - merge the new content into the existing taxonomy but don't add
>or update any items that already exist
>- sync - same as "default" but remove all nodes from each of the parent
>nodes if there is no equivalent item in the new content.
> 
> 
> Regards,
> Eric
> 
> On Thu, Dec 6, 2018 at 10:44 AM Jason E Bailey  wrote:
> 
> > We've set up a process to import content into our Sling instance and
> > we're running into a problem with the ContentLoader.
> > The use case is that a set of data that is managed in another part of
> > our company is being provided to us in the form of a JSON object for
> > loading into our Sling environment.
> > This works. However, this content changes daily, sometimes properties
> > will change and sometimes node structure.
> > We don't want to say "overwrite" because that causes the entire tree
> > structure to be deleted which is really intensive, however if we
> > don't say "overwrite" then nodes that are removed from the import
> > continue to exist.
> > Effectively what we need is a delta, we want to delete nodes if they
> > aren't in the import but otherwise leave it alone, the same thing with
> > properties.
> > Which, unless I'm missing something, is not a function the
> > importer supports. Has anyone had to deal with this? Maybe used a
> > different process?
> > Thanks
> > - Jason
> >
> >
> >


ContentLoader Import problem

2018-12-06 Thread Jason E Bailey
We've set up a process to import content into our Sling instance and
we're running into a problem with the ContentLoader.
The use case is that a set of data that is managed in another part of
our company is being provided to us in the form of a JSON object for
loading into our Sling environment.
This works. However, this content changes daily, sometimes properties
will change and sometimes node structure.
We don't want to say "overwrite" because that causes the entire tree
structure to be deleted which is really intensive, however if we
don't say "overwrite" then nodes that are removed from the import
continue to exist.
Effectively what we need is a delta, we want to delete nodes if they
aren't in the import but otherwise leave it alone, the same thing with
properties.
Which, unless I'm missing something, is not a function the
importer supports. Has anyone had to deal with this? Maybe used a
different process?
Thanks
- Jason




How do you identify the original content path of a request?

2018-09-17 Thread Jason E Bailey
I'm dealing with resources requests that have suffixes. 

When I'm at a component level, I'm trying to identify what the original
content path/ resource  is and there doesn't seem to be a way to do it.
Is anyone aware of a graceful way of doing this?

Thanks
- Jason




Re: Content Security Policy Headers

2020-01-10 Thread Jason E Bailey
I should have been more specific. I have a security person who wants us to 
remove the unsafe-inline for the javascript.
This has taken up so much of my focus that I forget all about the rest of it.

To pull off the removal of the unsafe-inline you have to use hashes for the 
javascript or a nonce that changes every time you request the page. This is 
where my mind starts to explode.

--
Jason

On Fri, Jan 10, 2020, at 2:13 PM, Daniel Klco wrote:
> Jason,
> 
> Rather than putting the headers in Sling, I'd recommend supplying the CSP
> in your caching (httpd etc) layer. Something like this:
> 
> Header set X-Frame-Options "ALLOW-FROM https://launch.adobe.com;
> 
>Header set X-XSS-Protection "1; mode=block"
> 
>Header set X-Content-Type-Options "nosniff"
> 
>Header set Feature-Policy "sync-xhr 'self' https://www.danklco.com;
> 
>Header set Content-Security-Policy "default-src https: data:
> 'unsafe-inline'"
> 
> 
> I use this on my personal site and have an A rating:
> https://securityheaders.com/?q=https%3A%2F%2Fwww.danklco.com%2F
> 
> Regards,
> Dan
> 
> 
> On Fri, Jan 10, 2020 at 12:26 PM Jason E Bailey  wrote:
> 
> > If you're not familiar with them
> >
> > https://tools.ietf.org/html/rfc7231
> > https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
> >
> > I'm wondering if anyone has used the CSP to secure javascript and styles
> > successfully in Sling and what techniques did they use to get there.
> >
> > I'm about to raise an issue with our vendor because of lack of support,
> > but I like to try to avoid tickets if necessary.
> >
> > - Jason
> >
>


Content Security Policy Headers

2020-01-10 Thread Jason E Bailey
If you're not familiar with them

https://tools.ietf.org/html/rfc7231
https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP

I'm wondering if anyone has used the CSP to secure javascript and styles 
successfully in Sling and what techniques did they use to get there.

I'm about to raise an issue with our vendor because of lack of support, but I 
like to try to avoid tickets if necessary. 

- Jason