authentication with anonymous access enabled

2013-08-02 Thread Oliver Lietz
hello all,

I'm porting an application from Vaadin to Sling using HTML and a custom Sling 
Servlet (service with property sling.servlet.paths).
This works fine, but securing this application with HTTP Basic Authentication 
Handler does not work.

- Allow Anonymous Access is enabled (in Apache Sling Authentication Service 
configuration)

- Authentication Requirements is empty (in Apache Sling Authentication Service 
configuration)

- HTTP Basic Authentication Handler is the only handler and registered for 
path /

- the custom servlet sets sling.auth.requirements to {+/services/myservlet, 
+/content/myapp} (myapp contains the HTML in JCR, no ACLs changed)

- Authenticator (slingauth) shows Authentication Required Yes for 
/services/myservlet and /content/myapp and No for / (and also No for 
/system/sling/logout, /system/sling/login, /server)

I expect the browser to ask for username and password when accessing 
/content/myapp and /services/myservlet, but that does not happen.
What is missing? Is this intended behavior or a bug (same behavior on current 
Sling and CQ 5.5)?

thanks,
O.


[security issue] Re: authentication with anonymous access enabled

2013-08-06 Thread Oliver Lietz
Am Freitag, 2. August 2013 schrieb Oliver Lietz:
 Am Freitag, 2. August 2013 schrieb Felix Meschberger:
  Hi

hello all,

 hello Felix,
 
  I would assume the Sling Authentication Service has HTTP Basic
  Authentication enabled with preemptive support. This means a 401 response
  is never sent. Reconfiguring the Authentication Service to fully enable
  HTTP Basic Authentication should do the trick.
 
 it's already configured with full support. Any other idea?

I tracked it down to pathInfo always being null in SlingAuthenticator. Instead 
of getPathInfo() getServletPath() should be used in all places. See 
SLING-2998.

Regards,
O.

 Regards,
 O.
 
  Hope this helps.
  
  Regards
  Felix
  
  Am 02.08.2013 um 13:38 schrieb Oliver Lietz:
   hello all,
   
   I'm porting an application from Vaadin to Sling using HTML and a custom
   Sling Servlet (service with property sling.servlet.paths).
   This works fine, but securing this application with HTTP Basic
   Authentication Handler does not work.
   
   - Allow Anonymous Access is enabled (in Apache Sling Authentication
   Service configuration)
   
   - Authentication Requirements is empty (in Apache Sling Authentication
   Service configuration)
   
   - HTTP Basic Authentication Handler is the only handler and registered
   for path /
   
   - the custom servlet sets sling.auth.requirements to
   {+/services/myservlet, +/content/myapp} (myapp contains the HTML in
   JCR, no ACLs changed)
   
   - Authenticator (slingauth) shows Authentication Required Yes for
   /services/myservlet and /content/myapp and No for / (and also No for
   /system/sling/logout, /system/sling/login, /server)
   
   I expect the browser to ask for username and password when accessing
   /content/myapp and /services/myservlet, but that does not happen.
   What is missing? Is this intended behavior or a bug (same behavior on
   current Sling and CQ 5.5)?
   
   thanks,
   O.



Re: App Server Deployment Help

2014-07-11 Thread Oliver Lietz
On Friday 11 July 2014 12:54:49 Alex Renger wrote:
 Hello Carsten,

hello Alex,

 I get the same 404 error when I try to access the base URL
 (http://localhost:8080/sling).  For clarification/confirmation, here's
 how to reproduce what I'm seeing:
 
 1. Get the latest source from subversion
 2. rm -fr ~/.m2/repository #just to be sure i'm working with the latest
 stuff) 3. set sling.home in the
 launchpad/base/src/main/webapp/WEB-INF/web.xml file such that it
 points to my sling/launchpad/base directory
 4. mvn clean install (from the main sling directory; that of the
 sling-builder project)
 5. move org.apache.sling.launchpad.base-4.4.0-2.5.1-SNAPSHOT-webapp.war
 from launchpad/base/target to launchpad/base and call it sling.war
 6. also move org.apache.sling.launchpad.base-4.4.0-2.5.1-SNAPSHOT.jar
 up one directory and call it org.apache.sling.launchpad.base.jar.
 7. deploy sling.war in a web container
 
 There are more steps here than are mentioned in the wiki for apache
 sling web app deployment, but this is the only way I could get it to
 deploy.  The webapp war apparently needs to be able to find the
 org.apache.sling.launchpad.base.jar file, which is why I set
 sling.home to the directory in which it can be found.
 
 After your latest change, the above procedure deploys the app without
 any errors in the server.log file, but returns 404 status from all
 http requests.

please start from scratch as described at 
https://cwiki.apache.org/confluence/display/SLING/App+Server+Deployment and 
use the *org.apache.sling.launchpad-7-SNAPSHOT.war* from 
launchpad/builder/target.

Regards,
O.
 
 Alex
[...]


Re: App Server Deployment Help

2014-07-13 Thread Oliver Lietz
On Friday 11 July 2014 14:17:29 Alex Renger wrote:
 Hello Oliver,

hello Alex,

 Thank you for your attempt to help and for the suggestion.  However,
 you'll note from earlier in this thread that I referenced those same
 instructions.  Unless there were recent changes to the sling baseline
 (i.e., within the past 24 hours) related to webapp deployment, then I
 would expect to run into the same problems I've had when following
 those steps.
 
 That is to say, I have indeed started from scratch multiple times and
 followed those instructions -- but upon deployment it reports an error
 that org.apache.sling.launchpad.base.jar cannot be found.  When I
 get past that problem (by setting sling.home in the web.xml file to a
 directory where said file is located), it deploys without error but
 returns 404.

it works with GlassFish 4 on OS X 10.9.4 with JDK 7u60 OOTB:

$ ./asadmin start-domain
Waiting for domain1 to start 
Successfully started the domain : domain1
domain  Location: /[...]/glassfish4/glassfish/domains/domain1
Log File: /[...]/glassfish4/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.
$ ./asadmin deploy /[...]/sling.war
Application deployed with name sling.
Command deploy executed successfully.
$ curl -u admin:admin -Fsling:resourceType=foo/bar -Ftitle=some title 
http://localhost:8080/sling/content/mynode
html
head
titleContent created /content/mynode/title
/head
body
h1Content created /content/mynode/h1
table
tbody
tr
tdStatus/td
tddiv id=Status201/div/td
/tr
tr
tdMessage/td
tddiv id=MessageCreated/div/td
/tr
tr
tdLocation/td
tda href=/sling/mynode 
id=Location/sling/mynode/a/td
/tr
tr
tdParent Location/td
tda href=/sling/content 
id=ParentLocation/sling/content/a/td
/tr
tr
tdPath/td
tddiv id=Path/content/mynode/div/td
/tr
tr
tdReferer/td
tda href= id=Referer/a/td
/tr
tr
tdChangeLog/td
tddiv 
id=ChangeLoglt;pregt;created(quot;/contentquot;);lt;br/gt;created(quot;/content/mynodequot;);lt;br/gt;modified(quot;/content/mynode/sling:resourceTypequot;);lt;br/gt;modified(quot;/content/mynode/titlequot;);lt;br/gt;lt;/pregt;/div/td
/tr
/tbody
/table
pa href=Go Back/a/p
pa href=/sling/mynodeModified Resource/a/p
pa href=/sling/contentParent of Modified Resource/a/p
/body
/html


Regards,
O.

 Alex
[...]


Re: App Server Deployment Help

2014-07-14 Thread Oliver Lietz
On Monday 14 July 2014 13:30:36 Alex Renger wrote:
 Good Morning Oliver,

hi Alex,

 I gave it another try this morning, just for good measure.
 
 $ rm -fr sling
 $ svn co http://svn.apache.org/repos/asf/sling/trunk sling
 $ mvn -DskipTests clean install
 # this fails, so I had to revert to r1609744
 $ svn update -r r1609744
 $ mvn -DskipTests clean install
 # BUILD SUCCESS
 $ cp
 launchpad/base/target/org.apache.sling.launchpad.base-4.4.0-2.5.1-SNAPSHOT
 -webapp.war /tmp/sling.war
 $ asadmin deploy /tmp/sling.war
 Application deployed with name sling.
 Command deploy executed successfully.
 # However, server.log reports:
 [#|2014-07-14T07:07:55.758-0400|SEVERE|oracle-glassfish3.1.2|javax.enterpri
 se.system.container.web.com.sun.enterprise.web|_ThreadID=17;_ThreadName=Thr
 ead-2;|WebModule[/sling]sling: Cannot load Launcher Servlet
 org.apache.sling.launchpad.base.webapp.SlingServletDelegate
 java.lang.IllegalArgumentException: Sling Launcher JAR
 /media/homespace/glassfish3/glassfish/domains/domain1/config/sling/_sling/o
 rg.apache.sling.launchpad.base.jar is not accessible
   at
 org.apache.sling.launchpad.base.shared.Loader.loadLauncher(Loader.java:104
 ) at
 org.apache.sling.launchpad.webapp.SlingServlet.startSling(SlingServlet.jav
 a:363) at
 org.apache.sling.launchpad.webapp.SlingServlet.startSling(SlingServlet.jav
 a:325) ...
 
 For what it's worth, note that I am using debian linux
 (3.2.60-1+deb7u1 x86_64), openJdk 6, maven 3, and glassfish 3.

why are you not using org.apache.sling.launchpad-7-SNAPSHOT.war?

Regards,
O.

 Alex
[...]


Re: App Server Deployment Help

2014-07-15 Thread Oliver Lietz
On Monday 14 July 2014 23:03:03 Alex Renger wrote:
 Whew -- good catch Oliver!  I'm not using said war file because
 somewhere in my wanderings through sling directories I came to confuse
 base with builder.  They both contain target directories, each
 with similar wars and jars that are refreshed during maven clean
 install... and this whole deal is new to me.
 
 Anyway, when I deploy the war file from the BUILDER directory, it
 works fine.  Thank you!

See my first reply from Friday.

O.

 Alex
 
 PS. It deploys fine with glassfish, not jboss -- but whatever, that's
 a totally different question.  The above question is resolved, and I
 marked it as such on stackoverflow, too.  Thanks guys.
[...]


Re: Defining new content types and associated import actions

2014-12-06 Thread Oliver Lietz
On Saturday 06 December 2014 08:00:41 Felix Meschberger wrote:
 Hi Bruce

hi,

 I think you are on the right track. ContentReader would probably help
 solving your problem.
 
 Yet, for now the content loader is not extensible — by intent because we
 didn’t have a need for making it extensible so far and we were not sure
 about how to do it.
 
 This might be a good opportunity, though, to do it.
 
 Quickly glancing through the code, I’d think that …
 
 * we create a new org.apache.sling.contentloader.reader package to be
 exported at version 1.0 * move the ContentCreator (@ProviderType) and
 ContentReader (@ConsumerType) to that new package * convert the
 BaseImportLoader into a standalone ContentReader service holder used by
 the DefaultContentImporter and ContentLoaderService components. * For the
 ContentReader service interface we define service registration properties
 for the service to expose the file name extension (and maybe content type)
 the reader supports.
 
 WDYT ?

we have some improvement issues open [1] for content loader, I will do some 
experimenting in my whiteboard area including Felix ideas.

Regards,
O.

[1] SLING-3533, SLING-3534, SLING-3535, SLING-3619

 Regards
 Felix
 
  Am 06.12.2014 um 06:32 schrieb Bruce Edge
  bruce.e...@nextissuemedia.com:
  
  After digging around in the sling code a bit I found the ContentReader
  interface, with Json, Zip, and XML reader classes. This looks looks like
  the right option, IOW implement a new ContentReader class for my data
  type.
  
  The one remaining question is, how does this tie in with the content type
  detection on the front end?
  
  I am setting up the mimeType for this extension already:
  mimeTypeService.registerMimeType(application/vnd.adobe.folio+zip,
  folio);
  
  but what else do I need to do to invoke the new ContentReader once this
  mimeType is detected?
  
  I see the existing loaders are all defined in BaseImportLoader. Is there
  an API to append new extension/loader mappings to this?
  
  -Bruce
  
  From: Bruce Edge
  bruce.e...@nextissuemedia.commailto:bruce.e...@nextissuemedia.com
  Reply-To: users@sling.apache.orgmailto:users@sling.apache.org
  users@sling.apache.orgmailto:users@sling.apache.org Date: Thursday,
  December 4, 2014 at 2:00 PM
  To: users@sling.apache.orgmailto:users@sling.apache.org
  users@sling.apache.orgmailto:users@sling.apache.org Subject:
  Defining new content types and associated import actions
  
  I keep finding that I’m doing things the hard way and that someone has
  already thought of this and has implemented something far better than my
  current attempt. Therefore I have to ask this question.
  
  I need to import content with a well defined structure adobe multi-folio
  archives. These are zip files consisting of an xml content descriptor, a
  mime type file and a number of child folio archives.
  
  Folio.xml
  mimetype
  _Cover.folio
  0001_article_xx.folio
  0002_artivle_yy.folio
  …
  
  The mime type contains:
  application/vnd.adobe.folio+zip%
  
  
  where each child .folio file is a zip consisting of another folio.xml
  descriptor file and additional media files:
  ├── Folio.xml
  ├── META-INF
  │   └── pkgproperties.xml
  ├── StackResources
  │   ├── asset_L.pdf
  │   ├── asset_P.pdf
  │   ├── scrubber_L1.jpg
  │   ├── scrubber_P1.jpg
  │   ├── thumb_L1.jpg
  │   ├── thumb_P1.jpg
  │   └── toc.jpg
  └── mimetype
  
  Is it possible to define a new content type for each of these, the parent
  multi-folio and the child folio structures such that when I post using
  something like:
  
  curl -u uid:pwd -F:contentType=multifolio -F:operation=import
  -F:contentFile=@~/bedge/issue.multifoliomailto:contentFile=@~/bedge/iss
  ue.multifolio http://localhost:8080/content/issue
  
  that the behavior would be to unpack the multifolio, then upon
  discovering the child .folio files, and recognizing the registered
  format for these, also unpack each of these?
  
  
  The gravy would be to also parse the folio.xml files and validate that
  all resources defined in the xml are indeed present, but I admit that’s
  getting greedy.
  
  -Bruce


Re: Apache Sling scheduler

2015-04-23 Thread Oliver Lietz
On Thursday 23 April 2015 14:28:05 nino martinez wael wrote:
 Ahh I just assumed it would be on maven repo aswell..

It is.

O.

 On Thu, Apr 23, 2015 at 2:15 PM, Roll, Kevin kevin-r...@idexx.com wrote:
  Nino, I believe the bundle you need is
  
  org.apache.sling.commons.threads-3.2.0.jar
  
  which can be found on the Sling Components page:
  
  https://sling.apache.org/downloads.cgi#components
  
  
  -Original Message-
  From: nino martinez wael [mailto:nino.martinez.w...@gmail.com]
  Sent: Thursday, April 23, 2015 7:32 AM
  To: users@sling.apache.org
  Subject: Apache Sling scheduler
  
  Hi I am trying to get the scheduler feature to boot.
  
  Heres my pax exam test:
  
  https://paste.apache.org/4WKo
  
  when it tries to boot I get this error (Scheduler seems to be
  dependent (org.apache.sling.commons.threads) on a non released Sling
  project?):
  
  2015-04-23 13:16:59,630 | WARN  | FelixStartLevel  |
  FeatureValidationUtil| 20 - org.apache.karaf.features.core
  - 3.0.3 | Old style feature file without namespace found (URI:
  file:C:/nino/develop/workspace/datatransfer/datatransfer-test/target/exam/
  abdeae24-8390-4f37-a14c-25def7648d71/test-dependencies.xml). This format
  is deprecated and support for it will soon be removed
  2015-04-23 13:17:11,498 | ERROR | FelixStartLevel  |
  BootFeaturesInstaller| 20 - org.apache.karaf.features.core
  - 3.0.3 | Error installing boot features
  java.lang.Exception: Could not start bundle
  mvn:org.apache.sling/org.apache.sling.commons.scheduler/2.4.6 in
  feature(s) test-dependencies-0.0.0: Unresolved constraint in bundle
  org.apache.sling.commons.scheduler [100]: Unable to resolve 100.0:
  missing requirement [100.0] osgi.wiring.package;
  ((osgi.wiring.package=org.apache.sling.commons.threads)(version=3.0.0)(!
  (version=4.0.0))) at
  org.apache.karaf.features.internal.FeaturesServiceImpl.startBundle(Featur
  esServiceImpl.java:504) at
  org.apache.karaf.features.internal.FeaturesServiceImpl.installFeatures(Fe
  aturesServiceImpl.java:459) at
  org.apache.karaf.features.internal.BootFeaturesInstaller.installBootFeatu
  res(BootFeaturesInstaller.java:92) at
  org.apache.karaf.features.internal.BootFeaturesInstaller.start(BootFeatur
  esInstaller.java:76) at
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_21] at
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
  :57)[:1.7.0_21] at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
  mpl.java:43)[:1.7.0_21] at
  java.lang.reflect.Method.invoke(Method.java:601)[:1.7.0_21]
  at
  org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.j
  ava:297)[15:org.apache.aries.blueprint.core:1.4.2] at
  org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:95
  8)[15:org.apache.aries.blueprint.core:1.4.2] at
  org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecip
  e.java:712)[15:org.apache.aries.blueprint.core:1.4.2] at
  org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecip
  e.java:824)[15:org.apache.aries.blueprint.core:1.4.2] at
  org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe
  .java:787)[15:org.apache.aries.blueprint.core:1.4.2] at
  org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:7
  9)[15:org.apache.aries.blueprint.core:1.4.2] at
  java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)[:1.7.0
  _21] at
  java.util.concurrent.FutureTask.run(FutureTask.java:166)[:1.7.0_21] at
  org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:8
  8)[15:org.apache.aries.blueprint.core:1.4.2] at
  org.apache.aries.blueprint.container.BlueprintRepository.createInstances(
  BlueprintRepository.java:245)[15:org.apache.aries.blueprint.core:1.4.2] at
  org.apache.aries.blueprint.container.BlueprintRepository.createAll(Bluepr
  intRepository.java:183)[15:org.apache.aries.blueprint.core:1.4.2] at
  org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEa
  gerComponents(BlueprintContainerImpl.java:682)[15:org.apache.aries.bluepri
  nt.core:1.4.2] at
  org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(Bluepri
  ntContainerImpl.java:377)[15:org.apache.aries.blueprint.core:1.4.2] at
  org.apache.aries.blueprint.container.BlueprintContainerImpl.run(Blueprint
  ContainerImpl.java:269)[15:org.apache.aries.blueprint.core:1.4.2] at
  org.apache.aries.blueprint.container.BlueprintExtender.createContainer(Bl
  ueprintExtender.java:294)[15:org.apache.aries.blueprint.core:1.4.2] at
  org.apache.aries.blueprint.container.BlueprintExtender.createContainer(Bl
  ueprintExtender.java:263)[15:org.apache.aries.blueprint.core:1.4.2] at
  org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(Blu
  eprintExtender.java:253)[15:org.apache.aries.blueprint.core:1.4.2] at
  org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.custom
  

