Re: Not-sticky sessions with Sling?

2017-01-11 Thread Chetan Mehrotra
If you are running a cluster with Sling on Oak/Mongo then sticky
sessions would be required due to eventual consistent nature of
repository. Changes done on one cluster node would not be immediately
visible on other cluster node. Hence to provide a consistent user
experience sticky sessions would be required
Chetan Mehrotra


On Thu, Jan 12, 2017 at 7:34 AM, lancedolan  wrote:
> The only example code I can find to authenticate to Sling will use the JEE
> servlet container's "j_security_check" which then stores the authenticated
> session in App Server memory. A load-balancer without sticky-sessions
> enabled will cause an unstable experience for users, in which they are
> suddenly unauthenticated.
>
> -Does Sling already offer a mechanism for authenticating without storing
> that JCR session in Servlet Container Session?
> -Do any of you avoid sticky sessions without writing custom code?
>
> I'm thinking that this problem *must* be solved already. Either there's an
> authenticationhandler in Sling that I haven't found yet, or there's an
> open-source example that somebody could share with me :)
>
> If I must write this myself, is this the best place to start?
> https://sling.apache.org/documentation/the-sling-engine/authentication/authentication-authenticationhandler.html
> https://sling.apache.org/apidocs/sling8/org/apache/sling/auth/core/spi/AuthenticationHandler.html
>
> ... as usual, thanks guys. I realize I'm really dominating the mail list
> lately. I've got a lot to solve :)
>
>
>
>
> --
> View this message in context: 
> http://apache-sling.73963.n3.nabble.com/Not-sticky-sessions-with-Sling-tp4069530.html
> Sent from the Sling - Users mailing list archive at Nabble.com.


Re: How to change run mode in Sling8

2017-01-11 Thread lancedolan
Ok that makes sense. It sounds like developing a new codebase *based on* the
launchpad might be my next step. I guess the launchpad is really an example,
and not intended to be deployed to production as provided from the war
download link here: https://sling.apache.org/downloads.cgi.

I guess downloading and copying the source for the software I want to use
and just using that as the basis for my own custom version of that software
just feels like a bad development practice. Like, how do I upgrade to future
versions of Sling? By respecting the Sling war as a deployable artifact, I
could just swap in future version in our provisioning scripts. I feel like
there are other examples of how that's awkward as well, but it's late and
I'm getting foggy hah.

If the war file provided as a release isn't intended to be more than an
example, copying and modifying the source is the way Sling is intended to be
used by the developers, then fair enough.

This sounds like valuable information for beginning developers that find
https://sling.apache.org. It's easy to get lost.





--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/How-to-change-run-mode-in-Sling8-tp4069494p4069533.html
Sent from the Sling - Users mailing list archive at Nabble.com.


Re: How to change run mode in Sling8

2017-01-11 Thread Justin Edelson
Yes, I mean your application code. In my experience, the actual Sling
launchpad is not very useful by itself except as a learning tool. In any
real-world case, you will end up creating your own launchpad by taking the
standard Sling launchpad and adding additional bundles to it.

And while yes, you can certainly deploy code to a running Sling instance,
the trend seems to be away from this (except for development) and towards
immutable instances.

On Thu, Jan 12, 2017 at 10:52 AM lancedolan  wrote:

> Hmm, my genuine apologies, I'm not sure what custom application bits are.
> If
> you're saying that I can deploy code that I write to Sling, that's
> absolutely true, but my understanding is that I need to change the  runmode
> BEFORE the Sling instance starts up for the very first time, and I can only
> deploy my code to Sling OSGI AFTER the sling instance starts up for the
> very
> first time.
>
> I don't understand how to tell Sling to use oak_mongo instead of oako_tar.
> Might only solution right now is to either unzip the war and change the
> properties file before deploying for the first time, or to branch off the
> Sling source code and rebuild with that property changed. Is this what the
> Sling developers expect of me? It feels hacky. Isn't there a more
> conventional way for me to control my runmodes?
>
>
>
> --
> View this message in context:
> http://apache-sling.73963.n3.nabble.com/How-to-change-run-mode-in-Sling8-tp4069494p4069528.html
> Sent from the Sling - Users mailing list archive at Nabble.com.
>


Re: How to change run mode in Sling8

2017-01-11 Thread Justin Edelson
I would say that's how the creators of JavaEE intended for deployment
options to be specified :)

On Thu, Jan 12, 2017 at 10:53 AM lancedolan  wrote:

> I can look into overriding init params through some servlet container
> features. Is that the way that Sling devs expect me to turn on Mongo
> functionality?
>
>
>
> --
> View this message in context:
> http://apache-sling.73963.n3.nabble.com/How-to-change-run-mode-in-Sling8-tp4069494p4069529.html
> Sent from the Sling - Users mailing list archive at Nabble.com.
>


Not-sticky sessions with Sling?

2017-01-11 Thread lancedolan
The only example code I can find to authenticate to Sling will use the JEE
servlet container's "j_security_check" which then stores the authenticated
session in App Server memory. A load-balancer without sticky-sessions
enabled will cause an unstable experience for users, in which they are
suddenly unauthenticated.

-Does Sling already offer a mechanism for authenticating without storing
that JCR session in Servlet Container Session? 
-Do any of you avoid sticky sessions without writing custom code?

I'm thinking that this problem *must* be solved already. Either there's an
authenticationhandler in Sling that I haven't found yet, or there's an
open-source example that somebody could share with me :) 

If I must write this myself, is this the best place to start? 
https://sling.apache.org/documentation/the-sling-engine/authentication/authentication-authenticationhandler.html
https://sling.apache.org/apidocs/sling8/org/apache/sling/auth/core/spi/AuthenticationHandler.html

... as usual, thanks guys. I realize I'm really dominating the mail list
lately. I've got a lot to solve :)




--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/Not-sticky-sessions-with-Sling-tp4069530.html
Sent from the Sling - Users mailing list archive at Nabble.com.


Re: How to change run mode in Sling8

2017-01-11 Thread lancedolan
I can look into overriding init params through some servlet container
features. Is that the way that Sling devs expect me to turn on Mongo
functionality?



--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/How-to-change-run-mode-in-Sling8-tp4069494p4069529.html
Sent from the Sling - Users mailing list archive at Nabble.com.


Re: How to change run mode in Sling8

2017-01-11 Thread lancedolan
Hmm, my genuine apologies, I'm not sure what custom application bits are. If
you're saying that I can deploy code that I write to Sling, that's
absolutely true, but my understanding is that I need to change the  runmode
BEFORE the Sling instance starts up for the very first time, and I can only
deploy my code to Sling OSGI AFTER the sling instance starts up for the very
first time.

I don't understand how to tell Sling to use oak_mongo instead of oako_tar.
Might only solution right now is to either unzip the war and change the
properties file before deploying for the first time, or to branch off the
Sling source code and rebuild with that property changed. Is this what the
Sling developers expect of me? It feels hacky. Isn't there a more
conventional way for me to control my runmodes?



--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/How-to-change-run-mode-in-Sling8-tp4069494p4069528.html
Sent from the Sling - Users mailing list archive at Nabble.com.


Re: How to change run mode in Sling8

2017-01-11 Thread Justin Edelson
But don't you need your own artifact anyway to include your custom
application bits?