Re: How to I set a sling:redirect property to something under /content?

2015-10-31 Thread Oliver Lietz
On Saturday 31 October 2015 18:26:20 Robert Munteanu wrote:
> Hi,

Hi Robert,

> I'm trying to create a redirect from / to /content/blog/posts . The way
> I did this was to change the sling:redirect property of / to
> /content/blog/posts.
> 
> However, the redirect ends up being sent to /blog/posts ( /content
> prefix removed ). By debugging I realised that this is removed by the
> ResourceResolver.map() call since there the
> ResourceResolverFactoryActivator URL mappings contain
> 
>   "/:/", "/content/:/", "/system/docroot/:/"
> 
> which means that for the ResourceResolver.map() call /content is
> removed.
> 
> I am not too familiar with that area of Sling, so my questions are:
> 
> 1) Is another ( clean ) way of doing this? I imagine I could redirect
> to /content/content/blog/posts or http://localhost:8080/content/blog/po
> sts, but both seem workardounds
> 
> 2) Does this look like a bug?

you usually don't want /content/ in your external URLs (visible to clients) 
and your resources under /content/blog/posts should be available also under 
/blog/posts. Does it work?

Have you read "Mappings for Resource Resolution"[0]?

Are you playing with a public available example?

Regards,
O.

[0] 
https://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html

> Thanks,
> 
> Robert



Re: management of sling instances

2015-07-09 Thread Oliver Lietz
On Thursday 09 July 2015 18:59:35 Jason Bailey wrote:

hello Jason,

 I was reviewing the way we manage deployments of our sling instances. Apache
 ACE looks interesting. I was wondering if anyone on the list has tried it,
 or has recommendations.

I haven't tried ACE but I'm working on bringing Sling to Karaf 4 (SLING-4412) 
which comes with full lifecycle management for features:
http://karaf.apache.org/manual/latest/users-guide/provisioning.html

Regards,
O.

 -Jason



Re: Sling retrieving out-of-date data

2015-12-02 Thread Oliver Lietz
On Tuesday 01 December 2015 19:22:14 H K wrote:
> Hi,
> 
> Sure. In pseudocode, here it is:
> 
> 1. Have Sling standalone running and have application that provides REST
> service createChildFolder (for example sake). Application connects to
> repository by using DocumentMK, as in the link from the OP post.
> 
> 2. Call createChildFolder("pathToParent", "childName").
> 
> 3. Make GET request to http://localhost:8080/pathToParent.infinity.json
> 
> 4. Inspecting the JSON Object, expect there to be a child node in parent
> node but none are there. Test failed.
> 
> However, if I let the thread sleep for 2 seconds after step 2, child exists
> in the JSON as wanted.

It works without a sleep when running in an OSGi container using a NodeStore 
from DocumentNodeStoreService (test is based on SlingLaunchpadOakMongoIT).
Non-OSGi setup with different NodeStore needs to be verified.

Regards,
O.

> Thanks,
> H
> 
> > From: apa...@oliverlietz.de
> > To: users@sling.apache.org
> > Subject: Re: Sling retrieving out-of-date data
> > Date: Tue, 1 Dec 2015 19:49:20 +0100
> > 
> > On Tuesday 01 December 2015 11:37:42 H K wrote:
> > > Hi,
> > 
> > Hi,
> > 
> > > I'm currently using the Sling 8 standalone and it's connected to a
> > > MongoDB
> > > database. I've got an application which also connects to the same
> > > MongoDB
> > > database and writes/reads from it. The connection is done using
> > > DocumentMK,
> > > following the instructions at
> > > https://jackrabbit.apache.org/oak/docs/construct.html
> > > 
> > > My problem is that when I write data to the repository through my
> > > application, Sling does not seem to get it fast enough, which may be
> > > because it is caching or because it only periodically checks to see if
> > > the
> > > data it has is up-to-date or not. For instance in my unit tests that
> > > test
> > > some of my REST services, I'm creating a child node somewhere and then
> > > doing a GET request to Sling to get back a JSON representing the updated
> > > parent. However, the returned result does not have the child in it. I
> > > know
> > > the changes are made because if I delay for two seconds before
> > > submitting
> > > the GET request, all works fine.
> > > 
> > > This was not a problem using Sling 7 with Jackrabbit (instead of Oak)
> > > and
> > > connecting over RMI.
> > > 
> > > Can someone provide some insight and/or a solution? Thanks!
> > 
> > can you provide a minimal test case which resembles what you are doing?
> > 
> > Regards,
> > O.




Re: Sling retrieving out-of-date data

2015-12-02 Thread Oliver Lietz
On Wednesday 02 December 2015 10:00:51 Chetan Mehrotra wrote:
> On Tue, Dec 1, 2015 at 10:07 PM, H K  wrote:
> > My problem is that when I write data to the repository through my
> > application, Sling does not seem to get it fast enough, which may be
> > because it is caching or because it only periodically checks to see if
> > the data it has is up-to-date or not

hi Chetan,

> What you are observing here is the result of eventual consistency
> model of Oak which is a MVCC based store [1]. When using
> DocumentNodeStore (used for Mongo) each cluster node periodically
> polls the backend for change in root node and then updates its head
> revision to make those changes visible to current cluster node. So
> change done by one cluster not would not be immediately *visible* on
> other cluster nodes.

but this is not the case for a single node, right? And I assume a non-cluster 
setup as H K didn't mention it.

Regards,
O.

> > This was not a problem using Sling 7 with Jackrabbit (instead of Oak) and
> > connecting over RMI.
> That was because there you were not using a cluster. You were
> connecting to the JR running within Sling using RMI. So it was a
> single node setup. If you use RMI now also and connect to same Sling
> node then it would work as expected.
> 
> Chetan Mehrotra
> [1] http://jackrabbit.apache.org/oak/docs/architecture/nodestate.html



Re: org.apache.sling.scripting.thymeleaf (0.1.7-SNAPSHOT)

2015-12-04 Thread Oliver Lietz
On Friday 04 December 2015 18:06:12 Helge-Frank Zimpel wrote:
> Hello,

Hello Helge,

> I’ve configured Scripting Thymelead 0.1.7 snapshot as follows:
> 
> - Extension ‚html‘ for the Script Engine Factory
> - '/apps/foo/bar/*.html‘ as pattern for template mode HTML
> 
> When calling my page (/imprint.html), i just get a page with the template
> path as content (fallback to StringTemplateResolver).
> 
> As you can see in the log, the HTML template resolver appears not to be
> configured
> 
> 04.12.2015 17:44:02.193 *INFO* [qtp934934504-72]
> org.apache.sling.scripting.thymeleaf Service
> [org.apache.sling.scripting.thymeleaf.internal.ThymeleafScriptEngineFactory
> ,461, [javax.script.ScriptEngineFactory]] ServiceEvent REGISTERED 04.12.2015
> 17:44:02.196 *INFO* [qtp934934504-72] org.apache.sling.scripting.thymeleaf
> Service
> [org.apache.sling.scripting.thymeleaf.internal.ResourceBundleMessageResolve
> r,460, [org.thymeleaf.messageresolver.IMessageResolver]] ServiceEvent
> REGISTERED 04.12.2015 17:44:04.801 *INFO* [0:0:0:0:0:0:0:1 [1449247444798]
> GET /imprint.html HTTP/1.1] org.thymeleaf.TemplateEngine [THYMELEAF]
> INITIALIZING TEMPLATE ENGINE 04.12.2015 17:44:04.814 *INFO*
> [0:0:0:0:0:0:0:1 [1449247444798] GET /imprint.html HTTP/1.1]
> org.thymeleaf.TemplateEngine.CONFIG Initializing Thymeleaf Template engine
> configuration... [THYMELEAF] TEMPLATE ENGINE CONFIGURATION:
> [THYMELEAF] * Cache Manager implementation:
> org.thymeleaf.cache.StandardCacheManager [THYMELEAF] * Template resolvers:
> [THYMELEAF] * org.thymeleaf.templateresolver.StringTemplateResolver
> [THYMELEAF] * Message resolvers:
> [THYMELEAF] * org.thymeleaf.messageresolver.StandardMessageResolver
> [THYMELEAF] * Dialect: Standard (org.thymeleaf.standard.StandardDialect)
> [THYMELEAF] * Prefix: "th"
> [THYMELEAF] TEMPLATE ENGINE CONFIGURED OK
> 04.12.2015 17:44:04.814 *INFO* [0:0:0:0:0:0:0:1 [1449247444798] GET
> /imprint.html HTTP/1.1] org.thymeleaf.TemplateEngine [THYMELEAF] TEMPLATE
> ENGINE INITIALIZED
> 
> What is wrong or missing here?

the NonCachingTemplateResolver is missing. Did you start with a fresh 
configuration for 0.1.x (Thymeleaf 3) or are you using one for 0.0.6 
(Thymeleaf 2.1)?

Regards,
O.

> Thanks in advance!
> 
> Helge



Re: org.apache.sling.scripting.thymeleaf (0.1.7-SNAPSHOT)

2015-12-07 Thread Oliver Lietz
On Friday 04 December 2015 18:06:12 Helge-Frank Zimpel wrote:
> Hello,
> 
> I’ve configured Scripting Thymelead 0.1.7 snapshot as follows:
> 
> - Extension ‚html‘ for the Script Engine Factory
> - '/apps/foo/bar/*.html‘ as pattern for template mode HTML
> 
> When calling my page (/imprint.html), i just get a page with the template
> path as content (fallback to StringTemplateResolver).
> 
> As you can see in the log, the HTML template resolver appears not to be
> configured
> 
> 04.12.2015 17:44:02.193 *INFO* [qtp934934504-72]
> org.apache.sling.scripting.thymeleaf Service
> [org.apache.sling.scripting.thymeleaf.internal.ThymeleafScriptEngineFactory
> ,461, [javax.script.ScriptEngineFactory]] ServiceEvent REGISTERED 04.12.2015
> 17:44:02.196 *INFO* [qtp934934504-72] org.apache.sling.scripting.thymeleaf
> Service
> [org.apache.sling.scripting.thymeleaf.internal.ResourceBundleMessageResolve
> r,460, [org.thymeleaf.messageresolver.IMessageResolver]] ServiceEvent
> REGISTERED 04.12.2015 17:44:04.801 *INFO* [0:0:0:0:0:0:0:1 [1449247444798]
> GET /imprint.html HTTP/1.1] org.thymeleaf.TemplateEngine [THYMELEAF]
> INITIALIZING TEMPLATE ENGINE 04.12.2015 17:44:04.814 *INFO*
> [0:0:0:0:0:0:0:1 [1449247444798] GET /imprint.html HTTP/1.1]
> org.thymeleaf.TemplateEngine.CONFIG Initializing Thymeleaf Template engine
> configuration... [THYMELEAF] TEMPLATE ENGINE CONFIGURATION:
> [THYMELEAF] * Cache Manager implementation:
> org.thymeleaf.cache.StandardCacheManager [THYMELEAF] * Template resolvers:
> [THYMELEAF] * org.thymeleaf.templateresolver.StringTemplateResolver
> [THYMELEAF] * Message resolvers:
> [THYMELEAF] * org.thymeleaf.messageresolver.StandardMessageResolver
> [THYMELEAF] * Dialect: Standard (org.thymeleaf.standard.StandardDialect)
> [THYMELEAF] * Prefix: "th"
> [THYMELEAF] TEMPLATE ENGINE CONFIGURED OK
> 04.12.2015 17:44:04.814 *INFO* [0:0:0:0:0:0:0:1 [1449247444798] GET
> /imprint.html HTTP/1.1] org.thymeleaf.TemplateEngine [THYMELEAF] TEMPLATE
> ENGINE INITIALIZED
> 
> What is wrong or missing here?

This was a bug in NonCachingTemplateResolver (line 140, fixed in r1718329).

https://svn.apache.org/viewvc?view=revision=r1718329

Regards,
O.

> Thanks in advance!
> 
> Helge



Re: Sling retrieving out-of-date data

2015-12-02 Thread Oliver Lietz
On Wednesday 02 December 2015 15:48:34 Chetan Mehrotra wrote:
> On Wed, Dec 2, 2015 at 2:20 PM, Oliver Lietz <apa...@oliverlietz.de> wrote:
> > but this is not the case for a single node, right? And I assume a
> > non-cluster setup as H K didn't mention it.
> 
> Code that HK mentioned above
> 
> 
> // REST service createChildFolder running on localhost:8040
> public void createChildFolder(String parentPath, String childName) {
> DB database = new MongoClient("127.0.0.1",
> 27017).getDB("sling"); DocumentNodeStore store = new
> DocumentMK.Builder().setMongoDB(database).getNodeStore();
> Repository repo = new Jcr(new Oak(store)).createRepository();
> SimpleCredentials creds = new SimpleCredentials("admin",
> "admin".toCharArray());
> Session session = (javax.jcr.Session) repository.login(creds);
> Node parent = session.getRootNode().getNode(parentPath);
> Node child = parent.addNode(childName, "sling:Folder");
> session.save();
> session.logout();
> store.dispose();
> }
> 
> 
> It technically creates a new Oak instances and thus you have a
> cluster! Had he connected to Sling using Remoting and not via Oak then
> it would be a single node case

Thanks, Chetan. Is it really the _new Oak_ or the new NodeStore which sets up 
a cluster? I would guess the new NodeStore as in my test with the same 
NodeStore and new Oak no sleep was required to get the previously created 
node. The Oak documentation for clustering could be more expressive...

O.

> Chetan Mehrotra



Re: Sling retrieving out-of-date data

2015-12-01 Thread Oliver Lietz
On Tuesday 01 December 2015 11:37:42 H K wrote:
> Hi,

Hi,

> I'm currently using the Sling 8 standalone and it's connected to a MongoDB
> database. I've got an application which also connects to the same MongoDB
> database and writes/reads from it. The connection is done using DocumentMK,
> following the instructions at
> https://jackrabbit.apache.org/oak/docs/construct.html
> 
> My problem is that when I write data to the repository through my
> application, Sling does not seem to get it fast enough, which may be
> because it is caching or because it only periodically checks to see if the
> data it has is up-to-date or not. For instance in my unit tests that test
> some of my REST services, I'm creating a child node somewhere and then
> doing a GET request to Sling to get back a JSON representing the updated
> parent. However, the returned result does not have the child in it. I know
> the changes are made because if I delay for two seconds before submitting
> the GET request, all works fine.
> 
> This was not a problem using Sling 7 with Jackrabbit (instead of Oak) and
> connecting over RMI.
> 
> Can someone provide some insight and/or a solution? Thanks!

can you provide a minimal test case which resembles what you are doing?

Regards,
O.



Re: Sling and link rewriter

2016-06-10 Thread Oliver Lietz
On Thursday 09 June 2016 18:20:31 Ben Fortuna wrote:
> Hi,

Hi Ben,

> I am seeing a curious error when I try to inject a link transformer in the
> rewriter pipeline of Sling 8 (running in docker). It tells me that the
> HtmlSerializerFactory can't find the HtmlSerializer class, even though it
> is an inner class of the factory.
> 
> I suspect the problem is that the required Cocoon libraries are not
> installed, but even then the rewriter bundle does not explicitly import the
> cocoon packages.

the Cocoon import is optional. Did you refresh package imports after 
installing Cocoon?

Regards,
O.

> Has anyone used the default Sling rewriter pipeline serializer, or do most
> use the implementation that comes with AEM (which is apparently different)?
> Many thanks.
> 
> Regards,
> Ben



Re: Sling and link rewriter

2016-06-14 Thread Oliver Lietz
On Saturday 11 June 2016 18:39:08 Ben Fortuna wrote:
> Just to follow up on this, I discovered the OBR version of sling rewriter
> is old (1.0.4) so when I installed from maven central (1.1.2) I am not
> seeing the same errors. Here is the link if anyone is interested:
> 
> http://search.maven.org/#artifactdetails%7Corg.apache.sling%7Corg.apache.sli
> ng.rewriter%7C1.1.2%7Cbundle
> 
> I also installed Cocoon serializers using this JAR:
> 
> http://search.maven.org/#artifactdetails%7Corg.apache.cocoon%7Ccocoon-serial
> izers-charsets%7C1.0.2%7Cbundle

Does it work now?

O.

> On Sat, Jun 11, 2016 at 12:29 PM, Ben Fortuna <benfort...@gmail.com> wrote:
> > Hi Oliver,
> > 
> > Yes I did refresh after installing, however I couldn't find a standard
> > OSGi bundle for cocoon, so I just embedded the cocoon-serializers JAR to
> > my
> > own bundle. So it's possible I am not exporting all of the required
> > packages.
> > 
> > Are there standard cocoon bundles I should use for the rewriter support? I
> > will look around a bit more to see if I can find some better bundle to
> > use.
> > Many thanks.
> > 
> > Regards,
> > Ben
> > On 11 Jun 2016 6:12 am, "Oliver Lietz" <apa...@oliverlietz.de> wrote:
> > 
> > On Thursday 09 June 2016 18:20:31 Ben Fortuna wrote:
> > > Hi,
> > 
> > Hi Ben,
> > 
> > > I am seeing a curious error when I try to inject a link transformer in
> > 
> > the
> > 
> > > rewriter pipeline of Sling 8 (running in docker). It tells me that the
> > > HtmlSerializerFactory can't find the HtmlSerializer class, even though
> > > it
> > > is an inner class of the factory.
> > > 
> > > I suspect the problem is that the required Cocoon libraries are not
> > > installed, but even then the rewriter bundle does not explicitly import
> > 
> > the
> > 
> > > cocoon packages.
> > 
> > the Cocoon import is optional. Did you refresh package imports after
> > installing Cocoon?
> > 
> > Regards,
> > O.
> > 
> > > Has anyone used the default Sling rewriter pipeline serializer, or do
> > 
> > most
> > 
> > > use the implementation that comes with AEM (which is apparently
> > 
> > different)?
> > 
> > > Many thanks.
> > > 
> > > Regards,
> > > Ben



Re: Response content type when url has no extension

2016-06-22 Thread Oliver Lietz
On Wednesday 22 June 2016 14:15:42 Bertrand Delacretaz wrote:
> Hi,
> 
> On Wed, Jun 22, 2016 at 12:39 AM, Ben Fortuna  wrote:
> > ...Should this be handled in sling or is it common practice to use another
> > mechanism to redirect / to /index.html? ...
> 
> I suspect people often use front-end rewriters like mod_rewrite to add
> extensions to URLs which have none.

Apache Sling URL Rewriter:
https://github.com/apache/sling/tree/trunk/contrib/extensions/urlrewriter

Regards,
O.

> Having a configurable default extension in Sling might be interesting,
> but we'd probably need to limit it to specific paths, or make that
> just an extension point.
> 
> -Bertrand



Re: Deploying Sling8 on Apache Karaf 4.0.4

2016-04-13 Thread Oliver Lietz
On Wednesday 13 April 2016 11:10:27 Ivan Gimenez wrote:
> Hi

Hi Ivan,

> I would like to use Sling8 for a project. I would like to ask if somebody
> has got successful experiences deploying Sling8 on Apache Karaf 4.0.4, or
> if there is a preferred/working method.
> 
> It seems there is no more Karaf feature repository for Sling8 to install,
> as was on Sling6,
> 
> feature:repo-add
> http://repo1.maven.org/maven2/org/apache/sling/org.apache.sling.launchpad/6/
> org.apache.sling.launchpad-6-features.xml

the new home for Karaf Features is in contrib/launchpad/karaf.
We don't have a release yet, some dependencies need to be released before.

Regards,
O.

> I am running into issues with the WAR method.  When just moved the
> launchpad8 WAR,  org.apache.sling.launchpad-8-webapp.war to deploy/
> directory  I got the following exception (i suspect is more related to
> PAX-WEB extender) on loading
> 
> 4/13/2016, 10:59:56 AM
> ERROR
> E​r​r​o​r​ ​d​e​p​l​o​y​i​n​g​ ​w​e​b​ ​a​p​p​l​i​c​a​t​i​o​n
> OPS4J Pax Web - Extender - WAR
> *java.lang.IllegalStateException: Multiple servlets map to path: *.jsp:
> jsp,sling*
> 
> 
> Any idea/suggestion/comment are welcomed.
> 
> Thanks
> Ivan



Re: Apache Sling OAK sample with launcher 9

2016-04-13 Thread Oliver Lietz
On Wednesday 13 April 2016 03:01:37 Arun Shaji wrote:
> Hi

Hi Arun,

>  I am trying out sling.
> 
>  *Can any body help with any samples of apache sling working with
> OAK/Mongo.*
> 
>  I started the launchpad with java -jar
> target/org.apache.sling.launchpad-*.jar -Dsling.run.modes=oak,oak_mongo.
>  sling is running not sure which repository its using.

Sling will use Oak with Mongo (oak run mode is obsolete now).

>   I am also running a mongo instance with sling db created but
> doesn't see any connections made by sling instance to it.

Check your logs for connection errors to Mongo.

>Also does the sample's with sling trunk use OAK as repository or
> they don't use any JCR repository at all.

That depends on Sling's version. We dropped support for Jackrabbit and use 
Jackrabbit Oak only now (look out for an Oak repository bundle).

Regards,
O.

> 
>  what i want to try out an example similar to slingshot where i can
> upload images & contents to OAK/Mongo repository.
> 
> Regards,
> Arun
> 
> 
> 
> --
> View this message in context:
> http://apache-sling.73963.n3.nabble.com/Apache-Sling-OAK-sample-with-launch
> er-9-tp4060792.html Sent from the Sling - Users mailing list archive at
> Nabble.com.



Re: Exception when trying out the fling sample

2016-04-30 Thread Oliver Lietz
On Saturday 30 April 2016 19:17:34 Roy Teeuwen wrote:
> Hello all,

Hello Roy,

> When navigating to fling.html after installing the fling samples I get
> following exception, any thought on what is going wrong? Parsing error in
> template /apps/fling/page/simple/html.html at line 20: extraneous input '('
> expecting {'}', '.', '&&', '||', '[', '@'} for expression
> page=${request.adaptTo(@org.apache.sling.samples.fling.page.Page@class)}
> (500)

until SLING-4430 is implemented you can run one script engine per extension 
only (service ranking is not honored by Sling's script engine manager, no need 
to try). https://issues.apache.org/jira/browse/SLING-4330

For running the Fling sample you have to deinstall Sightly.

I suggest to use the latest Scripting Thymeleaf snapshot which brings 
Thymeleaf 3.0.0.BETA03 (latest release).

The easiest way to get your dependencies right is to look at Launchpad Karaf 
Features:

https://github.com/apache/sling/blob/trunk/contrib/launchpad/karaf/org.apache.sling.launchpad.karaf-features/src/main/feature/feature.xml

But you don't have to fiddle around with dependencies at all when using 
Launchpad Karaf Features or Distribution – just install sling-launchpad-oak-
tar and sling-samples-fling.

Regards,
O.

> The requested URL /fling.html resulted in an error in
> /apps/fling/page/simple/html.html.
> 
> Exception:
> 
> org.apache.sling.scripting.sightly.SightlyException: Parsing error in
> template /apps/fling/page/simple/html.html at line 20: extraneous input '('
> expecting {'}', '.', '&&', '||', '[', '@'} for expression
> page=${request.adaptTo(@org.apache.sling.samples.fling.page.Page@class)} at
> org.apache.sling.scripting.sightly.impl.engine.UnitLoader.getSourceCodeForS
> cript(UnitLoader.java:135) at
> org.apache.sling.scripting.sightly.impl.engine.UnitLoader.createUnit(UnitLo
> ader.java:100) at
> org.apache.sling.scripting.sightly.impl.engine.SightlyScriptEngine.evaluate
> Script(SightlyScriptEngine.java:91)
> 
> The installed bundles that I am using to get the sample active on the
> current Sling 9-SNAPSHOT launchpad are the following:
> 
>   
> org.apache.sling.samples
> org.apache.sling.samples.fling
> 0.0.1-SNAPSHOT
> 
> 
> 
> org.apache.sling
> org.apache.sling.query
> 3.0.0
> 
> 
> 
> org.apache.sling
>
> org.apache.sling.jcr.jackrabbit.usermanager
> 2.2.4
> 
> 
> 
> org.apache.sling
> org.apache.sling.scripting.thymeleaf
> 0.0.6
> 
> 
> org.thymeleaf
> thymeleaf
> 3.0.0.BETA02
> 
> 
> org.apache.sling
> org.apache.sling.i18n
> 2.2.10
> 
> 
> org.javassist
> javassist
> 3.18.2-GA
> 
> 
> commons-io
> commons-io
> 2.4
> 
> 
> org.apache.servicemix.bundles
> org.apache.servicemix.bundles.xerces
> 2.11.0_1
> 
> 
> org.apache.servicemix.bundles
>
> org.apache.servicemix.bundles.xmlresolver
> 1.2_5
> 
> 
> 
> org.apache.sling
> org.apache.sling.validation.api
> 1.0.0-SNAPSHOT
> 
> 
> org.apache.sling
> org.apache.sling.validation.core
> 1.0.0-SNAPSHOT
> 
> 
> 
> org.apache.sling
> org.apache.sling.commons.messaging
> 0.0.1-SNAPSHOT
> 
> 
> Greetings,
> Roy




Re: Exception when trying out the fling sample

2016-05-01 Thread Oliver Lietz
On Saturday 30 April 2016 22:04:57 Vlad Bailescu wrote:
> On Saturday, 30 April 2016, Oliver Lietz <apa...@oliverlietz.de> wrote:
> > (service ranking is not honored by Sling's script engine manager, no need
> > to try).
> 
> Any idea why this is not a bug?

Why do you think it should be a bug?

Sling's Scripting support is built around Java's Scripting API (JSR-223) and 
that was obviously not designed to handle multiple script engines for one 
extension or mime type. So it is a limitation in Java's Scripting API.

>   https://issues.apache.org/jira/browse/SLING-4330
> 
> 
> I was under the impression SLING-4330 is about using both Sightly and
> Thymeleaf in the same running instance; and how to solve which one gets
> used on a file/script level.

Right.

> But for using just one scripting engine (Thymeleaf in this case) for a
> given extension we could just use the service ranking.

What is the benefit?

If you give Thymeleaf's script engine a higher service ranking than Sightly's 
to render HTML templates (.html) you make Sightly quite useless. The result is 
similar to deactivating/deinstalling Sightly's bundles (correct me if I'm 
wrong).

The other way round is not that destructive because Thymeleaf's script engine 
can be configured for different extensions (e.g. .htm, .thtml), can handle not 
only HTML but also XML, CSS, JavaScript, text and raw templates and makes its 
TemplateEngine available as OSGi service to render templates outside of 
Sling's Scripting context (see Fling sample).

So unless SLING-4330 is implemented and you want to use Thymeleaf for .html 
just deinstall Sightly.

Regards,
O.

> Best,
> Vlad



Re: Exception when trying out the fling sample

2016-05-01 Thread Oliver Lietz
On Sunday 01 May 2016 10:05:33 Vlad Bailescu wrote:
> Hi,
> 
> My comments are inline.
> 
> On Sunday, 1 May 2016, Oliver Lietz <apa...@oliverlietz.de> wrote:
> > On Saturday 30 April 2016 22:04:57 Vlad Bailescu wrote:
> > > On Saturday, 30 April 2016, Oliver Lietz <apa...@oliverlietz.de
> > 
> > <javascript:;>> wrote:
> > > > (service ranking is not honored by Sling's script engine manager, no
> > 
> > need
> > 
> > > > to try).
> > > 
> > > Any idea why this is not a bug?
> > 
> > Why do you think it should be a bug?
> 
> Because Sling generally uses the service ranking and it's a great mechanism.

"generally" is a somewhat optimistic term when it comes to service ranking at 
Sling. I don't think it's a bug still, but using service ranking could be an 
improvement indeed.

> > Sling's Scripting support is built around Java's Scripting API (JSR-223)
> > and
> > that was obviously not designed to handle multiple script engines for one
> > extension or mime type. So it is a limitation in Java's Scripting API.
> 
> The implementation could use service ranking as an optional/custom
> extension of the standard.

Right. And we will need an extension somehow when script engine manager is 
asked for an engine by extension or mime type. The manager could return null, 
throw an Exception or select the engine by service ranking when more than one 
engine is registered per extension or mime type. It will be implemented as 
part of SLING-4330 (work in progress).

> > >   https://issues.apache.org/jira/browse/SLING-4330
> > > 
> > > I was under the impression SLING-4330 is about using both Sightly and
> > > Thymeleaf in the same running instance; and how to solve which one gets
> > > used on a file/script level.
> > 
> > Right.
> > 
> > > But for using just one scripting engine (Thymeleaf in this case) for a
> > > given extension we could just use the service ranking.
> > 
> > What is the benefit?
> > 
> > If you give Thymeleaf's script engine a higher service ranking than
> > Sightly's
> > to render HTML templates (.html) you make Sightly quite useless. The
> > result is
> > similar to deactivating/deinstalling Sightly's bundles (correct me if I'm
> > wrong).
> > 
> > The other way round is not that destructive because Thymeleaf's script
> > engine
> > can be configured for different extensions (e.g. .htm, .thtml), can handle
> > not
> > only HTML but also XML, CSS, JavaScript, text and raw templates and makes
> > its
> > TemplateEngine available as OSGi service to render templates outside of
> > Sling's Scripting context (see Fling sample).
> > 
> > So unless SLING-4330 is implemented and you want to use Thymeleaf for
> > .html
> > just deinstall Sightly.
> 
> Right, but that seems a bit counter-intuitive since Sightly ships as
> default with Sling. From an user point of view it would make sense to just
> bump the ranking of Thymeleaf to make it "cut in front" instead of
> uninstalling something.

Sling Launchpad ships with Sightly because Adobe is pushing Sightly with full 
force. If you use Sling Launchpad Karaf no Scripting implementation is 
installed at all and you have the freedom to choose.

> This will not solve SLING-4330, of course, but will provide a better user
> experience, IMO.

Patches are welcome, go ahead!

O.

> > Regards,
> > O.
> 
> Best,
> Vlad




Re: Exception when trying out the fling sample

2016-05-01 Thread Oliver Lietz
On Sunday 01 May 2016 11:49:18 Roy Teeuwen wrote:
> Hey Olivier,

Hi Roy,

> Thanks for the explanation! For me real the benefit would be that I could
> take a vanilla sling launchpad and install the project where I would add a
> config file making the thymeleaf engine a higher service ranking and it
> would all work without any manual action of the user in the system console
> (unless there is a way I don’t know of that you can deactivate bundles
> through a config / maven plugin).

I don't think that it is possible right now, but you can build a custom 
Launchpad with Sling's Provisioning Model:

https://sling.apache.org/documentation/development/slingstart.html

> Also I still seem to be getting errors in the fling sample.
> 
> Firstly, when going to the form page, I get following error which can be
> fixed by making the  tags closed in the templates:
> 
>   org.thymeleaf.exceptions.TemplateInputException: Exception parsing
> document: template="/apps/fling/page/form/html.html", line 52 - column
> Caused by: org.xml.sax.SAXParseException; lineNumber: 52; columnNumber: 9;
> The element type "input" must be terminated by the matching end-tag
> "”.

(Thymeleaf 3 is using AttoParser not SAX)

> Secondly, when I manually close the input tags myself in the
> /apps/fling/page/form/html.html template and I submit the form, I just get
> redirected to following page and no validation occures:
> 
>   Content modified /content/fling/validation
> 
>   Status  200
>   Message OK
>   Location/fling/validation
>   Parent Location /fling
>   Path/content/fling/validation
>   Referer http://localhost:8080/fling/validation.html
>   ChangeLog   
modified("/content/fling/validation/formType");modifie
> d("/content/fling/validation/name"); Go Back
> 
>   Modified Resource
> 
>   Parent of Modified Resource

(the FormServlet is not registered as service, ITemplateEngine is missing 
probably)

The Fling sample now makes use of Sling Scripting Thymeleaf's new features so 
please use latest snapshot.

> Lastly, I was wondering what should be on the sling commons messaging page
> in the example. I just get a page with three columns, subject from and text
> but nothing filled in.

If you have installed and configured Commons Messaging Mail you will see mails 
received by (Wiser) SmtpService. For configuration see sling-samples-fling:

https://github.com/apache/sling/blob/trunk/contrib/launchpad/karaf/org.apache.sling.launchpad.karaf-features/src/main/feature/feature.xml

HTH,
O.

> Thanks!
> Greetings,
> Roy
[...]



Re: Support for the R6 HTTP Whiteboard in the Sling trunk

2016-08-01 Thread Oliver Lietz
On Monday 01 August 2016 14:44:02 Carsten Ziegeler wrote:
> > On Mon, 2016-08-01 at 14:21 +0200, Carsten Ziegeler wrote:
> >>> Hi,
> >>> 
> >>> On Mon, 2016-07-25 at 14:37 -0500, Carsten Ziegeler wrote:
>  Hi,
>  
>  did you have a look at the web console plugin whether your
>  servlet is
>  listed there? Maybe it is shadowed by something else.
> >>> 
> >>> If you mean http://localhost:8080/system/console/httpservice, it's
> >>> not
> >>> listed there.
> >> 
> >> Then it's not found at all. Just to check: are you sure that your
> >> test
> >> is correct and the servlet is registered correctly?
> >> You can check the service registry.
> > 
> > Some dependency updates later the servlet appears in the HTTP service
> > console. It is registered under the expected path but still not
> > serving requests.
> > 
> > Something to note - all other servlets are registered under Servlet
> > Context 'org.osgi.service.http', while this one is registered under
> > Servlet Context 'default'.
> 
> Yepp, as expected - org.osgi.service.http is the default context of the
> http service, in order to not break the http service, this context has
> precedence over the "default" context.
> And as  Sling is registered at "/", your servlet is never reached.
> 
> You can either register within the context 'org.osgi.service.http'
> (which only exists for the Felix implementation) or create your own context.

R6 support is work in progress for Pax Web 6, most should work with latest 
6.0.0-SNAPSHOTs: https://ops4j1.jira.com/browse/PAXWEB-804

Regards,
O.

> One we have the Sling context, you can use that one
> 
>  Carsten



Re: Minimal Sling

2016-07-26 Thread Oliver Lietz
On Tuesday 26 July 2016 13:21:33 Michael Marth wrote:
> Hi all,

Hi Michael,

> For educational purposes I am investigating a minimal, bare bones Sling.
> It should include core OSGi bundles and the minimal necessary Sling concepts
> (resource resolver), but nothing more (content repo, etc).
 
> Has anyone worked on something like this that I could re-use?

the Karaf Feature "sling" is a minimal Sling:

https://github.com/apache/sling/blob/trunk/karaf/org.apache.sling.karaf-features/src/main/feature/feature.xml