IIRC (and I can't find the code right now), we explicitly *don't* allow for
system properties to be used for sling properties in a webapp case since
multiple webapps can be deployed into the same container.

In any case, servlet containers generally support some mechanism to
override the init parameters in the web.xml file via some external file.
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html explains how to
do this in Tomcat.

Regards,
Justin

On Thu, Jan 12, 2017 at 4:49 AM lancedolan  wrote:

> What is the recommended process for setting that runmode on startup? I'm
> unzipping the war file, changing a properties file, and rezipping it...
> This
> means we'd need to maintain this custom deployment artifact for all of our
> deployments/provisioning, rather than just using Sling's. There must be a
> better way? Perhaps a JVM command line argument I could provide during
> startup that would override what's set in sling_install.properties ?
>
>
>
> --
> View this message in context:
> http://apache-sling.73963.n3.nabble.com/How-to-change-run-mode-in-Sling8-tp4069494p4069523.html
> Sent from the Sling - Users mailing list archive at Nabble.com.
>


RE: JS Use API usability or limitations

2017-01-11 Thread lancedolan
No architectural reason - purely speed of development reasons. Our team has
switched from Java to Node.js on our other projects and are seeing real
gains in dev time. We believe we could see the same faster development with
lightweight JS files as opposed to traditional type-safe Java.

I think this is a popular opinion amongst developers, that JS is faster to
write in than Java? The question currently on the table is whether the
difficulty in debugging esoteric Rhino interactions will negate that speed,
in which case we might as well stick to Java and enjoy stability of type
safety. 



--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/JS-Use-API-usability-or-limitations-tp4069490p4069526.html
Sent from the Sling - Users mailing list archive at Nabble.com.


RE: JS Use API usability or limitations

2017-01-11 Thread Jason Bailey
Alright, I'll bite.

If you're talking about model building logic. Is there some architectural 
constraint on why  you don't just stick with java?

-Jason

-Original Message-
From: lancedolan [mailto:lance.do...@gmail.com] 
Sent: Wednesday, January 11, 2017 2:37 PM
To: users@sling.apache.org
Subject: RE: JS Use API usability or limitations

Thank you for your time everybody! For posterity:

First to clarify, my very specific question is how to iterate an iterable in 
the model-building logic (what us old timers might call a "backing bean"). I do 
already know that I can use HTL to iterate the children, and I do recognize 
that in this contrived example it's a better separation of view/model concerns 
to do so. However I'm going to need to do lots of iterating on resources in my 
"backing beans" as I build model data for increasingly complex objects. Imagine 
a component that searches various parts of the JCR and filters on specific 
properties to generate a heterogenous list of content links... To suggest HTL 
just skirts around my development need in model-building logic.

Vlad's syntax solved my problem. I'd love to understand why. It seems the 
Iterable contains a Map or List objects with a key and resource... Is that due 
to Rhino? The Sling docs say getChildren returns Iterable. I didn't 
expect this.

I'm already feeling the pain of debugging JS Use API, which Stefan has warned 
about, and so did the sling docs on.

I'm concluding that the JS Use API probably isn't ready and requires too much 
esoteric/idiomatic knowledge to give the sort of development speed one would 
expect with JS. I'm going to keep it as an option for very simple components.






--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/JS-Use-API-usability-or-limitations-tp4069490p4069521.html
Sent from the Sling - Users mailing list archive at Nabble.com.


RE: JS Use API usability or limitations

2017-01-11 Thread lancedolan
Thank you for your time everybody! For posterity:

First to clarify, my very specific question is how to iterate an iterable in
the model-building logic (what us old timers might call a "backing bean"). I
do already know that I can use HTL to iterate the children, and I do
recognize that in this contrived example it's a better separation of
view/model concerns to do so. However I'm going to need to do lots of
iterating on resources in my "backing beans" as I build model data for
increasingly complex objects. Imagine a component that searches various
parts of the JCR and filters on specific properties to generate a
heterogenous list of content links... To suggest HTL just skirts around my
development need in model-building logic.

Vlad's syntax solved my problem. I'd love to understand why. It seems the
Iterable contains a Map or List objects with a key and resource... Is that
due to Rhino? The Sling docs say getChildren returns Iterable. I
didn't expect this.

I'm already feeling the pain of debugging JS Use API, which Stefan has
warned about, and so did the sling docs on.

I'm concluding that the JS Use API probably isn't ready and requires too
much esoteric/idiomatic knowledge to give the sort of development speed one
would expect with JS. I'm going to keep it as an option for very simple
components.






--
View this message in context: 
http://apache-sling.73963.n3.nabble.com/JS-Use-API-usability-or-limitations-tp4069490p4069521.html
Sent from the Sling - Users mailing list archive at Nabble.com.


Market Research - Request For Information: Apache Sling Professional Services

2017-01-11 Thread Ravindra Singareddy
Hello Experts,

We are a very small company and starting to propose Apache Sling based 
solutions for budget clients. I would like to know any small company 
(professionals) provides Apache Sling architectural review and yearly 
production support plans?


you can send email response to

ravi (at) singareddy (dot) com


Thanks a lot


Ravi Singareddy

Singareddy, Inc


Re: How to change run mode in Sling8

2017-01-11 Thread Julian Sedding
Why are you running the war file on Tomcat? It's not wrong of course.
However, I believe that most users use the standalone jar and
therefore help may be more readily available for that setup.

Regards
Julian


On Wed, Jan 11, 2017 at 4:19 AM, lancedolan  wrote:
> I cannot change run mode using the process I have in the past, with Sling8.
>
> The only thing that has worked for me was to crack open the
> org.apache.sling.launchpad-8-webapp.war file, crack open the oak jar file
> within it, edit sling_install.properties
> (sling.run.mode.install.options=oak|oak_mongo), and then zip it all back up
> again. This feels _wrong_ haha.
>
> Things I tried, which failed:
>
> -The Apache Sling Settings Service in OSGI console. It even says "The
> settings service manages some basic settings of Sling like run modes."
> However, there is no run mode config there.
>
> -JVM arguments. I've tried -Dsling.run.mode.options=oak,oak_mongo and
> -Dsling.run.modes=oak,oak_mongo. No luck.
>
> -Searched for other configurations in the configMgr console.
>
> How do I just tell a Sling instance to stop running oak_tar and start
> running oak_mongo?
>
>
>
> --
> View this message in context: 
> http://apache-sling.73963.n3.nabble.com/How-to-change-run-mode-in-Sling8-tp4069494.html
> Sent from the Sling - Users mailing list archive at Nabble.com.


Re: JS Use API usability or limitations

2017-01-11 Thread Vlad Bailescu
Hi Lance!

The problem is not the JS Use API but the way the JS Iterator is used. One
should do:

for (var [key, res] in Iterator(children)) {
returnObj.content += res.name;
}

Also, Robert is right, you should strive to keep your business logic (use
objects) as light as possible do the iterating and rendering in the HTL
script, if possible.

Best,
Vlad

On Wed, Jan 11, 2017 at 1:00 PM, Robert Munteanu  wrote:

> Hi,
>
> On Tue, 2017-01-10 at 18:29 -0700, lancedolan wrote:
> > All I want to do is print out a resource's children resources.
>
> Using the HTL repl [1] I narrowed down the following way of listing
> child resources:
>
> template.html
> -
>
> 
> 
> ${properties.jcr:title}
> 
> 
> 
>
> My siblings are:
> 
> ${child.name}
> 
> 
>
> 
> 
>
> logic.js
> 
>
> use(function () {
> return {
> siblings: resource.getParent().getChildren()
> };
> });
>
> I don't know enough about the HTL Javascript Use API to see what is
> wrong in your particular example unfortunately.
>
> Robert
>
>
> [1]: http://localhost:8080/htl/repl.html
>


Re: JS Use API usability or limitations

2017-01-11 Thread Robert Munteanu
Hi,

On Tue, 2017-01-10 at 18:29 -0700, lancedolan wrote:
> All I want to do is print out a resource's children resources.

Using the HTL repl [1] I narrowed down the following way of listing
child resources:

template.html
-



${properties.jcr:title}




My siblings are:

${child.name}






logic.js


use(function () {
return {
siblings: resource.getParent().getChildren()
};
});

I don't know enough about the HTL Javascript Use API to see what is
wrong in your particular example unfortunately.

Robert


[1]: http://localhost:8080/htl/repl.html


RE: JS Use API usability or limitations

2017-01-11 Thread Stefan Seifert
i've not tested your example but by reading the code i would say it should work 
like this conceptually.

i think there is no "community consensus" on using the JS use API or not. i 
personally would advise to not use it for non-trivial tasks, because it creates 
a unhealthy combination of javascript and java objects within the JS logic with 
often unexpected results even on simple thinks like string operations because 
you often do not know exactly if you have a js stirng or a java string object. 
it's also quite difficult to debug in this cases. my recommendation is to go 
with sling models and unit tests.

stefan


>-Original Message-
>From: lancedolan [mailto:lance.do...@gmail.com]
>Sent: Wednesday, January 11, 2017 2:30 AM
>To: users@sling.apache.org
>Subject: JS Use API usability or limitations
>
>I've got years of experience writing backing beans for Sling (aem)
>components, but can't seem to get a simple JS backing working using the
>new
>Javascript Use API.
>
>All I want to do is print out a resource's children resources.
>
>My JS backing bean:
>
>use([], function () {
>
> var returnObj = {
>content: ""
>};
>
>  var parent = resource.parent;
>  var children = parent.getChildren();
>
>  for (res in Iterator(children)) {
>   returnObj.content += res.name;
>  }
>
>return returnObj;
>});
>
>The contents of returnObj.content will be the word "undefined" repeated
>X
>times, where X is the number of children nodes of parent. This tells me
>it
>successfully iterates the Iterable once for each item in it, but it's
>failing to give me a reference to a child. If I try res.getName()
>instead, I
>get:
>
>org.mozilla.javascript.EcmaError: TypeError: Cannot find default value
>for
>object
>
>In fact, every single variation I've tried for iterating that collection
>has
>lead to that exact Exception.
>
>It seems to me Rhino is getting in the way. Am I right? What is the
>community consensus on use of the JS Use API? Is it production-ready and
>stable? Is my problem a user-error? What limitations exist here? I was
>planning on doing the same things in JS that I've always done in Java,
>which
>is usually a lot of read/write operations on the JCR.
>
>
>
>--
>View this message in context: http://apache-
>sling.73963.n3.nabble.com/JS-Use-API-usability-or-limitations-
>tp4069490.html
>Sent from the Sling - Users mailing list archive at Nabble.com.