You can use SlingOptions (derived from Sling's Karaf Features) from Testing 
PaxExam for setting up a minimal Sling instance for tests:

https://github.com/apache/sling/blob/trunk/testing/org.apache.sling.testing.paxexam/src/main/java/org/apache/sling/testing/paxexam/SlingOptions.java

Regards,
O.

> Also related to this I had a look at the File System Resource Provider [1].
> AFAICS it works with files (binaries), but there does not seem to be a
> feature that would allow to work with fine-granular content (e.g. a JSON
> file). Has anyone worked on extending the FSRP by chance?
 
> Thanks for any hints!
> Michael
> 
> 
> [1]
> https://sling.apache.org/documentation/bundles/accessing-filesystem-resourc
> es-extensions-fsresource.html
 



Re: Sling JobManager With Karaf "Unsatisfied" status for JobManagerConfiguration

2016-07-07 Thread Oliver Lietz
On Thursday 07 July 2016 06:25:17 mknair wrote:
> I am trying to use Sling JobManager with Apache Karaf and trying out a
> program as described here ().

Where?

> After installing the features, I am getting the following error

Which features?

> ["Unsatisfied","Service Name:
> org.apache.sling.event.impl.jobs.config.JobManagerConfiguration","Multiple:
> single","Optional: mandatory","Policy: static","No Services bound"]
> Any one encountered this error before ? Appreciate your help.

No. Works fine with latest Lauchpad Karaf Features/Distribution (sling-
launchpad-oak-tar and sling-extension-event).

Regards,
O.

> Regards
> 
> 
> 
> --
> View this message in context:
> http://apache-sling.73963.n3.nabble.com/Sling-JobManager-With-Karaf-Unsatis
> fied-status-for-JobManagerConfiguration-tp4062265.html Sent from the Sling -
> Users mailing list archive at Nabble.com.



Re: Sling JobManager With Karaf "Unsatisfied" status for JobManagerConfiguration

2016-07-08 Thread Oliver Lietz
On Friday 08 July 2016 06:53:16 mknair wrote:
> Thanks Olivier. What we are looking for is  feature repository like
> 
> http://repo1.maven.org/maven2/org/apache/sling/org.apache.sling.launchpad/6/
> org.apache.sling.launchpad-6-features.xml
> 
> for Sling 7 and Sling 8 so that we can directly refer from our
> applications. Is it planned in the near future ?

Launchpad Karaf Features is decoupled from Launchpad (builder) and it has now 
its own version. That will allow releases more frequently (and fine grained 
features). The initial release is blocked by some issues in Sling and Karaf 
but should happen this year (2016) finally.

O.

[...]



Re: Sling JobManager With Karaf "Unsatisfied" status for JobManagerConfiguration

2016-07-08 Thread Oliver Lietz
On Friday 08 July 2016 08:18:01 mknair wrote:
> Great!  Is there any option to use sling 7or8 without persistence?

Sure. You can run Sling without JCR (and you can use your own resource 
provider).

O.

[...]



Re: Sling JobManager With Karaf "Unsatisfied" status for JobManagerConfiguration

2016-07-08 Thread Oliver Lietz
On Friday 08 July 2016 11:22:42 mknair wrote:
> Thanks.  Any examples we can refer to?

http://svn.apache.org/repos/asf/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/resourceprovider/

O.

[...]



Re: Sling JobManager With Karaf "Unsatisfied" status for JobManagerConfiguration

2016-07-09 Thread Oliver Lietz
On Friday 08 July 2016 22:13:39 mknair wrote:
> Hi,
> 
> If I understood this correctly, I need NOT use features listed below (which
> are required to be installed for sling-launchpad-oak-tar
> * sling-launchpad-oak
> * sling-extension-discovery-oak
> * sling-scripting
> * sling-extension-healthcheck
> * sling-extension-bundleresource
> * sling-extension-adapter
> * sling-installer
> * sling-servlets
> * jackrabbit-sling
> * tika-sling
> * sling-jcr
> * sling-jcr-oak
> * sling-launchpad-oak-tar
> 
> instead for using the sling.event capability
> 1) Create a ResourceProvider in my application in similar lines to the
> example you shared .
> 2) Install following features
> * sling
> * sling-commons-scheduler
> * sling-commons-threads
> * sling-extension-discovery
> * sling-extension-event

No, read my second mail in this thread.

O.

> Any configuration changes required ?
> 
> 
> Regards
> 
> Manoj
[...]



[ANN] Apache Sling Scripting Thymeleaf 1.0.0

2016-07-11 Thread Oliver Lietz
The Apache Sling team is pleased to announce the release of Apache Sling 
Scripting Thymeleaf 1.0.0

Apache Sling is a web framework that uses a Java Content Repository, such as 
Apache Jackrabbit, to store and manage content. Sling applications use either 
scripts or Java servlets, selected based on simple name conventions, to 
process HTTP requests in a RESTful way.

Thymeleaf is a modern server-side Java template engine for both web and 
standalone environments. Thymeleaf's main goal is to bring elegant natural 
templates to your development workflow — HTML that can be correctly displayed 
in browsers and also work as static prototypes, allowing for stronger 
collaboration in development teams.

http://www.thymeleaf.org

Sling Scripting Thymeleaf is the scripting engine for Thymeleaf templates:

 * Supporting all of Thymeleaf's extension points: TemplateResolvers, 
MessageResolvers, Dialects, LinkBuilders, DecoupledTemplateLogicResolver, 
CacheManager and EngineContextFactory
 * SlingResourceTemplateResolver customizable through TemplateModeProvider
 * ResourceBundleMessageResolver backed by ResourceBundleProvider from Sling 
i18n customizable through optional AbsentMessageRepresentationProvider
 * PatternTemplateModeProvider supporting Pattern configurations for all 
template modes (HTML, XML, TEXT, JAVASCRIPT, CSS and RAW)
 * SlingDialect
 * Thymeleaf's TemplateEngine registered as OSGi Service (ITemplateEngine) for 
direct use

https://sling.apache.org/documentation/bundles/scripting/scripting-thymeleaf.html

This release is available from http://sling.apache.org/site/downloads.cgi

Building from verified sources is recommended, but convenience binaries are 
also available via Maven:


  org.apache.sling
  org.apache.sling.scripting.thymeleaf
  1.0.0


Release Notes:

Bug
 * [SLING-5351] - Thymeleaf fails loading version from properties

Improvement
 * [SLING-5518] - Get resource resolver from bindings by using 
SlingBindings.RESOLVER

New Feature
 * [SLING-5663] - Make Thymeleaf TemplateEngine available as service

Task
 * [SLING-4884] - remove embedded CaptureResponseWrapper
 * [SLING-5075] - Upgrade Thymeleaf to 3.0
 * [SLING-5685] - Upgrade Commons IO to 2.5

Enjoy!

-The Sling team



Re: Sling JobManager With Karaf "Unsatisfied" status for JobManagerConfiguration

2016-07-07 Thread Oliver Lietz
On Thursday 07 July 2016 08:44:28 mknair wrote:
> Hi Olivier,

Hi,

just to make sure, as you are mentioning sling-commons-scheduler below (which 
is part of the sling feature), you want to use Sling Event?

https://sling.apache.org/documentation/bundles/apache-sling-eventing-and-job-handling.html

https://sling.apache.org/documentation/bundles/scheduler-service-commons-scheduler.html

"The notion of Job used in this context is a different one than the one used 
for Sling Jobs. The main difference is that a scheduler's job is not 
persisted."

> Thanks for the response. We are building a Karaf based service which uses
> Sling-Event-JobManager. Following are the steps we followed
> * Referred to github feature.xml
> https://github.com/apache/sling/blob/trunk/contrib/launchpad/karaf/org.apach
> e.sling.launchpad.karaf-features/src/main/feature/feature.xml and in our
> Karaf project added following features as dependency (in our feature.xml)
> * sling
> * sling-commons-scheduler
> *sling-commons-threads
> * sling-extension-discovery
> * sling-extension-discovery-impl
> * sling-extension-event
> 
> and added sling-extension-event in our feature definition as below
>  description='jobmanager :: consumer'>
> sling-extension-event
> mvn:com..jobmgr/jobmanager-consumer/1.0.0-SNAPSHOT
> 
> 
> We did not add any other features from the github link above as we are more
> interested in the sling.event.* bundle. So added only yhe dependencies for
> this specific bundle.
> 
> Further we installed our feature and on observing at webconsole we found
> the error mentioned in the mail above.
> My initial suspicion was that JobManagerConfiguration is failing due to
> some file system permission issue, but as a super user as well we could not
> bring it up. I also looked into Karaf log and could not see any error
> scenarios logged in JobManagerConfiguration. So currently I am suspecting
> that some dependent bundle is not started (like EnvironmentComponent,
> ResourceResolverFactory , QueueConfigurationManager etc).
> 
> Kindly let me know if the steps followed is correct.

Sling Jobs from Sling Event are persisted. So Sling Event requires a 
SlingRepository implementation which is provided by 
org.apache.sling.jcr.oak.server – either with a SegmentNodeStore or a 
DocumentNodeStore. You will need something like sling-launchpad-oak-tar or 
sling-launchpad-oak-mongo.

Such dependencies will be expressed with OSGi capabilities in the future.

Regards,
O.

> Regards
> 
> 
> 
> 
> On Thu, Jul 7, 2016 at 7:51 PM, Oliver Lietz [via Apache Sling] <
> 
> ml-node+s73963n4062278...@n3.nabble.com> wrote:
> > On Thursday 07 July 2016 06:25:17 mknair wrote:
> > > I am trying to use Sling JobManager with Apache Karaf and trying out a
> > > program as described here ().
> > 
> > Where?
> > 
> > > After installing the features, I am getting the following error
> > 
> > Which features?
> > 
> > > ["Unsatisfied","Service Name:
> > 
org.apache.sling.event.impl.jobs.config.JobManagerConfiguration","Multiple:
> > > single","Optional: mandatory","Policy: static","No Services bound"]
> > > Any one encountered this error before ? Appreciate your help.
> > 
> > No. Works fine with latest Lauchpad Karaf Features/Distribution (sling-
> > launchpad-oak-tar and sling-extension-event).
> > 
> > Regards,
> > O.
> > 
> > > Regards
> > > 
> > > 
> > > 
> > > --
> > 
> > > View this message in context:
> > http://apache-sling.73963.n3.nabble.com/Sling-JobManager-With-Karaf-Unsati
> > s
> > 
> > > fied-status-for-JobManagerConfiguration-tp4062265.html Sent from the
> > 
> > Sling -
> > 
> > > Users mailing list archive at Nabble.com.
> > 
> > --
> > If you reply to this email, your message will be added to the discussion
> > below:
> > 
> > http://apache-sling.73963.n3.nabble.com/Sling-JobManager-With-Karaf-Unsati
> > sfied-status-for-JobManagerConfiguration-tp4062265p4062278.html To
> > unsubscribe from Sling JobManager With Karaf "Unsatisfied" status for
> > JobManagerConfiguration, click here
> > <http://apache-sling.73963.n3.nabble.com/template/NamlServlet.jtp?macro=un
> > subscribe_by_code=4062265=bWtuYWlyQGdtYWlsLmNvbXw0MDYyMjY1fDMxOT
> > YwODE3> .
> > NAML
> > <http://apache-sling.73963.n3.nabble.com/template/NamlServlet.jtp?macro=ma
> > cro_viewer=instant_html%21nabble%3Aemail.naml=nabble.naml.namespac
> > es.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web
> > .template.NodeNamespace=notify_subscribers%21nabble%3Aemail.na
> > ml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemai
> > l.naml>
> --
> View this message in context:
> http://apache-sling.73963.n3.nabble.com/Sling-JobManager-With-Karaf-Unsatis
> fied-status-for-JobManagerConfiguration-tp4062265p4062279.html Sent from the
> Sling - Users mailing list archive at Nabble.com.




Re: Getting the actual resource from a request

2016-07-28 Thread Oliver Lietz
On Thursday 28 July 2016 20:45:06 Roy Teeuwen wrote:
> Already tried that one ;) it returns a non existing resource with the path
> /content/dam/nice-image.cdn.jpg/modification-date/20160815/nice-image.jpg

Hi Roy,

that means your resource is not found. Make sure /content/dam/nice-image.jpg 
is available.

What's the reason for forwarding instead of reading/serving the resource from 
the repository in your current servlet?

Regards,
O.

> Greetings,
> Roy
> 
> > On 28 Jul 2016, at 18:35, Jason Bailey  wrote:
> > 
> > I'm under the understanding that it is;
> > 
> > request.getResource().getPath()
> > 
> > -Original Message-
> > From: Roy Teeuwen [mailto:r...@teeuwen.be]
> > Sent: Thursday, July 28, 2016 12:31 PM
> > To: users@sling.apache.org
> > Subject: Getting the actual resource from a request
> > 
> > Hey all,
> > 
> > I am creating a SlingServlet that will work by both using a selector and a
> > suffix. The resource is for example /content/dam/image.jpg and the actual
> > url will be
> > /content/dam/nice-image.cdn.jpg/modification-date/20160815/nice-image.jpg
> > 
> > What is the most easy way to get the actual resource path again from the
> > SlingHttpServletRequest? Currently I am doing the following but I find it
> > a bit cumbersome:
> > 
> > private String getResourcePath(SlingHttpServletRequest request) {
> > 
> >String requestUrl = request.getRequestPathInfo().getResourcePath();
> >int endIndex =
> >requestUrl.lastIndexOf(request.getRequestPathInfo().getSuffix());
> >String resourcePathWithSelector = requestUrl.substring(0, endIndex);
> >endIndex =
> >resourcePathWithSelector.lastIndexOf(request.getRequestPathInfo().getS
> >electorString() + "." + request.getRequestPathInfo().getExtension());
> >return resourcePathWithSelector.substring(0, endIndex) +
> >request.getRequestPathInfo().getExtension();> 
> > }
> > 
> > Is there an easier way or is parsing it like this the only way?
> > 
> > Also after I got the actual resourcePath, I tried doing the following, but
> > this doesn’t seem to work, any clue on why?
> > 
> > @Override
> > protected void doGet(SlingHttpServletRequest request,
> > SlingHttpServletResponse response) throws ServletException, IOException {> 
> >  RequestDispatcherOptions opts = new RequestDispatcherOptions();
> >  opts.setReplaceSelectors("");
> >  String resourcePath = getResourcePath(request);
> >  RequestDispatcher dispatcher =
> >  request.getRequestDispatcher(resourcePath, opts); if (dispatcher !=
> >  null) {
> >  
> >  dispatcher.forward(request, response);
> >  
> >  }
> > 
> > }
> > 
> > I would expect that the previous would actually just forward it to the
> > actual image being fetched from the getResourcePath but it just gives me
> > a 404 not found (I checked the getResourcePath and it does return
> > /content/dam/nice-image.jpg)
> > 
> > Thanks!
> > Roy




Re: Building Karaf - org.apache.sling.jcr.webdav 2.3.6 Build Error

2017-02-02 Thread Oliver Lietz
On Thursday 02 February 2017 16:30:42 Ravindra Singareddy wrote:
> Hello Experts,

Hi Ravi,

please do not cross-post on users@ and dev@.

> I have checked in latest sling code. I have compiled using maven and
> receiving org.apache.sling.jcr.webdav, version 2.3.6 is not available in
> maven repository. I have changed version to 2.3.4, it compiles but throws
> error in Integration tests.
> 
> 
> In bundle packages, org.apache.sling.jcr.webdav version set to
> 2.3.9-SNAPSHOT,  version need to set it to this value.

The release of JCR WebDav 2.3.6 was canceled. Please update your source and 
build any missing dependencies (releases under vote) yourself.

Regards,
O.

> Thanks
> 
> 
> Ravi Singareddy



Re: Sling in Karaf not working well

2016-09-06 Thread Oliver Lietz
On Tuesday 06 September 2016 09:32:17 Mike Hummel wrote:
> Hello,

Hello Mike,

Sling on Karaf is close to perfection and works very well in production.
When you have no or little experience with Sling or Karaf you should follow 
the *Getting Started* section (I already pointed you to 
https://github.com/apache/sling/tree/trunk/karaf).

You can run Sling with different resource providers (repositories/backends) 
and four are available as features on Karaf:

* sling-launchpad-oak-tar
* sling-launchpad-oak-mongo
* sling-launchpad-nosql-couchbase
* sling-launchpad-nosql-mongodb

Just install the feature sling-launchpad-oak-tar and everything else required 
gets pulled in. The other three features require setting up a database before.

> I try to run sling in karaf but have an issue with the Authentication
> Support. I have installed the bundles

Check the logs, a repository is missing.

Regards,
O.


> karaf@root() list
> 
> START LEVEL 100 , List Threshold: 50
> 
> ID | State | Lvl | Version| Name
> 
> 
> ---
> 
> 53 | Active|  80 | 2.0| Content Repository for JavaTM
> Technology API
> 
> 58 | Active|  80 | 3.2.2  | Apache Commons Collections
> 
> 59 | Active|  80 | 1.3.1  | Apache Commons FileUpload
> 
> 60 | Active|  80 | 2.4.0  | Commons IO
> 
> 61 | Active|  80 | 2.6| Commons Lang
> 
> 69 | Active|  80 | 2.9.0  | Apache Sling API
> 
> 70 | Active|  80 | 1.3.12 | Apache Sling Authentication Service
> 
> 71 | Active|  80 | 1.3.2  | Apache Sling Dynamic Class Loader
> Support
> 
> 72 | Active|  80 | 2.2.0  | Apache Sling Commons Java Compiler
> 
> 73 | Active|  80 | 2.0.16 | Apache Sling JSON Library
> 
> 74 | Active|  80 | 2.1.8  | Apache Sling MIME type mapping
> support
> 
> 75 | Active|  80 | 2.3.0  | Apache Sling Commons OSGi support
> 
> 76 | Active|  80 | 2.4.10 | Apache Sling Scheduler Support
> 
> 77 | Active|  80 | 3.2.2  | Apache Sling Thread Support
> 
> 78 | Active|  80 | 2.4.4  | Apache Sling Engine Implementation
> 
> 79 | Active|  80 | 3.0.0  | Apache Sling Query
> 
> 80 | Active|  80 | 1.2.6  | Apache Sling Resource Resolver
> 
> 81 | Active|  80 | 1.2.2  | Apache Sling Service User Mapper
> 
> 82 | Active|  80 | 1.3.7.SNAPSHOT | Apache Sling Settings
> 
> 117 | Active|  80 | 1.0.8  | Apache Sling Form Based
> Authentication Handler
> 
> A web-request brings the following error:
> 
> 
> AuthenticationSupport service missing. Cannot authenticate request.
> 
> 
> 
> 
> 
> Looks like I need an additional bundle? Already tried around and "Apache
> Sling Form Based Authentication Handler" should do the job?
> 
> 
> 
> 
> 
> Thx for help.
> 
> 
> 
> Mike




Re: setting repository.home

2016-09-01 Thread Oliver Lietz
On Wednesday 31 August 2016 21:58:53 Mike Nimer wrote:
> I'm trying to define the folder for the Tar/Repository files in Sling.
> However, I can't figure out the right way to set the repository.home
> folder on initial setup.
> 
> As I understand it, the Tar SegmentNodeStoreService is supposed to
> default to a folder under the {sling.home} path, set with the -c
> argument. No matter what I try it is always placing the repository
> folder relative to the folder I'm running java from. The rest of the
> Sling files goes in the sling.home folder.
> 
> For instance, if I'm in
> 
> ~/Development
> 
> and I run
> 
> java -jar project/target/sling-app.jar -c /temp
> 
> The sling bundles, logs, etc will be under /temp, but the
> sling/repository folder will be put under the ~/Development/sling
> folder. (what I want to change)
> 
> I've tried adding these extra command line arguments too, but they don't
> help.
> 
> -Drepository.home=/temp
> -Dsling.repository.home=/temp

Hi Mike,

please see SLING-6022 and report back if it works for you.
Sorry for the inconvenience. 
 
Regards,
O.

> Thanks in advance
> --mike



Re: User Defined Token Substitution in Content

2016-09-12 Thread Oliver Lietz
On Sunday 11 September 2016 21:19:23 Adam Henderson wrote:
> Hi,

Hello Adam,

> Being relatively new to Sling, is there an OOTB way to allow special tokens
> to be inserted into the textual content (not into sly/jsp templates) that
> when rendered can be resolved to some value (e.g. invoking a method on a
> service or a reference to a property in the JCR).
> 
> eg:
> 
> /apps/pages/productdetails.html
> 
> /content/page/product1details
>   - sling:resourceType: pages/productdetails
> 
> /content/products/product1
>   - description : string = “This is the description of Product 1, hurry -
> discount of $JCR[‘/content/promotions/discounts:holidayspecialdiscount’]%
> applies!”
> 
> /content/promotions/discounts
>   - holidayspecialdiscount : double = 10
> 
> So I would like Sling to resolve the $JCR token so that what is shown to the
> user would be:
> 
> "This is the description of Product 1, hurry - discount of 10% applies!"
> 
> So how would you approach this in in a Sling environment.

there are several ways to do it in Sling and it really depends on your 
requirements.

Post-processing: use Sling Rewriter or SSI to replace/fill the token/variable 
after the page resource was processed by your scripting engine.

Sling Models: use a Sling Model in your script and let it do the string 
processing.

Scripting engine: extend your scripting engine with a special tag/processor 
which will do the string processing.

You will need some kind of service to pick up the value by query from the repo 
in any way.

Regards,
O.

> Many thanks,
> Adam.



Re: Creating a service user for your own bundle

2016-11-07 Thread Oliver Lietz
On Monday 07 November 2016 10:05:18 Oliver Lietz wrote:
> On Monday 07 November 2016 07:58:33 Carsten Ziegeler wrote:
> > Roy Teeuwen wrote
> 
> Hi Roy,
> 
> > > Hey Carsten,

...and good morning, Carsten!

O.

> > > Thanks for the info, I will definitely follow up on the progress of what
> > > you are making then :).
> > > 
> > > One remark though, you say it's not the task of the bundle developer to
> > > create the user and assigning the rights. I can follow in this, but this
> > > also means that the potential users of the bundle you create has to know
> > > exactly the name of the service user and the rights required for the
> > > bundle to work.
> 
> which service user is mapped to the bundle is not important – but it has to
> be a service user with sufficient permissions.
> To ensure a user mapping is present for your component before getting
> activated use ServiceUserMapped[1].
> 
> Which permissions (JCR ACLs) are required by a bundle should be documented
> in the module's README but for now you have to look at provisioning model
> in launchpad/builder.
> 
> > > Is there going to be some sort of mechanism (like the
> > > require-capability header) to tell the users of the bundle what the
> > > needed user and rights are? Maybe even a webconsole plugin showing which
> > > bundles aren't satisfied
> > 
> > That's indeed a good point, so far we don't have any mechanism here.
> > Defining the requirement is easy and we could add an entry to the
> > manifest of a bundle if the bundle requires a service user including the
> > sub module names.
> > 
> > The problematic part is providing the capability as these can't be
> > dynamically created and added to a module at runtime. For example, it
> > would not be possible that the Oak implementation bundle adds the
> > provide capabilities entries based on the available service users.
> > 
> > I think the only option we have is using OSGi services as these are
> > dynamic and requirements can be easily expressed through services. I
> > don't have any good idea on how to do this with service users, but I
> > should definitely be possible and I agree that we should provide
> > something like this.
> 
> We would have to observe the repository for all system users' ACLs and
> provide both as capabilities (or services) – is it worth the effort?
> 
> Regards,
> O.
> 
> [1]
> https://sling.apache.org/apidocs/sling8/org/apache/sling/serviceusermapping/
> ServiceUserMapped.html
> > Regards
> > 
> >  Carsten




Re: Creating a service user for your own bundle

2016-11-07 Thread Oliver Lietz
On Monday 07 November 2016 10:43:18 Roy Teeuwen wrote:
> Hey Oliver,

Hi Roy,

> Forcing a user of a bundle to go and look up the git project to find the
> README.md to see which permissions are needed doesn't sound like a good
> solution for me, it should be present somehow in the built jar from the
> maven central repo. So I would also go for the manifest file here like
> Carsten proposed.

you are usually using a distribution (Sling Launchpad or AEM) where users and 
ACLs are already configured. Using a single bundle without looking into it's 
documentation is a rather rare case.

> I can follow that the provide capability could be something more of a nice
> to have seeing as Carsten said in his first reply, it should be the user
> who puts up the mapping between the users and the bundles that need the
> service users. But he should of course know that he needs to do this, hence
> the need for the require capability.

If a bundle requires a capability the system has to provide that capability 
otherwise the bundle would not resolve. Does it make sense to express these 
requirements by OSGi Capabilities? When running Sling with Mongo you also have 
to look into documentation and set up host and port – do you expect that also 
to be expressed by capabilities (a running MongoDB, no better example at hand 
but I guess you get the point)?

Regards,
O.

> Greetings,
> Roy
> 
> > On 7 Nov 2016, at 10:05, Oliver Lietz <apa...@oliverlietz.de> wrote:
> > 
> > On Monday 07 November 2016 07:58:33 Carsten Ziegeler wrote:
> >> Roy Teeuwen wrote
> > 
> > Hi Roy,
> > 
> >>> Hey Carsten,
> >>> 
> >>> Thanks for the info, I will definitely follow up on the progress of what
> >>> you are making then :).
> >>> 
> >>> One remark though, you say it's not the task of the bundle developer to
> >>> create the user and assigning the rights. I can follow in this, but this
> >>> also means that the potential users of the bundle you create has to know
> >>> exactly the name of the service user and the rights required for the
> >>> bundle to work.
> > 
> > which service user is mapped to the bundle is not important – but it has
> > to be a service user with sufficient permissions.
> > To ensure a user mapping is present for your component before getting
> > activated use ServiceUserMapped[1].
> > 
> > Which permissions (JCR ACLs) are required by a bundle should be documented
> > in the module's README but for now you have to look at provisioning model
> > in launchpad/builder.
> > 
> >>> Is there going to be some sort of mechanism (like the
> >>> require-capability header) to tell the users of the bundle what the
> >>> needed user and rights are? Maybe even a webconsole plugin showing which
> >>> bundles aren't satisfied
> >> 
> >> That's indeed a good point, so far we don't have any mechanism here.
> >> Defining the requirement is easy and we could add an entry to the
> >> manifest of a bundle if the bundle requires a service user including the
> >> sub module names.
> >> 
> >> The problematic part is providing the capability as these can't be
> >> dynamically created and added to a module at runtime. For example, it
> >> would not be possible that the Oak implementation bundle adds the
> >> provide capabilities entries based on the available service users.
> >> 
> >> I think the only option we have is using OSGi services as these are
> >> dynamic and requirements can be easily expressed through services. I
> >> don't have any good idea on how to do this with service users, but I
> >> should definitely be possible and I agree that we should provide
> >> something like this.
> > 
> > We would have to observe the repository for all system users' ACLs and
> > provide both as capabilities (or services) – is it worth the effort?
> > 
> > Regards,
> > O.
> > 
> > [1]
> > https://sling.apache.org/apidocs/sling8/org/apache/sling/serviceusermappin
> > g/ServiceUserMapped.html
> > <https://sling.apache.org/apidocs/sling8/org/apache/sling/serviceusermapp
> > ing/ServiceUserMapped.html>> 
> >> Regards
> >> 
> >> Carsten



Re: Creating a service user for your own bundle

2016-11-07 Thread Oliver Lietz
On Monday 07 November 2016 07:58:33 Carsten Ziegeler wrote:
> Roy Teeuwen wrote

Hi Roy,

> > Hey Carsten,
> > 
> > Thanks for the info, I will definitely follow up on the progress of what
> > you are making then :).
> > 
> > One remark though, you say it's not the task of the bundle developer to
> > create the user and assigning the rights. I can follow in this, but this
> > also means that the potential users of the bundle you create has to know
> > exactly the name of the service user and the rights required for the
> > bundle to work.

which service user is mapped to the bundle is not important – but it has to be 
a service user with sufficient permissions.
To ensure a user mapping is present for your component before getting 
activated use ServiceUserMapped[1].

Which permissions (JCR ACLs) are required by a bundle should be documented in 
the module's README but for now you have to look at provisioning model in 
launchpad/builder.

> > Is there going to be some sort of mechanism (like the
> > require-capability header) to tell the users of the bundle what the
> > needed user and rights are? Maybe even a webconsole plugin showing which
> > bundles aren't satisfied
> That's indeed a good point, so far we don't have any mechanism here.
> Defining the requirement is easy and we could add an entry to the
> manifest of a bundle if the bundle requires a service user including the
> sub module names.
> 
> The problematic part is providing the capability as these can't be
> dynamically created and added to a module at runtime. For example, it
> would not be possible that the Oak implementation bundle adds the
> provide capabilities entries based on the available service users.
> 
> I think the only option we have is using OSGi services as these are
> dynamic and requirements can be easily expressed through services. I
> don't have any good idea on how to do this with service users, but I
> should definitely be possible and I agree that we should provide
> something like this.

We would have to observe the repository for all system users' ACLs and provide 
both as capabilities (or services) – is it worth the effort?

Regards,
O.

[1] 
https://sling.apache.org/apidocs/sling8/org/apache/sling/serviceusermapping/ServiceUserMapped.html
 
> Regards
> 
>  Carsten




Re: Fling Installation on Trunk

2017-03-28 Thread Oliver Lietz
On Monday 27 March 2017 13:05:38 Andreas Schaefer Sr. wrote:
> Hi
> 
> I tried to install Fling from the Samples but failed with the latest Sling.
> 
> First I had to install Sling Messaging and Sling Query but then
> I gave up on Sling Thymeleaf which has dependencies on
> com.fasterxml.jackson.ocre etc that are not deployed in Sling and it also
> looks like they are not deployed by any other bundle.
> 
> A sample does not much good if I cannot build and install it, right?

*sigh

> I am pretty fluent with package dependencies and so if I cannot
> figure it out in an acceptable time frame then who will.

Stop whining and start reading, please.

> Any pointers on how to get this working would be very much
> appreciated.

The version of Fling is 0.0.1-SNAPSHOT which clearly indicates that it is work 
in progress. Fling itself depends on some snapshots namely Validation and 
Messaging (and therefore has to be adjusted sometimes when those dependencies 
do incompatible changes – see my latest commits). Fling's prerequisites are 
listed in the README: https://github.com/apache/sling/tree/trunk/samples/fling

How to install Scripting Thymeleaf is described in its README (and btw. 
Jackson is optional):
https://github.com/apache/sling/tree/trunk/contrib/scripting/org.apache.sling.scripting.thymeleaf

If you are unable to install those dependencies into Launchpad you can try 
with Sling's Karaf Distribution: 
https://github.com/apache/sling/tree/trunk/karaf

Start Karaf and open http://localhost:8181/system/console/features, install 
sling-launchpad-oak-tar and sling-samples-fling by clicking the play/install 
buttons on the right. Open http://localhost:8181/fling.html

O.

> Thanks - Andy Schaefer



Re: Fling Installation on Trunk

2017-03-28 Thread Oliver Lietz
On Tuesday 28 March 2017 10:07:00 Andreas Schaefer Sr. wrote:
> Hi Oliver

Hi Andy,

> It would be nice if the Readme would indicate that this is a work in
> progress to avoid users wasting time on a piece that is not ready
> for prime time. As the trunk is probably the first thing people
> get as Sling code this would be helpful I think.

the very first sentence says that this sample is using snapshots. People 
having no experience with Sling should not use trunk but releases.

> In my opinion an example should be plug and play. For anyone
> not very familiar with Sling this is disheartening and can turn them
> away from Sling. I hope that Fling eventually gets there but for
> now I pass as I don’t have the time to look into that (have my own
> little peeve Sling project).

The Fling sample is using modules (from trunk) which cannot be part of 
Launchpad – that means no plug and play with Launchpad (using Sling Karaf 
makes it plug and play though).

Nevertheless it works for others and some find it quite useful. I'm sorry that 
it doesn't work for you.

Regards,
O.

> Thanks - Andy Schaefer
> 
> > On Mar 28, 2017, at 1:22 AM, Oliver Lietz <apa...@oliverlietz.de> wrote:
> > 
> > On Monday 27 March 2017 13:05:38 Andreas Schaefer Sr. wrote:
> >> Hi
> >> 
> >> I tried to install Fling from the Samples but failed with the latest
> >> Sling.
> >> 
> >> First I had to install Sling Messaging and Sling Query but then
> >> I gave up on Sling Thymeleaf which has dependencies on
> >> com.fasterxml.jackson.ocre etc that are not deployed in Sling and it also
> >> looks like they are not deployed by any other bundle.
> >> 
> >> A sample does not much good if I cannot build and install it, right?
> > 
> > *sigh
> > 
> >> I am pretty fluent with package dependencies and so if I cannot
> >> figure it out in an acceptable time frame then who will.
> > 
> > Stop whining and start reading, please.
> > 
> >> Any pointers on how to get this working would be very much
> >> appreciated.
> > 
> > The version of Fling is 0.0.1-SNAPSHOT which clearly indicates that it is
> > work in progress. Fling itself depends on some snapshots namely
> > Validation and Messaging (and therefore has to be adjusted sometimes when
> > those dependencies do incompatible changes – see my latest commits).
> > Fling's prerequisites are listed in the README:
> > https://github.com/apache/sling/tree/trunk/samples/fling
> > 
> > How to install Scripting Thymeleaf is described in its README (and btw.
> > Jackson is optional):
> > https://github.com/apache/sling/tree/trunk/contrib/scripting/org.apache.sl
> > ing.scripting.thymeleaf
> > 
> > If you are unable to install those dependencies into Launchpad you can try
> > with Sling's Karaf Distribution:
> > https://github.com/apache/sling/tree/trunk/karaf
> > 
> > Start Karaf and open http://localhost:8181/system/console/features,
> > install
> > sling-launchpad-oak-tar and sling-samples-fling by clicking the
> > play/install buttons on the right. Open http://localhost:8181/fling.html
> > 
> > O.
> > 
> >> Thanks - Andy Schaefer




Re: Fling Installation on Trunk

2017-03-31 Thread Oliver Lietz
On Wednesday 29 March 2017 12:42:52 Bertrand Delacretaz wrote:
> On Tue, Mar 28, 2017 at 8:48 PM, Oliver Lietz <apa...@oliverlietz.de> wrote:
> > -...The Fling sample is using modules (from trunk) which cannot be part of
> > Launchpad...
> > 
> > Nevertheless it works for others and some find it quite useful...
> 
> I have added a warning about snapshots to the Fling sample in
> http://svn.apache.org/r1789329 - hopefully this helps and if not feel
> free to tweak.

Thanks, Bertrand. I made the warning bold to be even more obvious.

O.

> -Bertrand



Re: Fling Installation on Trunk

2017-04-02 Thread Oliver Lietz
On Saturday 01 April 2017 13:25:49 Roy Teeuwen wrote:
> Hey Andreas,
> 
> You can make your own custom launchpads with a maven project.
> 
> In your pom.xml you use the following plugin:
> 
> 
> org.apache.sling
> slingstart-maven-plugin
> true
> 
> 
> Until sling 9 is released you use the following snapshot dependency, or you
> could also use sling version 8:

Sling 8 is too old for Scripting Thymeleaf 1.1.0.

Regards,
O.

> 
> 
> org.apache.sling
> org.apache.sling.launchpad
> 9-SNAPSHOT
> slingstart
> 
> 
> Add a boot.txt in the directory src/main/provisioning containing the
> following info:
> 
> [feature name=:boot]
> 
> [artifacts]
> org.apache.sling/org.apache.sling.launchpad/9-SNAPSHOT/slingstart
> 
> Add any txt file in the same directory to add your custom stuff you need.
> For example add a thymeleaf.txt containing:
> 
> [feature name=thymeleaf]
> 
> # Add the dependencies on the Model exporter
> [artifacts]
>org.attoparser/attoparser/2.0.2.RELEASE
>org.unbescape/unbescape/1.1.4.RELEASE
>org.apache.servicemix.bundles/org.apache.servicemix.bundles.ognl/3.2_1
>org.javassist/javassist/3.20.0-GA
>org.apache.sling/org.apache.sling.scripting.thymeleaf/1.1.1-SNAPSHOT
> 
> Now build your project, and in your target folder you will have your custom
> created launchpad jar
> 
> Greets,
> Roy
> 
> > On 31 Mar 2017, at 23:39, Andreas Schaefer Sr. <schaef...@me.com> wrote:
> > 
> > For something else I delved into Sling Provisioning and I
> > came up with a way to import Thymeleaf. Not sure if  that
> > is the best way but it seems to work.
> > 
> > When I add a file called thymeleaf.txt to
> > launchpad/builder/src/main/provisioning with that content:
> > 
> > [feature name=thymeleaf]
> > 
> > # Add the dependencies on the Model exporter
> > [artifacts]
> > 
> >org.attoparser/attoparser/2.0.2.RELEASE
> >org.unbescape/unbescape/1.1.4.RELEASE
> >org.apache.servicemix.bundles/org.apache.servicemix.bundles.ognl/3.2_1
> >org.javassist/javassist/3.20.0-GA
> >org.apache.sling/org.apache.sling.scripting.thymeleaf/1.1.1-SNAPSHOT
> > 
> > Build and start sling (just the builder) I have thymeleaf installed and
> > prepped and ready.
> > 
> > So I am wondering if there is a better way or if I can create my own
> > provisioning models but keep them in a separate folder.
> > 
> > Thanks - Andy Schaefer
> > 
> >> On Mar 28, 2017, at 1:22 AM, Oliver Lietz <apa...@oliverlietz.de> wrote:
> >> 
> >> On Monday 27 March 2017 13:05:38 Andreas Schaefer Sr. wrote:
> >>> Hi
> >>> 
> >>> I tried to install Fling from the Samples but failed with the latest
> >>> Sling.
> >>> 
> >>> First I had to install Sling Messaging and Sling Query but then
> >>> I gave up on Sling Thymeleaf which has dependencies on
> >>> com.fasterxml.jackson.ocre etc that are not deployed in Sling and it
> >>> also
> >>> looks like they are not deployed by any other bundle.
> >>> 
> >>> A sample does not much good if I cannot build and install it, right?
> >> 
> >> *sigh
> >> 
> >>> I am pretty fluent with package dependencies and so if I cannot
> >>> figure it out in an acceptable time frame then who will.
> >> 
> >> Stop whining and start reading, please.
> >> 
> >>> Any pointers on how to get this working would be very much
> >>> appreciated.
> >> 
> >> The version of Fling is 0.0.1-SNAPSHOT which clearly indicates that it is
> >> work in progress. Fling itself depends on some snapshots namely
> >> Validation and Messaging (and therefore has to be adjusted sometimes
> >> when those dependencies do incompatible changes – see my latest
> >> commits). Fling's prerequisites are listed in the README:
> >> https://github.com/apache/sling/tree/trunk/samples/fling
> >> 
> >> How to install Scripting Thymeleaf is described in its README (and btw.
> >> Jackson is optional):
> >> https://github.com/apache/sling/tree/trunk/contrib/scripting/org.apache.s
> >> ling.scripting.thymeleaf
> >> 
> >> If you are unable to install those dependencies into Launchpad you can
> >> try
> >> with Sling's Karaf Distribution:
> >> https://github.com/apache/sling/tree/trunk/karaf
> >> 
> >> Start Karaf and open http://localhost:8181/system/console/features,
> >> install
> >> sling-launchpad-oak-tar and sling-samples-fling by clicking the
> >> play/install buttons on the right. Open http://localhost:8181/fling.html
> >> 
> >> O.
> >> 
> >>> Thanks - Andy Schaefer




Re: Fling Installation on Trunk

2017-04-01 Thread Oliver Lietz
On Friday 31 March 2017 14:39:46 Andreas Schaefer Sr. wrote:
> For something else I delved into Sling Provisioning and I
> came up with a way to import Thymeleaf. Not sure if  that
> is the best way but it seems to work.
> 
> When I add a file called thymeleaf.txt to
> launchpad/builder/src/main/provisioning with that content:
> 
> [feature name=thymeleaf]
> 
> # Add the dependencies on the Model exporter
> [artifacts]
> org.attoparser/attoparser/2.0.2.RELEASE
> org.unbescape/unbescape/1.1.4.RELEASE
> org.apache.servicemix.bundles/org.apache.servicemix.bundles.ognl/3.2_1
> org.javassist/javassist/3.20.0-GA
> org.apache.sling/org.apache.sling.scripting.thymeleaf/1.1.1-SNAPSHOT
> 
> Build and start sling (just the builder) I have thymeleaf installed and
> prepped and ready.
> 
> So I am wondering if there is a better way or if I can create my own
> provisioning models but keep them in a separate folder.

That way is totally perfect, but you can use Scripting Thymeleaf 1.1.0 of 
course.

Feel free to open an issue if you want Scripting Thymeleaf be part of 
Launchpad builder. We should provide run modes for Sightly and Thymeleaf then 
until SLING-4330 is done as both use .html extension per default which leads 
to errors when running both.

Regards,
O.

> Thanks - Andy Schaefer




Re: preparing sling deployment in production

2017-10-18 Thread Oliver Lietz
On Thursday 12 October 2017 14:52:55 Ioan Eugen Stan wrote:
> Hello,

Hi,

> I'm working to prepare our deployment of Sling based CMS in production.
> I could use some feedback and help to secure Sling. I wish to reduce the
> attack surface by removing features that are not needed in my setup.
> This work should help other people with their particular setups.
> 
> To bootstrap the process I created a git repo to serve as a sandbox [1].
> The README there has more information on the goals and what you will
> find in the repo. Contributions are more than welcomed.
> 
> First feedback: I did not found a quick way to get started in building
> my custom distribution. Eventually I copy-pasted that project and
> updated the pom.xml [2].  This initial step could be made easier by
> Sling - maybe a maven artifact?
> 
> 
> I would like to reduce the attack surface of Sling by removing all the
> dependencies that I don't use.
> 
> One problem that I have is that is difficult to find out what is used
> and what is not.

why not starting the other way round and only install what you need?
Have a look at Sling's Karaf Features:
https://github.com/apache/sling/tree/trunk/karaf

Regards,
O.

> I plan to use Sling + Composum + Oak RDMBS. That means I could get rid
> of Mongo, Slinghsot, Webdav dependencies and other.
> 
> We don't plan to use Sling features yet except the Composum
> functionality. After we get some experience with Sling we will be using
> it more and more.
> 
> Since I plan to work in Cluster mode, I might deploy the removed
> functionality (Webdav, etc) on another server (maybe not public ?)
> 
> Could you help me out to identify/split these services?
> 
> 
> Regards,
> 
> [1] https://github.com/netdava/sling-cms-sandbox
> 
> [2]
> http://altereos.com/2017/05/how-to-create-a-custom-distribution-of-apache-sl
> ing-to-run-your-sling-application/



Re: help with my first sling app

2018-05-29 Thread Oliver Lietz
On Monday 28 May 2018 23:07:57 Ioan Eugen Stan wrote:
> Hello Oliver,

Hi,

> I saw your presentation(s) on thymeleaf and Sing and I was hoping for
> some feedback from you :).
> 
> I saw the sample and I am aware of Sling Models but I try to keep it as
> simple as possible. I am already deep enough with new tech.
> 
> Regarding thymeleaf and sling do you know where I can find examples on
> how to use OGNL in templates? All my tries failed so far. 
> 
> After going through the documentation over and over again I think that I
> may have to write some servlets to make what I want.

a servlet for OGNL? No. You already showed some expressions in your code... so 
what is not working? Basic OGNL is used in Fling sample and in Scripting 
Thymeleaf's ITs. More advanced examples should be in Thymeleaf's 
documentation.

> 
> I was hoping (and still do) to get away easy and just do:
> 
> 
> 
> |rednerer = sling.getService(ThymeleafRenderer )|
> |
> |body = renderer.render(content, context)
> |
> |
> |send the response by wrapping body into layout. ||
> |
> |
> |||
> |
> |
> |I will have to rethink my strategy in terms of an osgi service / custom
> 
> resource maybe and use sling.include()? Still struggling to navigate all
> of what Sling has to offer. I think this should help
> 
> ||https://cwiki.apache.org/confluence/display/SLING/Scripting+variables .

Look again into the Fling sample: There is content from JCR rendered by a 
Thymeleaf script (page.content), i18n used for UI elements (main use case) and 
a servlet which renders a Thymeleaf template (not using Sling Scripting).

I'm usually not using i18n in projects for content but for UI elements and 
messages only. The structure in JCR looks always similar:

/content/sites/project/country/language/...

HTH,
O.


> On 28.05.2018 18:12, Oliver Lietz wrote:
> > On Monday 28 May 2018 11:50:25 Ioan Eugen Stan wrote:
> >> Score 1 for me 99 for Sling.
> >> 
> >> I found out how to use resources in sling templates with thymeleaf.
> >> 
> >> My *ieugen/page* page  looks like this and it works. Now let's see if I
> >> can manage to render the content using the thymeleaf rendering service
> >> or another way.
> >> 
> >> Note to who is reading: Is there a simpler/better way to solve this?
> >> 
> >> 
> >> 
> >> 
> >> 
> >> 
> >> 
> >>   
> >>   
> >> SIMPLE PAGE
> >>   
> >>   
> >> 
> >> 
> >> 
> >> 
> > 
> > There is a sample for Thymeleaf with Sling Models:
> > 
> > https://github.com/apache/sling-samples/tree/master/fling
> > 
> > Are you aware of it? Tip: Use Sling Models.
> > 
> > Regards,
> > O.
> > 
> >> On 28.05.2018 03:35, Ioan Eugen Stan wrote:
> >>> Hello,
> >>> 
> >>> (Dear lazy sling community)
> >>> 
> >>> I'm working to implement my first sling application / pages. We have to
> >>> deploy a *Terms of use* page that need to be translated across multiple
> >>> languages.
> >>> 
> >>> I figured this should be easy with Sling - and it's not quite as I
> >>> expected :( .
> >>> 
> >>> The solution that I have settled for in my head is using thymeleaf
> >>> templates and sling i18n with json files. However I need some help
> >>> implementing it.
> >>> 
> >>> I'm sharing what is in my head, please help correct if I am wrong. I
> >>> have been at this (and other sling related stuff - content loading, etc)
> >>> for the past few days.
> >>> 
> >>> My page is going to live in */content**/terms-of-us**e.ht**ml*. It's a
> >>> *nt:file*, *sling:res**ource* with *sling:resourceType =
> >>> **ieugen**/page*
> >>> .
> >>> 
> >>> Now, let's put translations for the page under
> >>> */lib/trans**lations/content/t**erms**-of-use**.htlm/{english**.**json*,
> >>> *deuts**ch.json}* . These files should follow the format described in
> >>> [1].
> >>> 
> >>> My goal is for the content of the "/content/terms-of-use.html" node to
> >>> be a thymeleaf template itself. This template will use attributes like
> >>> th-text="#{text-id-from-translation-file}".
> >>> 
> >>> Now, the script "*ieu**gen/page*" should to the following:
> >>> 
> >>> - take the content of the JCR node
> >>> 
&g

Re: help with my first sling app

2018-05-28 Thread Oliver Lietz
On Monday 28 May 2018 11:50:25 Ioan Eugen Stan wrote:
> Score 1 for me 99 for Sling.
> 
> I found out how to use resources in sling templates with thymeleaf.
> 
> My *ieugen/page* page  looks like this and it works. Now let's see if I
> can manage to render the content using the thymeleaf rendering service
> or another way.
> 
> Note to who is reading: Is there a simpler/better way to solve this?
> 
> 
> 
> 
> 
> 
>   
> SIMPLE PAGE
>   
> 
> 
> 

There is a sample for Thymeleaf with Sling Models:

https://github.com/apache/sling-samples/tree/master/fling

Are you aware of it? Tip: Use Sling Models.

Regards,
O.

> On 28.05.2018 03:35, Ioan Eugen Stan wrote:
> > Hello,
> > 
> > (Dear lazy sling community)
> > 
> > I'm working to implement my first sling application / pages. We have to
> > deploy a *Terms of use* page that need to be translated across multiple
> > languages.
> > 
> > I figured this should be easy with Sling - and it's not quite as I
> > expected :( .
> > 
> > The solution that I have settled for in my head is using thymeleaf
> > templates and sling i18n with json files. However I need some help
> > implementing it.
> > 
> > I'm sharing what is in my head, please help correct if I am wrong. I
> > have been at this (and other sling related stuff - content loading, etc)
> > for the past few days.
> > 
> > My page is going to live in */content**/terms-of-us**e.ht**ml*. It's a
> > *nt:file*, *sling:res**ource* with *sling:resourceType = **ieugen**/page*
> > .
> > 
> > Now, let's put translations for the page under 
> > */lib/trans**lations/content/t**erms**-of-use**.htlm/{english**.**json*,
> > *deuts**ch.json}* . These files should follow the format described in [1].
> > 
> > My goal is for the content of the "/content/terms-of-use.html" node to
> > be a thymeleaf template itself. This template will use attributes like
> > th-text="#{text-id-from-translation-file}".
> > 
> > Now, the script "*ieu**gen/page*" should to the following:
> > 
> > - take the content of the JCR node
> > 
> > - load the proper translation file based on the requested language and
> > the node currently being rendered.
> > 
> > - render the content of the node (thymeleaf template - or any other
> > template language - handlebars?? ) by providing a context with the
> > translation files loaded
> > 
> > - extra: the content might be rendered inside a layout defined by
> > ieugen/page script - with common headers and footers.
> > 
> > My goal is to be able to create pages that are easy to internationalize.
> > 
> > So far I have a few setbacks:
> > 
> > 1. I don't know how to render resource properties.
> > 
> > 2. I don't know how to render a template inside a script.
> > 
> > So far, my script looks like this:
> > 
> > 
> >  > data-th-with="*valueMap=${resource.adaptTo(@org.apache.sling.api.resource.
> > ValueMap@class)}*"> 
> >   
> > 
> > 
> > 
> >   This works prints the resource 
> >   *This fails -
> > valueMap is null* 
> >   
> >  *How do I render node content here**?**Node content is a
> > thymeleaf? template* 
> >   
> > 
> > Common footer
> > 
> > 
> > 
> > Thanks,
> > 
> > [1]
> > https://sling.apache.org/documentation/bundles/internationalization-suppor
> > t-i18n.html#json-file-based



Re: system users administrative session

2018-02-06 Thread Oliver Lietz
On Sunday 04 February 2018 12:57:10 Andres Bott wrote:
> Hello all,

Hi  Andres,

> I'm currently using this code in my bundle
> http://svn.apache.org/viewvc/sling/trunk/launchpad/test-services/src/main/ja
> va/org/apache/sling/launchpad/testservices/repository/SystemUsersInitializer
> .java?view=markup=1727946 to execute a repoinit file to create
> service users.
> 
> I wanted to know if there is a better/intended way to execute repoinit
> on bundle installation
> 
> and since loginAdministrative is deprecated, how should we run this code
> in the future?

you can provide OSGi configurations with Repoinit statements in your bundle. 
To get an idea have a look at SLING-7177[1], Karaf Configs[2] and how to 
install OSGi configurations from bundles[3].

Regards,
O.

[1] https://issues.apache.org/jira/browse/SLING-7177
[2] 
https://github.com/apache/sling-org-apache-sling-karaf-configs/tree/master/src/main/resources
[3] 
http://sling.apache.org/documentation/bundles/configuration-installer-factory.html

> Regards
> Andres



Re: Problem with pax exam test using repository

2018-01-17 Thread Oliver Lietz
On Wednesday 17 January 2018 11:47:17 Christian Schneider wrote:
> I found the solution to my problem with AbstractMethodError:
> org.apache.jackrabbit.core.XASessionImpl.getItemOrNull
> 
> The problem was that I loaded org.apache.sling.jcr.jackrabbit.server whioch
> bundles parts of jackrabbit core .. so this way XASessionImpl was used
> instead of the correct org.apache.jackrabbit.oak.jcr.session.SessionImpl
> Not sure why I had that bundle at all but removing it solved the issue.

Therefore we have (Pax Exam) Options:

slingQuickstartOakTar(string, int)[1]

You will have every bundle and configuration in situ for running Sling with 
Oak Tar repository.

Regards,
O.

[1] 
https://github.com/apache/sling-org-apache-sling-testing-paxexam/blob/master/src/main/java/org/apache/sling/testing/paxexam/SlingOptions.java#L940

> Christian
> 
[...]



Re: Problem with pax exam test using repository

2018-01-16 Thread Oliver Lietz
On Tuesday 16 January 2018 18:22:41 Christian Schneider wrote:
> I am trying the test some code that works on the sling repository.

Hi Christian,

> I have problems getting the pax exam test working. I get the exception
> below:
> 
> java.lang.AbstractMethodError:
> org.apache.jackrabbit.core.XASessionImpl.getItemOrNull(Ljava/lang/String;)Lj
> avax/jcr/Item; at
> org.apache.sling.jcr.resource.internal.helper.jcr.JcrItemResourceFactory.ge
> tItemOrNull(JcrItemResourceFactory.java:184)
> 
> Full exception:
> https://gist.github.com/cschneider/d01d087244dc0650b3751e99a70b6a72
> 
> This might be some incompatibility between the jackrabbit core bundle and
> the sling bundles.
> I use:
> oak 1.7.6
> jackrabbit 2.15.4

don't use odd (minor) versions (even not in tests). Those are cut from 
unstable branches.

> mavenBundle("org.apache.sling", "org.apache.sling.jcr.resource", "2.9.2"),
> 
> mavenBundle("org.apache.sling", "org.apache.sling.resourceresolver",
> "1.5.22"),
> 
> mavenBundle("org.apache.sling", "org.apache.sling.serviceusermapper",
> "1.2.4"),
> 
> Any idea what is wrong with my setup and which versions I should combine to
> avoid this issue?

You can try with Sling's Pax Exam support (Sling Testing PaxExam):
http://sling.apache.org/documentation/development/testing-paxexam.html

At least look at Sling's Karaf Features[1] or Testing PaxExam's 
VersionResolver[2] to see which versions play together (backed by lots of 
ITs).

Regards,
O.

[1] 
https://github.com/apache/sling-org-apache-sling-karaf-features/blob/master/src/main/feature/feature.xml

[2] 
https://github.com/apache/sling-org-apache-sling-testing-paxexam/blob/master/src/main/java/org/apache/sling/testing/paxexam/SlingVersionResolver.java

> Christian



Re: Status of sling provisioning model & documentation of models

2018-10-08 Thread Oliver Lietz
On Saturday 06 October 2018 18:35:51 Jörg Hoh wrote:
> Hi

Hi Jörg,

> while working on SLING-7960 I also came across the integration tests for
> the jcr-repoinit module and found if very interesting. Compared to other
> (older) approaches it looks pretty slick and uses the sling feature module
> (provisioning model? Unsure about the correct naming) to build the runtime
> environment for the integration tests, see [1] and the pom [2].
> 
> But I wonder where the artifacts it depends on are documented. The website
> where the Sling provisioning model lacks this (even the reference to it).
> Is there documentation out there I missed?

did you see the note on [3]? "The OSGi Feature Model is meant to eventually 
replace the Sling Provisioning Model. If you are starting a new Sling project, 
please ask on the Sling developers list about the status of the Feature Model 
to figure out which is best suited to your needs."

Which other approaches do you mean? Manually setting up a Sling instance is of 
course highly discouraged and we have an extension for Pax Exam which takes 
care: http://sling.apache.org/documentation/development/testing-paxexam.html

Regards,
O.


> Jörg
> 
> [1]
> https://github.com/apache/sling-org-apache-sling-jcr-repoinit/blob/master/sr
> c/test/provisioning/it-model.txt [2]
> https://github.com/apache/sling-org-apache-sling-jcr-repoinit/blob/master/po
> m.xml#L111
> 
> [3] https://sling.apache.org/documentation/development/slingstart.html



Re: Regarding sling clam api

2018-11-01 Thread Oliver Lietz
On Friday 26 October 2018 00:05:07 Swathi V wrote:
> Hi Team,

Hi Swati,

> Our application is central repository to store digital assets and we use
> Adobe experience manager to build the application. And Aem tool don’t have
> inbuilt feature to enable antivirus scan for digital assets . And I heard
> sling clam api serve this feature. I would like to know how to utilise the
> clam bundle for antivirus scan of digital assets before storing into
> application.

Sling Commons Clam[1] and Sling Clam[2] are built for AEM 6.4 but do not 
depend on any AEM API.

Sling Commons Clam doesn't even depend on Sling, JCR or Jackrabbit/Oak API and 
can be used in any OSGi runtime with DS/SCR.

How to utilize the two Clam modules depends on your requirements and 
processes.

If you want to scan assets use the ClamService from Sling Commons Clam in an 
asset workflow.

If you want to scan all binary (and string) data which gets stored in Oak use 
the NodeObservingJcrPropertyDigger.

You have to disable SecureNodeStoreAccess in AEM to make the NodeStore 
available for NodeObservingJcrPropertyDigger either manually or via 
ComponentDisabler (recommended) from ACS AEM Commons[3].

Regards,
O.

[1] https://github.com/apache/sling-org-apache-sling-commons-clam
[2] https://github.com/apache/sling-org-apache-sling-clam
[3] 
https://adobe-consulting-services.github.io/acs-aem-commons/features/osgi-disablers/component-disabler/index.html

> Thanks,
> Swati



Re: Integration testing based on feature model

2019-07-23 Thread Oliver Lietz
On Monday, July 22, 2019 10:14:45 PM CEST Jörg Hoh wrote:
> Hi,

Hi Jörg,

> I recently came across the IT tests of the Sling Event bundle [1], and my
> personal opinion is that having such a listing of bundles in the
> testclasses is hard to maintain.
> 
> From what I understand, the feature model is already able to collect a set
> of artifacts and start a process on top of that. This could be very helpful
> to define the environment in which integration testing could happen: I
> define an environment as feature-model, which is augmented with the bundle
> under test and the testcases, everything is started/deployed and the tests
> are running afterwards.
> 
> This should allow us to use "pre-packaged" environment definitions (e.g.
> "sling11-core") which we could use (and easily update) for these IT tests.
> 
> At the moment this is just an idea, and I do neither have the time nor the
> knowledge to implement that. But it would make the creation of integration
> tests with Sling much easier.
> 
> WDYT?

It's already implemented based on Sling's Karaf Features:

https://sling.apache.org/documentation/development/testing-paxexam.html

Regards,
O.

> Jörg
> 
> 
> 
> [1]
> https://github.com/apache/sling-org-apache-sling-event/blob/master/src/test/
> java/org/apache/sling/event/it/AbstractJobHandlingTest.java






Re: Integration testing based on feature model

2019-07-24 Thread Oliver Lietz
On Tuesday, July 23, 2019 10:08:39 PM CEST Jörg Hoh wrote:
> Hi Oli,
> 
> 
> Am Di., 23. Juli 2019 um 16:12 Uhr schrieb Oliver Lietz <
> 
> apa...@oliverlietz.de>:
> > It's already implemented based on Sling's Karaf Features:
> > 
> > https://sling.apache.org/documentation/development/testing-paxexam.html
> 
> Hm, it still seems to me that the list of bundles and their versions are
> all hardcoded (see SlingOptions.java). I would like to use complete
> features (as provided by the feature model), because these features are
> often already defined and used elsewhere (thus reuse), and secondly I can
> reference them from within the POM (instead of hardcoding them in a bundle).
> 
> As much as I like your approach, I see the problem that the maven
> dependencies and the IT dependencies are maintained twice and also at
> different locations.

The Sling "Features" (Options) provided by Testing PaxExam are really coming 
from this feature file (no double maintenance):

https://github.com/apache/sling-org-apache-sling-karaf-features/blob/master/
src/main/feature/feature.xml

The two Java files are a result of applying the Handlebars templates on the 
data from Sling's Karaf Features:

https://github.com/apache/sling-org-apache-sling-testing-paxexam/tree/master/
src/main/resources/templates

We have some ITs where the Provisioning Model is used, but three (probably 
more) shortcomings which come to mind are:
  - dedicated module for ITs required 
  - single instance for all tests (?)
  - no way to adjust Features

Solved already with Testing PaxExam, for adjusting a Feature (Option) see

https://github.com/apache/sling-org-apache-sling-jcr-contentloader/blob/
master/src/test/java/org/apache/sling/jcr/contentloader/it/
ContentloaderTestSupport.java#L89

It takes the existing Option (Features), removes the 
org.apache.sling.jcr.contentloader bundle and the current bundle from build is 
added as usual. The first two points are default.

There are of course more goodies included and having direct access into the 
OSGi container makes several workarounds unnecessary (via HTTP: deploying 
bundles, waiting for services, running tests...).

Regards,
O.

> Jörg







Re: Mock resource resolver factory for use in OSGi?

2020-03-04 Thread Oliver Lietz
On Wednesday, March 4, 2020 11:59:32 AM CET Bertrand Delacretaz wrote:
> Hi,

Hi,

> On Wed, Mar 4, 2020 at 11:03 AM Christian Schneider
> 
>  wrote:
> > ...Now I also need to change nodes in the repository. Is there a way to
> > test this without the full sling pax exam testing?..

Do you need a RRF *and* a full (read/write) JCR?

> You might "manually" setup just the bundles that you need to get a
> ResourceResolverFactory service, but I've found that to be a pain
> while sling-org-apache-sling-testing-paxexam has that all sorted out
> for you.
> 
> At the expense of tests that might take longer to startup due to more
> baggage than you actually need - which you can trim by removing
> specific bundles [1] but that might get you back to hunting for just
> the right set of dependencies.

See also features (Adjusting of provided Options):

https://sling.apache.org/documentation/development/testing-paxexam.html

> But https://sling.apache.org/documentation/development/sling-mock.html
> might help? Those mocks are well tested.

Regards,
O.

> -Bertrand
> 
> [1]
> https://github.com/apache/sling-org-apache-sling-servlets-resolver/blob/138
> 6d2eca418eee37a08b9c488ba657c7a1032d3/src/test/java/org/apache/sling/servlet
> s/resolver/it/ServletResolverTestSupport.java#L96






Re: Mock resource resolver factory for use in OSGi?

2020-03-04 Thread Oliver Lietz
On Wednesday, March 4, 2020 12:01:41 PM CET Carsten Ziegeler wrote:
> ok, i see...I would assume there is some pax magic to include the
> testing jar as a bundle and then you just register the mock as a service

You can of course wrap the JAR and use it with a base Sling from Testing 
PaxExam and register the mock as service.

Regards,
O.


> Regards
> Carsten
> 
> On 04.03.2020 11:28, Christian Schneider wrote:
> > Testing the config admin functionality outside of OSGi is not very
> > reliable
> > as it misses many possible error cases.
> > My current tests that involve config admin already use OSGi.
> > Now that I added a @Reference ResourceResolverFactory my OSGi tests of
> > course stopped working as it can not be found.
> > 
> > Christian
> > 
> > Am Mi., 4. März 2020 um 11:04 Uhr schrieb Carsten Ziegeler <
> > 
> > cziege...@apache.org>:
> >> If you just need config admin and a RRF, why do you need OSGi for the
> >> test?
> >> 
> >> Carsten
> >> 
> >> On 04.03.2020 11:02, Christian Schneider wrote:
> >>> I am currently working on a small bundle that will run in sling. It
> >>> needs
> >>> only config admin and ResourceResolverFactory.
> >>> 
> >>> For the tests I am currently using plain pax exam. I started with just
> >> 
> >> the
> >> 
> >>> need for config admin.
> >>> Now I also need to change nodes in the repository. Is there a way to
> >>> test
> >>> this without the full sling pax exam testing?
> >>> 
> >>> I thought about exporting a mock ResourceResolverFactory as a service
> >>> but  org.apache.sling.testing.resourceresolver-mock
> >>> is not even a bundle.
> >>> So I can not use it in OSGi.
> >>> 
> >>> Is there any easy way to use a mock  ResourceResolverFactory in OSGi?
> >>> 
> >>> Christian
> >> 
> >> --
> >> --
> >> Carsten Ziegeler
> >> Adobe Research Switzerland
> >> cziege...@apache.org






Re: Everyone ACL Read on /

2020-03-12 Thread Oliver Lietz
On Wednesday, March 11, 2020 10:05:20 PM CET Cris Rockwell wrote:
> I think your response helps in a way. I am asking why this default exists.
> Is there is a rationale for the default or no? Based on your response, it
> should be deleted if the application needs to control ACL read permissions,
> and maybe there is no reason for the default other than to ensure everyone
> can read everything under /content.

It is convenient for the Sling Starter and the sample applications.

When you build your own Sling application (incl. starter or features) you 
usually configure it depending on your requirements (Tar vs Mongo, blob store, 
etc.) and use not the default values.

What is your use case? How would removing the read permission for /content 
help?

O.

> Cris
> 
> > On Mar 11, 2020, at 3:42 PM, Oliver Lietz  wrote:
> > 
> > On Wednesday, March 11, 2020 8:34:12 PM CET Cris Rockwell wrote:
> >> Hi Oliver
> >> 
> >> Thanks for the fast reply. Can I ask the exact same set of questions
> >> about
> >> default jcr:read access for everyone on /content? Is that required?
> > 
> > It depends on your application. If you do not want to serve content to
> > anonymous users/clients you can remove the read permissions.
> > You can even remove the whole JCR from Sling if you do not want to serve
> > content from it.
> > 
> > Does it help?
> > 
> > Regards,
> > O.
> > 
> >> Cris Rockwell
> >> 
> >>> On Mar 11, 2020, at 3:05 PM, Oliver Lietz  wrote:
> >>> 
> >>> On Wednesday, March 11, 2020 6:50:51 PM CET Cris Rockwell wrote:
> >>>> Hello Sling Users
> >>> 
> >>> Hi Cris,
> >>> 
> >>>> When I launch Sling, there is an ACL for jrc:read for the everyone
> >>>> ‘principle' on jcr:root, as described in the repoinit.txt
> >>>> http://archive.apache.org/dist/sling/org.apache.sling.launchpad-9.jar
> >>>> <http://archive.apache.org/dist/sling/org.apache.sling.launchpad-9.jar>
> >>>> 
> >>>> I have found these resources:
> >>>> 
> >>>> http://apache-sling.73963.n3.nabble.com/Principal-quot-everyone-quot-is
> >>>> -n
> >>>> ot-> clear-td4078544.html
> >>>> <http://apache-sling.73963.n3.nabble.com/Principal-quot-everyone-quot-i
> >>>> s
> >>>> -no t-clear-td4078544.html>
> >>>> https://jackrabbit.apache.org/oak/docs/security/user/membership.html
> >>>> <https://jackrabbit.apache.org/oak/docs/security/user/membership.html>
> >>>> 
> >>>> But I still have questions:
> >>>> * Why is everyone by default granted jcr:read access to the whole
> >>>> repository? * If you wanted to control access, isn’t it better to
> >>>> whitelist
> >>>> (i.e. grant) instead of deny? * If the everyone ACL jcr:read rule was
> >>>> deleted from root, what problems should be expected?
> >>> 
> >>> That was changed several years ago already, see SLING-6130 and current
> >>> setup:
> >>> 
> >>> https://github.com/apache/sling-org-apache-sling-starter/blob/master/src
> >>> /m
> >>> ain/ provisioning/repoinit.txt
> >>> 
> >>> Regards,
> >>> O.
> >>> 
> >>>> Many thanks!







Re: Everyone ACL Read on /

2020-03-11 Thread Oliver Lietz
On Wednesday, March 11, 2020 8:34:12 PM CET Cris Rockwell wrote:
> Hi Oliver
> 
> Thanks for the fast reply. Can I ask the exact same set of questions about
> default jcr:read access for everyone on /content? Is that required?

It depends on your application. If you do not want to serve content to 
anonymous users/clients you can remove the read permissions.
You can even remove the whole JCR from Sling if you do not want to serve 
content from it.

Does it help?

Regards,
O.


> Cris Rockwell
> Applications Architect Sr
> College of Literature, Science, and the Arts | University of Michigan
> LSA Technology Services | 6503 Haven Hall | 505 S. State Street | Ann Arbor,
> MI I 48109 Desk: 734.763.6818 | Email: cmroc...@umich.edu
> 
> > On Mar 11, 2020, at 3:05 PM, Oliver Lietz  wrote:
> > 
> > On Wednesday, March 11, 2020 6:50:51 PM CET Cris Rockwell wrote:
> >> Hello Sling Users
> > 
> > Hi Cris,
> > 
> >> When I launch Sling, there is an ACL for jrc:read for the everyone
> >> ‘principle' on jcr:root, as described in the repoinit.txt
> >> http://archive.apache.org/dist/sling/org.apache.sling.launchpad-9.jar
> >> <http://archive.apache.org/dist/sling/org.apache.sling.launchpad-9.jar>
> >> 
> >> I have found these resources:
> >> 
> >> http://apache-sling.73963.n3.nabble.com/Principal-quot-everyone-quot-is-n
> >> ot-> clear-td4078544.html
> >> <http://apache-sling.73963.n3.nabble.com/Principal-quot-everyone-quot-is
> >> -no t-clear-td4078544.html>
> >> https://jackrabbit.apache.org/oak/docs/security/user/membership.html
> >> <https://jackrabbit.apache.org/oak/docs/security/user/membership.html>
> >> 
> >> But I still have questions:
> >> * Why is everyone by default granted jcr:read access to the whole
> >> repository? * If you wanted to control access, isn’t it better to
> >> whitelist
> >> (i.e. grant) instead of deny? * If the everyone ACL jcr:read rule was
> >> deleted from root, what problems should be expected?
> > 
> > That was changed several years ago already, see SLING-6130 and current
> > setup:
> > 
> > https://github.com/apache/sling-org-apache-sling-starter/blob/master/src/m
> > ain/ provisioning/repoinit.txt
> > 
> > Regards,
> > O.
> > 
> >> Many thanks!
> >> Cris Rockwell
> >> Applications Architect Sr
> >> College of Literature, Science, and the Arts | University of Michigan
> >> LSA Technology Services | 6503 Haven Hall | 505 S. State Street | Ann
> >> Arbor, MI I 48109 Desk: 734.763.6818 | Email: cmroc...@umich.edu






Re: Everyone ACL Read on /

2020-03-11 Thread Oliver Lietz
On Wednesday, March 11, 2020 6:50:51 PM CET Cris Rockwell wrote:
> Hello Sling Users

Hi Cris,

> When I launch Sling, there is an ACL for jrc:read for the everyone
> ‘principle' on jcr:root, as described in the repoinit.txt
> http://archive.apache.org/dist/sling/org.apache.sling.launchpad-9.jar
> 
> 
> I have found these resources:
> 
> http://apache-sling.73963.n3.nabble.com/Principal-quot-everyone-quot-is-not-> 
> clear-td4078544.html
>  t-clear-td4078544.html>
> https://jackrabbit.apache.org/oak/docs/security/user/membership.html
> 
> 
> But I still have questions:
> * Why is everyone by default granted jcr:read access to the whole
> repository? * If you wanted to control access, isn’t it better to whitelist
> (i.e. grant) instead of deny? * If the everyone ACL jcr:read rule was
> deleted from root, what problems should be expected?

That was changed several years ago already, see SLING-6130 and current setup:

https://github.com/apache/sling-org-apache-sling-starter/blob/master/src/main/
provisioning/repoinit.txt

Regards,
O.


> Many thanks!
> Cris Rockwell
> Applications Architect Sr
> College of Literature, Science, and the Arts | University of Michigan
> LSA Technology Services | 6503 Haven Hall | 505 S. State Street | Ann Arbor,
> MI I 48109 Desk: 734.763.6818 | Email: cmroc...@umich.edu






Re: Calling OSGi Service from JSP

2020-04-08 Thread Oliver Lietz
On Wednesday, April 8, 2020 1:42:17 PM CEST JCR wrote:
> On 07.04.20 12:06, Bertrand Delacretaz wrote:
> > Hi,

Hi,

> > On Tue, Apr 7, 2020 at 11:37 AM JCR  wrote:
> >> ...But what I
> >> observe is, that MANIFEST.MF gets overriden on every change and even
> >> package-info is present, the package in there gets set back to to
> >> private...> 
> > It looks like your build setup is causing trouble.
> > 
> > I recommend that you compare your project with one of ours that you
> > can gradually adapt to your needs.
> > 
> > You might start with
> > https://github.com/apache/sling-org-apache-sling-commons-mime for
> > example, which is a small standalone module change the public package
> > and/or class names for your initial test, build, verify that you can
> > use those services from your JSP and then gradually adapt or compare
> > with your code.
> > 
> > Hope this helps,
> > -Bertrand
> 
> Hi Bertrand,
> 
> Nice hearing from you!
> 
> Well, the problem is that there's a lot of outdated docu around. For
> instance, above commons-mime package contains a bnd.bnd file, which is
> not generated anymore (well, perhaps it is, but just process temporary).
> Among many others, the examples at felix.apache.org are not current,
> too. So, I've been chasing a lot of phantoms in the past few days. That
> wasn't the fun Sling usually provides.
> 
> As mentioned in my mail, there must be some hidden detail. Well, after
> days of research, I found it in the readme of the bnd-maven-plugin
> (https://github.com/bndtools/bnd/blob/master/maven/bnd-maven-plugin/README.m
> d):
> 
> 
>  
> 
> 
> So this is the secret sauce that does the job. That needs to be added to
> the project's pom.xml.

Well, it's not a secret. See my previous mail where I pointed to Sling Parent 
and the configuration for bnd Maven Plugin. It contains the default for all 
Sling bundle modules. Additional configuration is added in bnd.bnd file (the 
file is not generated but created manually).

Regards,
O.

> Keywords: solved, osgi, bundle, bnd-maven-plugin 1.2.2, export-package,
> felix
> 
> -Juerg







Re: Calling OSGi Service from JSP

2020-03-29 Thread Oliver Lietz
On Sunday, March 29, 2020 5:14:48 PM CEST JCR wrote:
> > Am Sa., 28. März 2020 um 20:55 Uhr schrieb JCR :
> >> Hello

Hi Juerg,

> >> I wrote a very simple POJO, built it as OSGi bundle and deployed it to
> >> Sling11. Here's the source:
> >> 
> >> package rome.testly.testly1;
> >> import org.osgi.service.component.annotations.Component;
> >> 
> >> @Component(service=SlingFutil.class )
> >> public class SlingFutil {
> >> 
> >>   public String nonsense() {
> >>   
> >>   return "This is nonsense";
> >>   
> >>   }
> >> 
> >> }
> >> 
> >> The component/service appears on the Felix console:
> >> 
> >> symbolic Name   testly1
> >> Version 0.0.1.202003271754
> >> Bundle Location
> >> 
> >>   /home/juerg/eclipse-workspace/testly1/target/classes
> >> 
> >> Last Modification   Fri Mar 27 18:54:01 CET 2020
> >> Start Level 20
> >> Exported Packages   ---
> >> Imported Packages   org.osgi.framework,version=1.9.0 from
> >> org.apache.felix.framework (0)
> >> 
> >> org.osgi.service.component,version=1.4.0 from org.apache.felix.scr (50)
> >> 
> >> org.slf4j,version=1.7.25 from slf4j.api (20)
> >> 
> >> Service ID 477 
> >> Types: java.lang.Runnable
> >> Component Name: rome.testly.testly1.SimpleDSComponent
> >> Component ID: 323
> >> Service ID 478 
> >> Types: rome.testly.testly1.SlingFutil
> >> Component Name: rome.testly.testly1.SlingFutil
> >> Component ID: 324
> >> 
> >> 
> >> 
> >> Now I try to call SlingFutil.nonsense() from a JSP:
> >> 
> >> ...
> >> <%@ page import="javax.jcr.*,
> >> 
> >>   org.apache.sling.api.resource.Resource,
> >>   rome.testly.testly1.*"
> >> 
> >> %>
> >> ...
> >> <%
> >> SlingFutil some = new SlingFutil();
> >> %>
> >> ...
> >> 
> >> At this point, the JSP compiler complains that the type (SlingFutil) is
> >> unknown.
> >> I also tried
> >> 
> >> sling.getService(rome.testly.testly1.SlingFutil.class);
> >> 
> >> instead, but the result is the same.
> >> 
> >> This used to work well at BND times of Sling, so I don't know what's
> >> wrong with this R7 code.
> >> 
> >> Thanks,
> >> Juerg
> > 
> > On 28.03.20 21:15, Jörg Hoh wrote:
> >> Hi Juerg,
> >> 
> >> Looks like your bundle does not export that class, so it's not available
> >> outside of that bundle.
> >> 
> >> Jörg
> 
> Hi Jörg
> 
> The class is declared as @Component (see above). Do I need any other
> declaration to make the export happen?

It depends on the plugin (and version) you use. See the configuration in Sling 
Parent for bnd Maven Plugin:

-exportcontents: ${removeall;${packages;VERSIONED};${packages;CONDITIONAL}}

https://github.com/apache/sling-parent/blob/master/sling-bundle-parent/
pom.xml#L71

And here is an example for a versioned (and therefore exported) package:

@Version("2.3.4")
package org.apache.sling.api;

https://github.com/apache/sling-org-apache-sling-api/blob/master/src/main/
java/org/apache/sling/api/package-info.java

Regards,
O.


> Thanks,
> Juerg






Re: Apache Sling Commons Messaging Mail

2020-12-28 Thread Oliver Lietz
On Monday, December 28, 2020 9:46:09 AM CET Nicola Cisternino wrote:
> Hi Dan

Hi Nicola,

> and thank you for replay ...
> ... excuse me ... but ...
> https://github.com/klcodanr/danklco.com-site-cna/blob/cloud-native-sling/fea
> ture/src/main/features/site.json link is broken :-(

Please also have a look at the integration tests:

https://github.com/apache/sling-org-apache-sling-commons-messaging-mail/blob/
master/src/test/java/org/apache/sling/commons/messaging/mail/it/tests/
SimpleMailServiceIT.java#L152

Commons Messaging Mail requires a CryptoService which decrypts the SMTP 
password. You could also create your own.

Regards,
O.


> Il 12/26/20 5:19 PM, Daniel Klco ha scritto:
> > Hey Nicola,
> > 
> > The Apache Sling Commons Messaging Mail bundle uses Commons Crypto to
> > encrypt the password for the SMTP server. You'll need to provide the
> > 
> > configuration for Commons Crypto including:
> > -
> > org.apache.sling.commons.crypto.jasypt.internal.JasyptRandomIvGenerato
> > rRegistrar -
> > org.apache.sling.commons.crypto.jasypt.internal.JasyptRandomSaltGenera
> > torRegistrar -
> > org.apache.sling.commons.crypto.jasypt.internal.JasyptStandardPBEStrin
> > gCryptoService -
> > org.apache.sling.commons.crypto.internal.FilePasswordProvider
> > 
> > You can see the configuration (sans secrets) I use on my personal website
> > here:
> > https://github.com/klcodanr/danklco.com-site-cna/blob/cloud-native-sling/f
> > eature/src/main/features/site.json
> > 
> > Once that's set up correctly you should see an option under the 'Available
> > crypto service' here:
> > [serverhost:port]/system/console/sling-commons-crypto-encrypt
> > 
> >  From there you can enter your password to encrypt it and use it in
> > 
> > the org.apache.sling.commons.messaging.mail.internal.SimpleMailService
> > configuration.
> > 
> > Hope that helps!
> > -Dan
> > 
> > On Wed, Dec 23, 2020 at 5:36 AM Nicola Cisternino  
wrote:
> >> Hi all
> >> 
> >> I'm trying to compose and send emails (Sling 12) using Apache Sling
> >> Commons Messaging Mail Bundle.
> >> Can someone help me define a complete setup ?
> >> All web examples refer to the use of AEM (CQ Mail service) :-(
> >> I've already:
> >> 1) installed bundle (org.apache.sling.commons.messaging.mail-1.0.0.jar)
> >> 2) solved bundle dependencies installing:
> >> - javax.mail-1.6.2.jar
> >> - org.apache.sling.commons.crypto-1.0.0.jar
> >> - org.apache.sling.commons.messaging-1.0.0.jar
> >> 4) created and saved a "Simple mail service" configuration (configMgr)
> >> 3) created a component using documentation example
> >> (https://github.com/apache/sling-org-apache-sling-commons-messaging-mail)
> >> 
> >> I don't see any log error ... but ...
> >> 
> >> @Reference
> >> MailService mailService;
> >> 
> >>  is always null 
> >> 
> >> Thanks a lot.
> >> Nicola.






[ANN] Apache Sling Commons Messaging Mail 2.0.0 released

2021-12-13 Thread Oliver Lietz
The Apache Sling team is pleased to announce the release of Apache Sling 
Commons Messaging Mail 2.0.0

Commons Messaging Mail provides a simple layer on top of Jakarta Mail 2.0 
including a message builder and a service to send mails via SMTPS.

This is the very first release of Apache Sling which is using the new Jakarta 
namespace.

https://github.com/apache/sling-org-apache-sling-commons-messaging-mail

This release is available from https://sling.apache.org/downloads.cgi

Building from verified sources is recommended, but convenience binaries are
also available via Maven:


  org.apache.sling
  org.apache.sling.commons.messaging.mail
  2.0.0

 
Release Notes:

- Switch to Jakarta Mail and Activation APIs
- Support for arrays and collections of addresses in MessageBuilder
- Improved Header parameters support
- Support for server identity check (checks are enabled by default)
- Dedicated Properties and Session per SimpleMessageBuilder instance
- Various updates and code checks


A security issue ("SMTPS server hostname not checked when making TLS 
connection to SMTPS server") was reported by Michael Lescisin and accepted by 
the project. The issue is tracked as CVE-2021-44549.

The SimpleMailService in Commons Messaging Mail 1.0 lacks an option to enable 
server identity checks for the shared mail session.
A user could enable these checks nevertheless by accessing the session via the 
message created by SimpleMessageBuilder and setting the property 
mail.smtps.ssl.checkserveridentity to true.

- https://javaee.github.io/javamail/docs/SSLNOTES.txt
- 
https://javaee.github.io/javamail/docs/api/com/sun/mail/smtp/package-summary.html
- https://github.com/eclipse-ee4j/mail/issues/429

Enjoy!

-The Apache Sling team






Re: Server-Side Testing

2022-09-27 Thread Oliver Lietz
On Monday, 26 September 2022 18:21:26 CEST Andreas Schaefer wrote:
> Hi
> 
> As mentioned in my previous email I ran into an issue with Composum as I
> could not open it with the Pax Tests even though I included composum()
> setup.
> 
> I could fix that with this line:
> 
> mavenBundle().groupId("org.apache.geronimo.bundles").artifactId("jstl").vers
> ion("1.2_1"),

Could you please check if it works with 4.0.0-SNAPSHOT? There are some changes 
related to Scripting JSP (Composum option was renamed to composumNodes).

> I have another question regarding uploading a file. I was able to use Jsoup
> to upload a file to create a file node in Sling. I am wondering if there is
> a way with PaxExam to do that with a direct API exam as my tests are not
> there to test the REST Api but rather to make sure my code is working?
> 
> Anyhow Jsoup will work fine if it is the only way.

You could use any Sling or Jackrabbit/Oak service (as Eric already 
highlighted) or Sling Initial Content.

O.


> - Andy
> 
> > On Aug 23, 2022, at 11:03 AM, Eric Norman  wrote:
> > 
> > Hi Andy,
> > 
> > What I usually do for debugging/inspecting the pax exam instance is to add
> > optional configuration to enable remote debugging (see [1]).  Then you can
> > set a breakpoint in your test code and it will stop there for you to take
> > a
> > look around.
> > 
> > One example of this is at:
> > 1, AuthFormTestSupport.java#L94
> > <https://github.com/apache/sling-org-apache-sling-auth-form/blob/0040aac8a
> > 3a89a0cfc4727f2802bd560803c4c8a/src/test/java/org/apache/sling/auth/form/i
> > t/AuthFormTestSupport.java#L94>
> > 
> > 
> > Hope that helps.
> > 
> > Regards,
> > Eric
> > 
> > 
> > On Mon, Aug 22, 2022 at 2:14 PM Andreas Schaefer
> > 
> > 
> > wrote:
> >> Hi Oliver
> >> 
> >> I am making good progress but I noticed that I cannot get composum up on
> >> both 3.1.0 or 3.0.0 which is the current version I am using because I am
> >> still running against Sling 11.
> >> 
> >> The issues I see is: 'The absolute uri: http://java.sun.com/jsp/jstl/core
> >> cannot be resolved’
> >> 
> >> Also is there a way to keep the Sling instance running (something like
> >> keep running flag) after the tests were done in case I need to
> >> investigate
> >> an issue with the Sling instance like bundles dependencies etc?
> >> 
> >> Thanks - Andy
> >> 
> >>> On Aug 15, 2022, at 2:20 AM, Oliver Lietz  wrote:
> >>> 
> >>> On Sunday, 14 August 2022 23:15:16 CEST Andreas Schaefer wrote:
> >>>> Hi
> >>> 
> >>> Hi Andy,
> >>> 
> >>>> I am working on some sling components and want to IT test them within
> >> 
> >> the
> >> 
> >>>> server to avoid client-side polling.
> >>>> 
> >>>> It looks like there are two ways to do that:
> >>>> 
> >>>> - Junit Servlet
> >>>> - Sling Testing Server Setup and Teleporter
> >>>> 
> >>>> Does Sling do any server side testing?
> >>>> What is the currently support way of doing server side tests?
> >>> 
> >>> Running tests inside the OSGi container is the default when using OPS4J
> >> 
> >> Pax
> >> 
> >>> Exam. See the list of Sling modules using Sling's Testing PaxExam and
> >> 
> >> have a
> >> 
> >>> look what the ITs are doing to get some ideas:
> >>> 
> >>> https://sling.apache.org/documentation/development/testing-paxexam.html
> >>> 
> >>> Let me know if more documentation is needed.
> >>> 
> >>> HTH,
> >>> O.
> >>> 
> >>>> Thanks - Andy






Re: Server-Side Testing

2022-09-08 Thread Oliver Lietz
On Monday, 22 August 2022 23:14:12 CEST Andreas Schaefer wrote:
> Hi Oliver

Hi Andy,

> I am making good progress but I noticed that I cannot get composum up on
> both 3.1.0 or 3.0.0 which is the current version I am using because I am
> still running against Sling 11.

Testing PaxExam provides an option for Composum - have you checked?

https://github.com/apache/sling-org-apache-sling-testing-paxexam/blob/
9451309852a723aecd3395b72f05f356e4d55baf/src/main/java/org/apache/sling/
testing/paxexam/SlingOptions.java#L1199

> The issues I see is: 'The absolute uri: http://java.sun.com/jsp/jstl/core
> cannot be resolved’
> 
> Also is there a way to keep the Sling instance running (something like keep
> running flag) after the tests were done in case I need to investigate an
> issue with the Sling instance like bundles dependencies etc?

I'm not aware of a feature in Pax Exam and how it could work as multiple 
instances could be started for a single test class (per test method).
If you want to keep an instance up for some time you could reference a non-
existing service via @Inject (with filter incl. timeout). Or debug as described 
by Eric.

Do you have some code to share? Or are you able to discuss on Slack?

Regards,
O.


> Thanks - Andy
> 
> > On Aug 15, 2022, at 2:20 AM, Oliver Lietz  wrote:
> > 
> > On Sunday, 14 August 2022 23:15:16 CEST Andreas Schaefer wrote:
> >> Hi
> > 
> > Hi Andy,
> > 
> >> I am working on some sling components and want to IT test them within the
> >> server to avoid client-side polling.
> >> 
> >> It looks like there are two ways to do that:
> >> 
> >> - Junit Servlet
> >> - Sling Testing Server Setup and Teleporter
> >> 
> >> Does Sling do any server side testing?
> >> What is the currently support way of doing server side tests?
> > 
> > Running tests inside the OSGi container is the default when using OPS4J
> > Pax
> > Exam. See the list of Sling modules using Sling's Testing PaxExam and have
> > a look what the ITs are doing to get some ideas:
> > 
> > https://sling.apache.org/documentation/development/testing-paxexam.html
> > 
> > Let me know if more documentation is needed.
> > 
> > HTH,
> > O.
> > 
> >> Thanks - Andy






Re: Server-Side Testing

2022-08-15 Thread Oliver Lietz
On Sunday, 14 August 2022 23:15:16 CEST Andreas Schaefer wrote:
> Hi

Hi Andy,

> I am working on some sling components and want to IT test them within the
> server to avoid client-side polling.
> 
> It looks like there are two ways to do that:
> 
> - Junit Servlet
> - Sling Testing Server Setup and Teleporter
> 
> Does Sling do any server side testing?
> What is the currently support way of doing server side tests?

Running tests inside the OSGi container is the default when using OPS4J Pax 
Exam. See the list of Sling modules using Sling's Testing PaxExam and have a 
look what the ITs are doing to get some ideas:

https://sling.apache.org/documentation/development/testing-paxexam.html

Let me know if more documentation is needed.

HTH,
O.


> Thanks - Andy