schema location
Hi, I'm setting up my eclipse environment, and I thought I'd add the schemas for sling and jcr to the xml catalog that's on eclipse so that I can get context validation and auto-completion while I'm working on xml. I can't seem to locate those schemas in the bundles. Can someone point me to where I can find those? Thanks -Jason
RE: schema location
Thanks Felix, would those namespace definitions be accessible or are they more of an abstract concept? -Jason -Original Message- From: Felix Meschberger [mailto:fmesc...@adobe.com] Sent: Tuesday, September 04, 2012 2:45 PM To: users@sling.apache.org Subject: Re: schema location Hi What do you mean by schemas ? In the sense of XML Schemas ? There is no such thing in Sling and JCR. We do have a few namespace definitions to be able to differentiate nodes and properties in the way namespaces are used in XML to differentiate elements. But there is no XML Schema involved on the Sling and JCR level. Regards Felix Am 04.09.2012 um 12:34 schrieb Jason Bailey: Hi, I'm setting up my eclipse environment, and I thought I'd add the schemas for sling and jcr to the xml catalog that's on eclipse so that I can get context validation and auto-completion while I'm working on xml. I can't seem to locate those schemas in the bundles. Can someone point me to where I can find those? Thanks -Jason
Sling :redirect as a security vulnerability
We're reviewing our recent security scans and we had a red flag on the usage of :redirect in our forms. It's being flagged as a potential attack vector as you can set this to any url. So knowing that these reports are indicators of potential problems and not always valid. I wanted to get some clarity from the sling user base to whether they have seen this before, is there a setting that I am missing? Or do I need to do some additional to prevent this from being an issue? Etc. Thanks -Jason Bailey
adding java classes into the jcr
We're using CQ5 pretty extensively for our external web presence and I'm in the process of evaluating Sling for a wider range of use cases internally. One of the questions that comes up on a regular basis is whether we are able to define a java object alongside the JSP when we are creating a widget. So that we can potentially implement a very specific business logic and have it co-located with the presentation logic. There seems to be support in Sling for compiling java classes located in the JCR, but there's a lack of clarity on when/how that occurs. Any information would be appreciated. -Jason
RE: adding java classes into the jcr
Hi Olaf I appreciate the feedback. You're correct that this is a desire to modularize on the component level, as I stated in my email, when I'm dealing with people ramping up on the framework this question of co-location is the most common I get. I had half expected that someone had implemented something where the default java ScriptEngine was removed and an Event based compiler added to handle java files. Not that I'm bothered too much, I'm doing more due diligence then anything else. I will check out slice and neba. -Jason From: Olaf Otto o...@x100.de Sent: Thursday, July 17, 2014 6:06 PM To: users@sling.apache.org Subject: RE: adding java classes into the jcr Hi Jason I take it the idea is to strictly modularize on a CQ component level? While there is some support for placing java files in the JCR and use them as servlets for specific resources, this approach is somewhat exotic and you're better of providing application code - such as models - in OSGi bundles. This is much better in terms of separation of layers and concerns, and allows you to use all the OSGi goodness Felix provides, such as SCR (http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-pl ugin/scr-annotations.html) as well as any of the following solutions: 1.) The #1 way to provide specific models for resource in Sling is to use an AdapterFactory so you can .adaptTo(SpecificModel.class) from a resource, e.g. in a view, taglib, servlet and the like. (http://sling.apache.org/documentation/the-sling-engine/adapters.html) 2.) Nowadays, you can do so declaratively using Sling Models (http://sling.apache.org/documentation/bundles/models.html). This also gives you Resource - to - model mapping, i.e. mapping properties and resources onto a POJO java model. 3.) If you'd like to leverage google guice, you can use Slice from cognifide (http://www.cognifide.com/blogs/cq/make-your-cq-life-easier-with-slice/). This will also support .adaptTo and provides resource to model mapping. 4.) Finally, there is NEBA (http://neba.io), which gives you .adaptTo + resource to model mapping and Spring MVC plus some more features. I'm a bit biased towards that one - since I am NEBA's lead developer ;-) Kind regards, Olaf -Original Message- From: Jason Bailey [mailto:jason.bai...@sas.com] Sent: Mittwoch, 16. Juli 2014 21:07 To: users@sling.apache.org Subject: adding java classes into the jcr We're using CQ5 pretty extensively for our external web presence and I'm in the process of evaluating Sling for a wider range of use cases internally. One of the questions that comes up on a regular basis is whether we are able to define a java object alongside the JSP when we are creating a widget. So that we can potentially implement a very specific business logic and have it co-located with the presentation logic. There seems to be support in Sling for compiling java classes located in the JCR, but there's a lack of clarity on when/how that occurs. Any information would be appreciated. -Jason
Sling Standalone Application won't start
Got an odd situation here. I'm unable to start the Sling Standalone Application (org.apache.sling.launchpad-6-standalone.jar) it throws the following 19.07.2014 08:25:18.502 *ERROR* [main] Failed to Start OSGi framework org.osgi.framework.BundleException: Uncaught Instantiation Issue: java.lang.ArrayIndexOutOfBoundsException: -1 at org.apache.sling.launchpad.base.impl.Sling.init(Sling.java:245) at org.apache.sling.launchpad.base.app.MainDelegate$1.init(MainDelegate.java:159) at org.apache.sling.launchpad.base.app.MainDelegate.start(MainDelegate.java:159) at org.apache.sling.launchpad.app.Main.startSling(Main.java:244) at org.apache.sling.launchpad.app.Main.init(Main.java:107) at org.apache.sling.launchpad.app.Main.main(Main.java:56) Caused by: java.lang.ArrayIndexOutOfBoundsException: -1 running OpenJDK Runtime Environment (rhel-2.4.7.2.el7_0-x86_64 u55-b13) OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode) -Jason
RE: Sling Standalone Application won't start
Well that's a kick in the teeth to my plans to get it adopted. Does anyone on the list know when the next stable release is? From: Robert Munteanu robert.munte...@gmail.com Sent: Saturday, July 19, 2014 3:58 PM To: users@sling.apache.org Subject: Re: Sling Standalone Application won't start Hi Jason, On Jul 19, 2014 8:55 PM, Jason Bailey jason.bai...@sas.com wrote: Got an odd situation here. I'm unable to start the Sling Standalone Application (org.apache.sling.launchpad-6-standalone.jar) it throws the following 19.07.2014 08:25:18.502 *ERROR* [main] Failed to Start OSGi framework org.osgi.framework.BundleException: Uncaught Instantiation Issue: java.lang.ArrayIndexOutOfBoundsException: -1 I think that you're running the launchpad against a Java version that is too new. You should either use an older version of Java or build a launchpad from trunk. The trunk versions support all released versions of Java. Robert and at org.apache.sling.launchpad.base.impl.Sling.init(Sling.java:245) at org.apache.sling.launchpad.base.app.MainDelegate$1.init(MainDelegate.java:159) at org.apache.sling.launchpad.base.app.MainDelegate.start(MainDelegate.java:159) at org.apache.sling.launchpad.app.Main.startSling(Main.java:244) at org.apache.sling.launchpad.app.Main.init(Main.java:107) at org.apache.sling.launchpad.app.Main.main(Main.java:56) Caused by: java.lang.ArrayIndexOutOfBoundsException: -1 running OpenJDK Runtime Environment (rhel-2.4.7.2.el7_0-x86_64 u55-b13) OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode) -Jason
RE: HATEOAS compliant json self/child references from sling?
Not unless you add it yourself. As a note, you may not want to design your application where you are relying on the default json renderer to supply information to the front end client. It can reveal more information and structure then a lot of people are comfortable with. -Original Message- From: Bruce Edge [mailto:bruce.e...@nextissuemedia.com] Sent: Wednesday, November 12, 2014 1:49 PM To: users Subject: HATEOAS compliant json self/child references from sling? Can one retrieve HATEOAS format responses form sling? % curl -qu admin:admin http://localhost:8090/var/content.tidy.json { jcr:createdBy: admin, jcr:mimeType: application/octet-stream, jcr:created: Sat Nov 08 2014 16:17:51 GMT-0800, jcr:lastModified: Sat Nov 08 2014 16:17:51 GMT-0800, jcr:primaryType: sling:Folder } Using a HATEOAS server I would expect something like this: { jcr:createdBy: admin, jcr:mimeType: application/octet-stream, jcr:created: Sat Nov 08 2014 16:17:51 GMT-0800, jcr:lastModified: Sat Nov 08 2014 16:17:51 GMT-0800, jcr:primaryType: ³sling:Folder _links:{ self:{ href:http://localhost:8090/var/content; } } } Is it possible to have sling insert both self and child references into all json responses? -Bruce
RE: HATEOAS compliant json self/child references from sling?
So when you say data structure you're talking about nodes in the jcr structure and their contents. Each node is wrapped in concept called a resource. When you wrote the url earlier http://localhost:8090/var/content.tidy.json the underlying REST engine is finding the resource at the path /var/content/ which in this case is specifically a jcr node resource and then it's looking at the extension you're using and selecting an OSGi that renders that service. In this case there's a specific resource renderer that handles json and it's the renderer that is taking your request for that resource and returning the json object. You could actually get the entire tree that you are authorized to see with one call by using http://localhost:8090/var/content.infinity.json More information at http://sling.apache.org/documentation/the-sling-engine/architecture.html -Original Message- From: Bruce Edge [mailto:bruce.e...@nextissuemedia.com] Sent: Wednesday, November 12, 2014 2:29 PM To: users@sling.apache.org Subject: Re: HATEOAS compliant json self/child references from sling? I must be missing some fundamental concept here. I'm not sure exactly what you mean by default json rendering of resources. I'm after structure data here, not actual content rendering. I just want to be able to obtain self child references in json responses so the UI can create the appropriate tree structure to navigate the JCR data. The actual representation of the leaf node data will be specific to that data type and handled by the client UI. -Bruce From: Sarwar Bhuiyan sarwar.bhui...@gmail.commailto:sarwar.bhui...@gmail.com Reply-To: users@sling.apache.orgmailto:users@sling.apache.org users@sling.apache.orgmailto:users@sling.apache.org Date: Wednesday, November 12, 2014 at 11:20 AM To: users@sling.apache.orgmailto:users@sling.apache.org users@sling.apache.orgmailto:users@sling.apache.org Subject: Re: HATEOAS compliant json self/child references from sling? Bruce, it's not the format that's the problem. It's the default json rendering of resources that's the issue for things exposed to the public side. Typically what we do for the web side of things is either write our own servlets or component jsps where we can have more control of what to output. On Wednesday, November 12, 2014, Bruce Edge bruce.e...@nextissuemedia.commailto:bruce.e...@nextissuemedia.com wrote: I can understand how exposing that level of structure may be a risk in some circumstances but it allows for a huge leg up on the client side code. Things like https://github.com/GonzaloAlvarez/restangular-hateoas provide a superbly simple way to wrap a UI around the whole thing if you have HATEOAS on the server side. It's as close as you can get to a CRUD UI with seriously minimal code. Also, this is the data format provided by spring-data-rest, so it's a format that already has wide acceptance. I suppose one could enable this only for specific paths if security was a concern. -Bruce From: Jason Bailey jason.bai...@sas.commailto:jason.bai...@sas.com javascript:;mailto: jason.bai...@sas.commailto:jason.bai...@sas.com javascript:; Reply-To: users@sling.apache.orgmailto:users@sling.apache.org javascript:;mailto: users@sling.apache.orgmailto:users@sling.apache.org javascript:; users@sling.apache.orgmailto:users@sling.apache.org javascript:;mailto:users@sling.apache.org javascript:; Date: Wednesday, November 12, 2014 at 11:05 AM To: users@sling.apache.orgmailto:users@sling.apache.org javascript:;mailto:users@sling.apache.org javascript:; users@sling.apache.orgmailto:users@sling.apache.org javascript:;mailto: users@sling.apache.orgmailto:users@sling.apache.org javascript:; Subject: RE: HATEOAS compliant json self/child references from sling? Not unless you add it yourself. As a note, you may not want to design your application where you are relying on the default json renderer to supply information to the front end client. It can reveal more information and structure then a lot of people are comfortable with. -Original Message- From: Bruce Edge [mailto:bruce.e...@nextissuemedia.com javascript:;] Sent: Wednesday, November 12, 2014 1:49 PM To: users Subject: HATEOAS compliant json self/child references from sling? Can one retrieve HATEOAS format responses form sling? % curl -qu admin:admin http://localhost:8090/var/content.tidy.json { jcr:createdBy: admin, jcr:mimeType: application/octet-stream, jcr:created: Sat Nov 08 2014 16:17:51 GMT-0800, jcr:lastModified: Sat Nov 08 2014 16:17:51 GMT-0800, jcr:primaryType: sling:Folder } Using a HATEOAS server I would expect something like this: { jcr:createdBy: admin, jcr:mimeType: application/octet-stream, jcr:created: Sat Nov 08 2014 16:17:51 GMT-0800, jcr:lastModified: Sat Nov 08 2014 16:17:51 GMT-0800, jcr:primaryType: ³sling:Folder _links:{ self:{ href:http://localhost:8090/var/content; } } } Is it possible to have sling insert
RE: Equivalent to modeshape Sequencers or equivalent in sling/oak?
I did something similar with a side project that I work on, I created an import service that would be called based on the mimetype of the data that was being delivered. OOTB, there is a ContentImporter service, but it seems to be deliberately limited to a single implementation. IMHO I would love to see the ability to expand on that so that one could implement a custom ContentImporter for specific types. -Jason -Original Message- From: Bruce Edge [mailto:bruce.e...@nextissuemedia.com] Sent: Thursday, November 13, 2014 2:25 PM To: users@sling.apache.org Subject: Equivalent to modeshape Sequencers or equivalent in sling/oak? I'm writing an jcr population module for some specific content archive types. I read about the idea of the mode shape sequencers here: https://docs.jboss.org/author/display/MODE/Sequencing Is there any similar functionality in sling/oak for ingesting standardized data formats? Conversely, are there any input processing modules or samples for extracting archives , of other bundled data into a JCR hierarchy? -Bruce
RE: SlingServlet paths/resourceType/etc for POST to nonexistent URLs in JCR
Bruce, How you would do this depends in part on what that servlet does that's listening at /var/cars/ If you have all the data that is supposed to be at a particular path then removing that custom servlet and using the built in content creation process detailed at http://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html Is probably your best bet. So that something like this curl -u admin:admin -F key1=value1 -F key2=value2 -F key3=value3 -F data=@filename localhost:8080/var/cars/fiat/124-F/1970 would generate that file structure, add all the keys and values as properties on the 1970 node and put your file beneath 1970. -Jason -Original Message- From: Bruce Edge [mailto:bruce.e...@nextissuemedia.com] Sent: Friday, November 14, 2014 10:23 AM To: users@sling.apache.org Subject: SlingServlet paths/resourceType/etc for POST to nonexistent URLs in JCR I have a SlingServlet working with a fixed length path, using sling.servlet.paths=/var/cars. Under this I have a fixed format hierarchy consisting of make, model, year. I can populate by passing make, model, year and data as POST parameters. curl -u admin:admin -F make=fiat -F model=124 -F year=1970 -F data=@filename localhost:8080/var/cars/ I'd like to handle POSTs to any path below the servlet's base path, e.g.: /var/cars/{make}/{model}/{year} eg: curl -u admin:admin -F date=@filename localhost:8080 /var/cars/content/fiat/124/1970 I don't see a way to specify paths beyond the base without something kludgy like appending the make/model/year after a selector, i.e.: /var/cars.json/fiat/124/1970 What's the recommended SlingServlet solution for pushing data into a sparse tree with lots of path name components? -Bruce
RE: Injecting OSGI services using sling models
That's an usual problem you're having. You should be able to see the service you've defined in the OSGi panel before executing the request that creates the model. -Jason From: Hasanein Khafaji hasanein@gmail.com Sent: Wednesday, November 19, 2014 6:54 AM To: users@sling.apache.org Subject: Re: Injecting OSGI services using sling models Sorry, I forgot to add that. It implements ManagedService. Do you think it has anything to do with the fact that the interface and the implementation are in different bundles, thus get loaded by a different class loader? and end up being incompatible when reflection is used to set one type to the other? I've tried o keep the interface and the implementation in a single bundle and it seems to be working now. But I am deviating from the project convention we have in place to keep interfaces in separate bundle than it's implementation. On Wed, Nov 19, 2014 at 11:43 AM, Felix Meschberger fmesc...@adobe.com wrote: Hi Could it be that you announce the component to be „ManagedService“ but the class does not implement it and thus the component cannot be instantiated at all ? Regards Felix Am 19.11.2014 um 12:32 schrieb Hasanein Khafaji hasanein@gmail.com: Let's assume that Bundle A defines a service interface and export the package that contains it to OSGi: Public interface ServiceInterface { . } Bundle B, provides an OSGi component/service that implement the service interface @Component(immediate = true, metatype = true) @Service(value = {ServiceInterface.class, ManagedService.class}) @org.apache.felix.scr.annotations.Properties({ @Property(name = Constants.SERVICE_PID, value = com.example.MyService), @Property(name = Constants.SERVICE_VENDOR, value = Contoso), @Property(name = Constants.SERVICE_DESCRIPTION, value = My Service), }) public class MyService implements ServiceInterface { ... } Bundle C, contains Sling model classes that needs to use the above service, we inject it using @Inject or @Inject @Source(osgi-service) as per Sling Model documentation @Model(adaptables = {Resource.class}) public class MyModel { @Inject private ServiceInterface serviceInterface; ... } The problem is that the service never get injected into the model as it should be, the Exception we get is thrown by the ModelAdapterFactory saying that it's unable to inject MyService into ServiceInterface as if they were an incompatible types but they are not. On Wed, Nov 19, 2014 at 9:24 AM, Sarwar Bhuiyan sarwar.bhui...@gmail.com wrote: Could you paste that bit of code please? On Wednesday, November 19, 2014, Hass Joseph Khafaji hasanein@gmail.com wrote: The model is simply a sling model class, not an osgi service at all. The model is being looked up via slightly, thus it has to be fully populated when that happen which require that the model invoke a service to obtain data from. Sling model documentation says that you can inject osgi services into sling models but that is not seem to be working. Sent from my iPhone On 19 Nov 2014, at 09:09, Sarwar Bhuiyan sarwar.bhui...@gmail.com javascript:; wrote: The model is not an OSGi service/component right? I'm not sure of why you need a reference to an osgi service in the model but you can probably use a setter by yourself but I still think you can just have another service which does the action on the model instead of the model calling the service. On Wednesday, November 19, 2014, Hass Joseph Khafaji hasanein@gmail.com javascript:; wrote: Hello, I am trying to inject OSGI service defined using scr annotation into a sling model class using the @inject annotation. What we seem to be getting is that the ModelAdapterFactory is unable to inject the service into the corresponding field as if it was an incompatible type. We not doing anything fancy here, it's just a simple service injection. Did anyone faced a similar issue in the past? Do we have to use custom injectors for this? Note: tried to use the @inject @source with an osgi-service but getting the same result. Cheers.
help needed problems with redirects and https
Our environment is set up where we have an apache instance with a dispatcher passing the requests back to our Sling instances. The apache instance prepends either /content/external1 or /content/external2 onto the request before sending it the sling instance(based on domain). In the sling instance we have the sling resource resolver configuration that will remove /content/external1 and /content/external2 from all outgoing paths. This worked fine in our older version of sling(cq5.5) but in our upgraded version(aem6.0) we have a difference with redirects. Previously the redirects would not have the protocol and host name, just the path .. something like /en_us/software/versions/foo now the redirect has the full pathing... http://www.sas.com/en_us/software/versions/foo. This is causing a problem as it always specified it as http:// Even when our external request that is hitting apache is in the form of https. Not sure if something changed in Sling or with the new Jetty servlet engine. Any help would be appreciated. -Jason
RE: Best practices for java DTOs to/from Sling
I'm going to chime in and say that I don't think you need to change your process. You mentioned defining the :operation=import which really threw me off since I associate that with a form posting and you mentioned JSON. I took a second look at the links that Julian sent out and there's a section which specifies updating a node via a post with JSON as the content format. this is the specific section. https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html#content-creation-or-modification There's some additional parameters there for modifying/replacing nodes :replace and :replaceProperties to be specific. This just might be an issue of adding one of these to the submission that's occurring. -Jason -Original Message- From: Henry Saginor [mailto:hsaginor.apa...@gmail.com] Sent: Monday, July 27, 2015 2:13 PM To: users@sling.apache.org Subject: Re: Best practices for java DTOs to/from Sling Are you using just Sling itself or a Sling based product like Adobe CQ/AEM? Which Sling UI are you referring to? Also how is you application deployed with Sling? Sling models, I think, is tightly coupled with Sling itself and has a dependency on OSGi container. JCR API supports remote access. Different protocols are supported - RMI or WebDav for example. At least Jackrabbit supports both. But I have not kept up with remoting support in OAK. And since Sling can be backed either by Jackrabbit or OAK you can do this with Sling (Sling Eclipse Tooling connects to the repository this way I believe). Also, considering what Jason mentioned regarding added support for content modification you might want to check what version of Sling Post servlet you are using. Check the version of the OSGi bundles in Felix Console and make sure they match versions mentioned in https://issues.apache.org/jira/browse/SLING-1172 https://issues.apache.org/jira/browse/SLING-1172. I do like what Sarwar suggested bellow to extend Sling yourself with custom post servlet(s). Don’t know why I did not think of responding with that myself. I would probably do that in actually. But as you can see you have several options. It really depends on your use case and preference. On Jul 27, 2015, at 10:37 AM, Sarwar Bhuiyan sarwar.bhui...@gmail.com wrote: If you are willing to deploy some code to sling (OSGi), you may be able to write sling servlets which do take a JSON payload and do whatever operations are necessary. That way, you can sort out any issues between the client (your spring code) and the server (sling/JCR). I brought up Sling Models only as a suggestion to be able to use the POJOs but it may not even be necessary. I find in the Sling world, using the maps works out best when it's flexibility of the data model you want since you can write some generic code for the servlets even if your data model changes slightly. I hope this helps a little. Sarwar On Mon, Jul 27, 2015 at 12:55 PM, Haefele, Michael michael-haef...@idexx.com wrote: Sarwar and Henry, Thank you for your help. I'm not entirely sure why we went with Sling as opposed to using JCR directly. I think the Sling GUI made a very good impression in the initial demo (which was before my time). We are primarily using it as an alternative database (with the hopes that using JCR will make it very easy to eventually mirror some/all of the data in the cloud). Is a hybrid system where we utilize JCR directly in some cases, but Sling in others possible/desirable? I'll also take a look at Sling Models. That sounds promising. -Original Message- From: Sarwar Bhuiyan [mailto:sarwar.bhui...@gmail.com] Sent: Thursday, July 23, 2015 1:03 AM To: users@sling.apache.org Subject: Re: Best practices for java DTOs to/from Sling Have a look at Sling Models. On Thu, Jul 23, 2015 at 12:32 AM, Henry Saginor hsaginor.apa...@gmail.com wrote: Hi Michael, Since Sling itself is a framework for building web applications with it’s own persistence and services layer it’s a bit unusual to get questions on integration with Spring here (I think). But I don’t know enough about your application and its use cases to question why you are doing this. ButI think you you can use JCR API to persist your DTOs. Look up JCR API and Apache Jackrabbit and OAK projects. Technically you could do away with Sling entirelly and use Apache Jackrabbit or OAK directly if all you are using Sling for is as document/content store. But again don’t know enough about your application. And I don’t really want to discourage you from using Sling since I am a big fan. :) Henry On Jul 22, 2015, at 1:36 PM, Haefele, Michael michael-haef...@idexx.com wrote: We have a Sling application that we're using basically as a database/file manager for portions of a java Spring application. In java we have a bunch of DTOs that we import by converting to json
RE: SlingServlet SO Question
Hi Chris, Can you capture what the post url looks like? -Jason -Original Message- From: Christopher Rockwell [mailto:cmroc...@umich.edu] Sent: Wednesday, July 15, 2015 2:08 PM To: users@sling.apache.org Subject: SlingServlet SO Question Hi all. I'm having trouble with a servlet that extends SlingAllMethodsServlet. I've posted about the problem ... http://stackoverflow.com/questions/31437806/custom-sling-post-servlet-not-working Any input would be much appreciated. Thanks Chris Rockwell LSA CMS/Web Services cmroc...@umich.edu
RE: Errorpage for the SlingPostServlet
Sandro, Have you had any luck with this? I wasn't aware that you could even use a component level error handling until I re-read the error handling page. I'm taking a look at the Resource Resolver code to try to get a better idea of the logic that was implemented. This is one of the times that I feel a resource type structure isn't always sufficient. I would much rather have an error handling solution that would resolve the servlet based on a path structure then a resource type. -Jason -Original Message- From: Sandro Boehme [mailto:sandro.boe...@gmx.de] Sent: Wednesday, July 15, 2015 5:26 PM To: users@sling.apache.org Subject: Re: Errorpage for the SlingPostServlet Hi Jason, I guess you mean general error handlers? In my case I would like to have an error handler for a specific resource type. This seem to work for a 500.jsp (as seen in the example) but I wonder if it's possible for a general error page as well. Best, Sandro Am 15.07.15 um 21:49 schrieb Jason Bailey: Sandro, I guess I haven't been keeping up, I thought error handlers had to be under /sling/servlet/errorhandler/ ??? Was that changed? -Jason -Original Message- From: Sandro Boehme [mailto:sandro.boe...@gmx.de] Sent: Wednesday, July 15, 2015 6:57 AM To: users@sling.apache.org Subject: Errorpage for the SlingPostServlet Hello again, as my message seem to get lost in the big traffic of the dev list and as it might not be a bug I'm posting it here again. I would like to have an error jsp that is shown on all errors of the Sling post servlet and that displays the according error message. Based on an example of Bertrand I would like to show what I mean here in detail: 1. Creating the container node for the resource type $ curl -u admin:admin -Fsling:resourceType=posterror http://localhost:8080/apps/posterror 2. Creating a simple html form $ echo 'htmlbodyform method=post input type=hidden name=:sendError value=true input type=text name=aProperty input type=submit /form/body/html' /tmp/posterror.jsp $ curl -u admin:admin -T/tmp/posterror.jsp http://localhost:8080/apps/posterror/posterror.jsp 3. The general error handler that I would like to show up because the post of the HTML form in the step before is not authenticated. $ echo 'This is a general error handler' /tmp/Throwable.jsp $ curl -u admin:admin -T /tmp/Throwable.jsp http://localhost:8080/apps/posterror/Throwable.jsp 4. The form whose submit should lead to the rendering of the Throwable.jsp. How can I make that happen? Is that a bug or is there an other way to do that? $ curl http://localhost:8080/apps/posterror.html 5. If I create a 500.jsp like this it gets rendered instead of the Throwable.jsp. Why is that the case as I would have expected it to be a 401 Unauthorized error? $ echo 'Error 500: %=request.getAttribute(javax.servlet.error.message)%, Exception: %=request.getAttribute(javax.servlet.error.exception)%' /tmp/500.jsp $ curl -u admin:admin -T /tmp/500.jsp http://localhost:8080/apps/posterror/500.jsp 6. Deleting the 500.jsp for debugging reasons $ curl -u admin:admin -F:operation=delete http://localhost:8080/apps/posterror/500.jsp Help is much appreciated! Thanks, Sandro
RE: sling-maven-plugin install goal issues
I'm reading Steven's concern as that the Sling plugin is not assuming the use of the Sling post handler. Which is preventing the use of the POST command to the desired location. Which is kind of odd. -Original Message- From: Stefan Seifert [mailto:sseif...@pro-vision.de] Sent: Wednesday, October 28, 2015 11:16 AM To: users@sling.apache.org Subject: RE: sling-maven-plugin install goal issues hello steven. i use a configuration just like this: ${server}/system/console ${sling.user} ${sling.pass} false which posts the bundle to the felix webconsole, deploys and starts them. they are not stored in the repository, though. stefan >-Original Message- >From: Steven Walters [mailto:steven.walt...@icidigital.com] >Sent: Wednesday, October 28, 2015 4:11 PM >To: users@sling.apache.org >Subject: sling-maven-plugin install goal issues > >I'm trying to use the sling-maven-plugin install as described at [0]. >I'm now encountering a scenario where I can not use the goal to install >a bundle in a particularly desired way. > >Previously, this was being used successfully within the environment to >place the bundles under the /apps/install folder within the JCR. >So this was configured in the pom.xml such as > ${server}/apps/install > true > ${sling.user} > ${sling.pass} > >The target system here was a 5.x version of CQ/AEM.
RE: Resource class vs CND
t for, how does it change / update, what data volume do > you expect etc. > Following, I'd then look at how these semantics are best expressed in > a RESTful architectural style (which is the core concept of Sling). > > I'd address the implementation details last, since - contrary to many > other web frameworks - those do not dominate the solution design. > > Regards, > Olaf > > * Okay, there is JCR OCM, but it's dated / requires some additional work: > http://www.connectcon.ch/2015/en/speakers/katarzyna-kozlowska.html > > > -Original Message- > From: Guillaume Lucazeau [mailto:glucaz...@gmail.com] > Sent: Freitag, 13. November 2015 16:10 > To: users@sling.apache.org > Subject: Re: Resource class vs CND > > Thank you for your advice > > I got rid of my CND file and created content using sling:resourceType. > I had the idea that defining my node structure somewhere would allow > me to create form dynamically to add subnodes. > > So I've created two classes: > // Document.java > @Model(adaptables=Resource.class) > public class Document { > > @Inject @Named("jcr:title") > private String title; > > @Inject > private List pages; > } > > // Page.java > @Model(adaptables=Resource.class) > public class Page { > > @Inject @Named("jcr:title") > private String title; > > @Inject > private List components; > } > > But I don't see how to map them to a sling:resourceType. Is it with > getResourceType() like in here: > > https://svn.apache.org/repos/asf/sling/trunk/launchpad/test-services/s > rc/main/java/org/apache/sling/launchpad/testservices/resourceprovider/ > PlanetResource.java > ? > > Sling definitely has its own rhythm to it and I'm slow to pick it up > :) > > > > On Fri, Nov 13, 2015 at 2:48 PM, Daniel Klco <daniel.k...@gmail.com> > wrote: > > > Agreed, I would also highly suggest looking at Sling Models as an > > option to make your code more strongly typed without requiring a > > rigid node type > > structure: > > https://sling.apache.org/documentation/bundles/models.html > > > > On Fri, Nov 13, 2015 at 8:37 AM, Jason Bailey <jason.bai...@sas.com> > > wrote: > > > > > My opinions: > > > > > > Sling is really about being able to take a data set and present > > > that data in multiple ways. For the vast majority of use cases you > > > should use the existing node types and property values and you > > > don't need to > use a CND. > > > > > > A custom nodetype is useful if there is a need to perform some > > > explicit searching over a large set of data or if you absolutely > > > require > > limitations > > > on properties that the existing nodetypes don't help with. > > > > > > Avoid trying to think of it in terms of other frameworks; Sling > > > has its own rhythm to it. You have a request that identifies a > > > resource and then that data is handed off to a renderer. Using as > > > much out of the box functionality will give you the greatest flexibility. > > > > > > > > > -Jason > > > > > > -Original Message- > > > From: Guillaume Lucazeau [mailto:glucaz...@gmail.com] > > > Sent: Friday, November 13, 2015 8:01 AM > > > To: users@sling.apache.org > > > Subject: Resource class vs CND > > > > > > Hello, > > > > > > I'm currently studying Sling for a project, to store "documents" > > > containing pages, and components (image, text, maps, graphs etc.) > > > > > > While it seems to fit our needs perfectly, I'm a bit struggling to > > > learn some basic stuff before presenting a POC to our team. > > > > > > My first question would be: on what criteria should I choose to > > > manage my resources using a class extending AbstractResource or a > > > nodetype > > definition > > > in a CND file? Do you have advice on it? I'm tending to use a > > > class to > > keep > > > everything in Java, but I'm wondering if it's more/less/equally > > > flexible, and if it has drawbacks or benefits compared to a CND file. > > > > > > Thank you for every information you could give me > > > > > > Regards, > > > Guillaume > > > > > > >
management of sling instances
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. -Jason
So my filter ordering got reversed
Working on an upgrade to AEM 6.0sp2 and things started going weird all over the place. Figured out the ordering of the servlet filters got reversed. Per https://issues.apache.org/jira/browse/SLING-2920 We're now going through the process of changing our filter run ordering . However I'm not understanding the comments.. Is the ordering going to change again at some point in the future? Or once, I reset the run ordering will I be good?
RE: Resource class vs CND
My opinions: Sling is really about being able to take a data set and present that data in multiple ways. For the vast majority of use cases you should use the existing node types and property values and you don't need to use a CND. A custom nodetype is useful if there is a need to perform some explicit searching over a large set of data or if you absolutely require limitations on properties that the existing nodetypes don't help with. Avoid trying to think of it in terms of other frameworks; Sling has its own rhythm to it. You have a request that identifies a resource and then that data is handed off to a renderer. Using as much out of the box functionality will give you the greatest flexibility. -Jason -Original Message- From: Guillaume Lucazeau [mailto:glucaz...@gmail.com] Sent: Friday, November 13, 2015 8:01 AM To: users@sling.apache.org Subject: Resource class vs CND Hello, I'm currently studying Sling for a project, to store "documents" containing pages, and components (image, text, maps, graphs etc.) While it seems to fit our needs perfectly, I'm a bit struggling to learn some basic stuff before presenting a POC to our team. My first question would be: on what criteria should I choose to manage my resources using a class extending AbstractResource or a nodetype definition in a CND file? Do you have advice on it? I'm tending to use a class to keep everything in Java, but I'm wondering if it's more/less/equally flexible, and if it has drawbacks or benefits compared to a CND file. Thank you for every information you could give me Regards, Guillaume
RE: Control JcrInstaller (OsgiInstaller) Behavior of Bundle Updating vs Installing
I'm a bit confused by the use case. Breakage should only occur if the bundle is exporting an API that is versioned, and you have a bundle that is explicitly set to not accept the new package version. Or is the breakage somewhere else? -Jason -Original Message- From: Steven Walters [mailto:steven.walt...@icidigital.com] Sent: Monday, September 21, 2015 11:03 AM To: users@sling.apache.org Subject: Control JcrInstaller (OsgiInstaller) Behavior of Bundle Updating vs Installing Is it possible to control the JcrInstaller behavior (which utilizes the OsgiInstaller functionality) to indicate whether a bundle should be considered a "new install" rather than an "update"? e.g. upload guava-17.0.jar to /apps/a/install/guava-17.0.jar This creates a new bundle registered within Felix. upload guava-18.0.jar to /apps/b/install/guava-18.0.jar This updates the 17.0 bundle in felix to be the 18 version. This is rather undesirable result (to have 17 be updated to 18 here), as this causes all functionality dependent on 17 to now fail. Instead I would like to have 18 be installed as "new" rather than as an "update", but am having trouble finding out how to do this, is this possible? Thanks, Steven.
Sling job pool sizing
I'm trying to understand the relationships between the different pools of threads in Sling and get feedback on configuration. Specifically with Jobs. There is a default job queue with a job pool size. You can then define a specific job queue with a pool size and optional thread queue There is also an overall Sling Job Thread pool. This is my understanding: Both the general and specific job queues create their queues from the overall thread pool. If you specify a thread pool, then a new thread pool gets created that is completely independent of the overall thread pool. Feedback Does anyone have any feedback or experience configuring queues? How many threads per CPU should I consider appropriate? How many threads per Jobs? Thanks -Jason
RE: Using the resource resolver
I agree with Paul, I would say that the rule of thumb is to stay open for just the length of time needed to access the resource via the resource resolver. A couple of notes, based on your sample 1. The use of getAdministrativeResourceResolver is considered harmful. Ideally you should have an account that has been configured with just the permissions for the service to do what it needs to do. In the latest versions of Sling, there are service accounts that can be configured just for that purpose. 2. Review how the service is being accessed. I see a common use case where services are being accessed as part of a HTTP request, when an http request is made there is already a resource resolver created and associated with that request that you can then pass in to the service, like Paul mentioned. 3. When you create a resource resolver you are creating an associated session. That session maintains a persistent view of the underlying JCR. Think MVCC in DB terms. If you must have a resource resolver tied to an account that is open for the entire time period. Be sure to use the .refresh() method on the resolver before using. Otherwise the result you are returning could be incorrect. -Jason -Original Message- From: Paul McMahon [mailto:oro...@yahoo.com.INVALID] Sent: Tuesday, June 14, 2016 11:31 AM To: users@sling.apache.org Subject: Re: Using the resource resolver I generally follow the practice of having the resource resolver passed in if possible. If the whatever is calling the service is triggered by some sort of HTTP request it's always best to just have the resource resolver passed in - in which case the resource resolver is only around for the life the request and gets disposed of automatically by the system. If I do have to leverage a resource resolver that you get from the factory I tend to try and dispose of them in the same method I created it. Paul McMahon From: Roy TeeuwenTo: users@sling.apache.org Sent: Tuesday, June 14, 2016 11:19 AM Subject: Using the resource resolver Hello all, I am wondering on the usage of the resource resolver and on how long it should stay open. Lets say I have the following implementation: @Component @Service(SomeService.class) public class SomeServiceImpl implements SomeService { @Reference private ResourceResolverFactory resourceResolverFactory; private ResourceResolver resourceResolver; @Activate protected synchronized void activate(Map properties) throws Exception { try { resourceResolver = resourceResolverFactory.getAdministrativeResourceResolver(null); } catch (LoginException e) { LOG.error("Failed to get admin resourceresolver", e); throw e; } } @Deactivate protected synchronized void deactivate(Map properties) throws Exception { if (resourceResolver != null && resourceResolver.isLive()) { resourceResolver.close(); } } public void doSomething(String path) { Resource resource = resourceResolver.getResource(path); //do something } } Is there anything wrong on using this? Knowing that this means the resourceresolver will stay open for possible months/years… Or should one try and make the resourceresolver opening as short as possible? Knowing that the method will be called around 1000-2000 times an hour. Another solution is of course passing the resourceResolver to do the doSomething, but then the question still remains, how long should you keep a resourceresolver open Greetings, Roy
RE: Response content type when url has no extension
I believe that exists, or I'm misunderstanding the intent. Under org.apache.sling.servlets.resolver for the property servletresolver.defaultExtensions -Original Message- From: Bertrand Delacretaz [mailto:bdelacre...@apache.org] Sent: Wednesday, June 22, 2016 8:16 AM To: usersSubject: Re: Response content type when url has no extension 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. 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: Out of memory during query
I don't think you'll find that specific answer on this list. >From a practical point of view. I had to create a service that provided a >report on all the pages in our system that we considered an active page. That would be iterating through ~400k pages across 70 sites and checking several properties on each page. To minimize the memory consumption, each time I would find a matching node, I would write the path out to the response object and not actually keep the node reference in memory. That process, running on our hardware, would spit 370k results in just over a minute. The best we could ever get it to run in jackrabbit with a query was 10 minutes. -Original Message- From: Roll, Kevin [mailto:kevin-r...@idexx.com] Sent: Friday, March 25, 2016 4:51 PM To: users@sling.apache.org Subject: RE: Out of memory during query A practical question on #3... I'm trying it and it seems to work well. Let's say I do this: final Session session = resourceResolver.adaptTo(Session.class); final Node rootNode = session.getRootNode(); ...and then start recursively traversing all of the nodes. Is there anything in the Session that will accumulate the nodes I traverse? Or, will they be reclaimable as soon as I am finished with them? Again, I am extremely paranoid about memory usage and I cannot have an out-of-memory condition. -Original Message- From: Jason Bailey [mailto:jason.bai...@sas.com] Sent: Friday, March 25, 2016 1:01 PM To: users@sling.apache.org Subject: RE: Out of memory during query A couple of observations. 3. Queries are generally slow. In the most counter intuitive experience I've ever had. We've discovered it is far faster to manually descend through the resources and identify the items that you are searching for than any query we've created.
RE: Out of memory during query
A couple of observations. 1. The query you created is amazingly broad with the usage of nt:base and no restricitions such as path. If you're going to create a query the more restrictive you can make the query the better. 2. Not sure if you're using JCR or OAK. If you're using oak, be sure to index on the property. 3. Queries are generally slow. In the most counter intuitive experience I've ever had. We've discovered it is far faster to manually descend through the resources and identify the items that you are searching for than any query we've created. -Original Message- From: Roll, Kevin [mailto:kevin-r...@idexx.com] Sent: Friday, March 25, 2016 12:46 PM To: users@sling.apache.org Subject: RE: Out of memory during query I am still working through the out-of-memory issue. The problem seems to be identical to what I saw in November - a potentially unbounded query that eats up memory. I thought that configuring a resultFetchSize in Jackrabbit had fixed the issue, but apparently not, and I'm not sure that this parameter is having any effect. I'm now experimenting with using the QueryManager directly and setting a limit: final Session session = resourceResolver.adaptTo(Session.class); final QueryManager queryManager = session.getWorkspace().getQueryManager(); final Query query = queryManager.createQuery(QUERY_STRING, Query.JCR_SQL2); query.setLimit(MAX_NODES_TO_PROCESS); final RowIterator rowIterator = query.execute().getRows(); while (rowIterator.hasNext()) The query execution is still using more memory than I like (all I want is the path!) but it appears to be stable. My question is whether the setLimit() is actually passing that value to Lucene. I traced down into the Sling code, and got lost in the lower levels, but as far as I could tell that value is pushed downward. So, can anyone clarify if this will be an actual constraint on Lucene? To put the question a different way, will Lucene use approximately the same amount of memory to run my query no matter how large my repository gets? What I am desperately trying to avoid is an unbounded query execution that will eventually fail given a large enough repository. From: Roll, Kevin Sent: Wednesday, March 23, 2016 3:54 PM To: 'users@sling.apache.org'Subject: Out of memory during query Back in November we had an out-of-memory problem with our Sling application. I determined that a periodic task was executing a query that appeared to be unlimited in terms of result set size, which would eat up memory as the repository grew. In order to combat this I marked the nodes I am interested in with a boolean flag, and I configured Jackrabbit to set the resultFetchSize to 100. This seemed to solve the problem and we had no further issues - until last week, when the problem reappeared. I've been able to determine that the problem is entirely in the execution of this query. I can enter it from the JCR Explorer query window and it will cause the runaway memory problem. The query is very straightforward, it is simply: select * from [nt:base] where uploadToImageManagerFlag = true I have no need for any parallel results, I simply want to examine the resultant Resources one at a time. Deleting/rebuilding the Jackrabbit indexes did not help. Any ideas why this query might be causing runaway memory consumption? Looking at a heap dump it appears that there are massive numbers of NodeId, HashMap$Entry, NameSet, ChildNodeEntry, NodeState, etc. It seems that for whatever reason a large number of nodes are being pulled into memory. If this would make more sense on the Jackrabbit list I can ask over there as well. Thanks!
RE: One Resource to multiple views in different locations
I've never needed to have the resource resolver select a different script. Referencing your example of breadcrumb. I've had the main breadcrumb script import the specific implementation based on a configuration. /apps/www/components/breadcrumb/breadcrumb.jsp /apps/www/components/breadcrumb/breadcrumb-site1.jsp /apps/www/components/breadcrumb/breadcrumb-site2.jsp The main breadcrumb.jsp is always executed and within that script is the logic that determines which version of the breadcrumb we want to provide. At that point we pull in the relevant jsp to render the site specific markup. This keeps all your breadcrumb logic within a single structure. It also adds value in the form of being able to offer sites options on how they would like their breadcrumbs to look that could be controlled by configuration. -Original Message- From: vkum14 [mailto:vkuma...@sapient.com] Sent: Wednesday, July 13, 2016 10:27 AM To: users@sling.apache.org Subject: Re: One Resource to multiple views in different locations Hi Jason, I believe you are talking about css/js here while my use case is to have even different markups for the same component based on the site, it is being rendered. IMO, this is a typical use case of telling servletresourceresolver to pick different scripts based on the site input. Have you done some sorts of that? -- View this message in context: http://apache-sling.73963.n3.nabble.com/One-Resource-to-multiple-views-in-different-locations-tp4061093p4062511.html Sent from the Sling - Users mailing list archive at Nabble.com.
RE: Getting the actual resource from a request
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().getSelectorString() + "." + 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: Getting the actual resource from a request
I was going to say that you shouldn't need to implement NonExistingResource interface because a selector wouldn't impact resolution then I had one of those blinding aha moments. In the case of the url you posted you aren't adding a selector, you are modifying the resource name. '/content/dam/nice-image.jpg' does not have an extension in the traditional sense, in the traditional sling sense the resource would actually be '/content/dam/nice-image' and jpg would be a handler that would return the asset as a jpeg. So when you are adding a selector to it it's not matching anything because there is no '/content/dam/nice-image' resource to match against. So first make your request find the resource without the servlet in the way. If you switch around the .cdn to the end and add a period at the end of cdn like this... content/dam/nice-image.jpg.cdn./modification-date/20160815/nice-image.jpg This should work to return the original nice-image.jpg at that point it should be easier to create a servlet that will have the resource as part of the request. Or optionally you could try adding a sling:resourceType to the image and have a selector within that resource type that does what you need it do. -Jason -Original Message- From: Roy Teeuwen [mailto:r...@teeuwen.be] Sent: Thursday, July 28, 2016 3:17 PM To: users@sling.apache.org Subject: Re: Getting the actual resource from a request Hmm Sorry Jason, I might have had to notice that I am extending SlingSafeMethodServlet but also implementing the following servlet: https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/day/cq/commons/servlets/NonExistingResourceServlet.html And as it states in the docs itself, it also says: public boolean accepts(SlingHttpServletRequest request) { // get non-existing path (incl. selectors and extension!) String path = request.getResource().getPath(); // return true if this servlet can handle this path return true; } So probably it’s not possible to do it through this interface in without manually parseing :) It also says in the docs: Please note: This is a temporary solution until Sling provides a built-in mechanism for this use case. Not to be used by client implementations! Any clue if it is possible yet to do it with standard sling, the thing I try to achieve is a servlet that also catches resources with a selector AND suffix (as stated in my example of course) ? Thanks! Roy > On 28 Jul 2016, at 18:35, Jason Bailey <jason.bai...@sas.com> 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().getSelectorString() > + "." + 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: Getting the actual resource from a request
If we're talking dispatcher, then yes, this is the wrong list :) However if we focus on the general concern, which is that as a by-product of its design. There is an inherent exploit which can result in DOS attack when using a cache. One solution might be a generic selector filter, one that can accept a list of patterns to whitelist or blacklist. -Original Message- From: Roy Teeuwen [mailto:r...@teeuwen.be] Sent: Saturday, July 30, 2016 6:58 AM To: users@sling.apache.org Subject: Re: Getting the actual resource from a request Hey Jason, Just come back to the dispatcher caching problem you saw. I think this is actually a global problem that happens anywhere, is there any rule in the dispatcher to be able stop this? Just to look at a fun real life example: http://wwwimages.adobe.com/content/dam/Adobe/images/shared/product_mnemonics/48x48/dreamweaver-no-shadow-48x48.png <http://wwwimages.adobe.com/content/dam/Adobe/images/shared/product_mnemonics/48x48/dreamweaver-no-shadow-48x48.png> http://wwwimages.adobe.com/content/dam/Adobe/images/shared/product_mnemonics/48x48/dreamweaver-no-shadow-48x48.png./test.jpg <http://wwwimages.adobe.com/content/dam/Adobe/images/shared/product_mnemonics/48x48/dreamweaver-no-shadow-48x48.png./test.jpg> http://wwwimages.adobe.com/content/dam/Adobe/images/shared/product_mnemonics/48x48/dreamweaver-no-shadow-48x48.png./test/another.jpg <http://wwwimages.adobe.com/content/dam/Adobe/images/shared/product_mnemonics/48x48/dreamweaver-no-shadow-48x48.png./test/another.jpg> It seems to make a new image in the dispatcher cache for every request. But I guess we would be on the wrong list to discuss something like this ;) Greets Roy > On 29 Jul 2016, at 15:04, Roy Teeuwen <r...@teeuwen.be> wrote: > > Hey Jason, > > You are absolutely right, damn :)! It’s because I didn’t realise that the > .jpg didn’t count as extension. I’m going to keep it with a suffix though: > /content/dam/nice-image.jpg.cdn./mod-date/20160815/nice-image.jpg just so > that in the browser it still looks like the image is called nice-image.jpg > ;). > > And you are also right about the second part, sadly enough :P. So maybe it > would be safe to make the servlet after all, so that I can check the mod-date > suffix part and see if that asset actually exists with that last modified > date and only return it then, and else return a 404. This would solve the > caching possibility of infinite image issue! > > Thanks > Roy > > >> On 29 Jul 2016, at 14:31, Jason Bailey <jason.bai...@sas.com> wrote: >> >> Roy, >> >> I think you may slap your forehead on this one :) You had to >> implement a service because when you added the cdn between the image >> name and the jpeg. It broke the resource resolution. That's why you >> had problems with the request.getResource() >> >> Once you fixed it by moving the selector, the resource is identified. That >> means, it's found the image. You don't need to have a service. The Sling >> application will take your URL, identify the resource and return that >> resource. >> >> So if all you did was just append .%timestamp$. to the end of your >> assets it will do what you want it do >> >> content/dam/nice-image.jpg.20160815. >> >> This is a nice idea for cdn's but you need to be aware of a potential issue. >> I know, from a dispatcher point of view that the ability to add selectors to >> any resource and return the original resource is a potential attack vector. >> An example would be if that url you gave was behind a dispatcher that does >> caching. I could sit there and call that asset with a millisecond time stamp >> and each time I did it, it would be cached, and the cache would get larger. >> Until some point I have consumed all of your disk space. >> >> I'm assuming a similar type issue with cdn's >> >> -Jason >> >> -Original Message- >> From: Roy Teeuwen [mailto:r...@teeuwen.be] >> Sent: Friday, July 29, 2016 8:14 AM >> To: users@sling.apache.org >> Subject: Re: Getting the actual resource from a request >> >> Hey all, >> >> Ok so I fixed it finally by doing the following: >> >> @SlingServlet( >> resourceTypes = "sling/servlet/default", >> selectors = "cdn" >> ) >> @Service({Servlet.class}) >> public class CDNAssetServlet extends SlingSafeMethodsServlet { >> >> private static final Logger LOG = >> LoggerFactory.getLogger(CDNAssetServlet.class); >> >> @Override >> protected void doGet(SlingHttpServletRequest request, >> SlingHttpSer
resource locator project
I have a utility for sling that I've been working on open sourcing that I'd like to share. https://github.com/JEBailey/sling-resourcelocator This is a java 8 port of a tool I developed in-house. It provides a set of predefined predicates for properties, and a traversal control so that you can iterate through a resource tree to find the resources you want. Feedback welcomed. -Jason
Re: Call JSP Directly on Apache Sling
This really depends on what you mean by 'calling directly' if you put a jsp file under the /apps directory. You are putting a file there. You can access that file directly as a file. If you are looking at accessing the functionality that the jsp provides, the servlet, you need to point to something that says 1. compile that jsp over there that the meta data is aware of into a servlet 2. pass the arguments from the called object into that servlet That's the whole basis of the sling design with the separation of logic and content that represents that logic. If you feel really compelled to do something where you want to put a jsp and then be able to call that as servlet from the location you put it, in my understanding, that would be a custom implementation where you would need to create your own extension or selector so that when you requested the jsp file it would be handled in the manner that you want. -Jason From: JúniorSent: Tuesday, August 9, 2016 9:10 AM To: users@sling.apache.org Subject: Call JSP Directly on Apache Sling Hi, Is there any way to call a JSP directly on Apache Sling? I'd like to call a JSP that is deployed on Apache Sling. Any tips are welcome. Thanks -- Francisco Ribeiro *SCEA|SCJP|SCWCD|IBM Certified SOA Associate*
RE: Sling Health Checks
So I'm part of a team that I will characterize as being "highly resource optimized" We have an AppDynamics instance that we use to monitor the state of our instances as much as possible. One of the OOTB features is the ability to tie into JMX and present graphs and historical information on specific items. We have a variety of business processes and functions in Sling that would be beneficial to us to monitor, and in particular graph, so that we can do intelligent alarming. Where we are having problems is that collection of state that would allow us to do intelligent monitoring. Example being submission processing. If the number of submissions each instance is handling falls below a certain threshold or increases beyond a certain number, it's an issue of concern, a warning. But certain days and a particular time, it's a situation where need someone looking at it immediately. Additionally having a value being returned would also allow us to track trends or unusual events in a historical manner so that we can hopefully identify issues before they happen. -Jason -Original Message- From: Georg Henzler [mailto:slin...@ghenzler.de] Sent: Tuesday, January 31, 2017 3:24 AM To: users@sling.apache.org Subject: Re: Sling Health Checks Hi Jason, no it is not possible at the moment - but nobody stops you to make the HC component also provide an additional, custom MBean that shares some additional result properties of the HC execution to other services. In theory the HC result could be extended to allow for custom properties (that are then in turn exposed via JMX), but the idea behind the HCs is that due to the clearly defined result type (with a clear semantic for each status) consumers can easily decide whether an instance is healthy or not, additional properties might be confusing. Could you describe your use case in a bit more detail? Regards Georg On 2017-01-30 18:56, Jason Bailey wrote: > Anyone know if it's possible to use the Sling Health Checks to expose > a value via the MBean other than the ones explicitly defined in the > Result Object? > > Thanks > -Jason
RE: Sling Health Checks
I appreciate the feedback. There is so much churn in the developer mailing list I found myself unable to track new additions or changes like I used to do. The touch point with is AppDynamics is JMX, which I see is supported in the dropwizard metrics. For the issue I had, I am fortunate to have a talented intern and she was able to get everything working for our last Sprint. Going forward, I will be floating this functionality around and see if we can't start leveraging it soon. Thanks -Jason -Original Message- From: Björn Weide [mailto:bjoern.we...@netcentric.biz] Sent: Tuesday, February 07, 2017 4:12 AM To: users@sling.apache.org Cc: georg.henz...@netcentric.biz Subject: Re: Sling Health Checks Just my 2cents on that one - for me it sounds like it would be a good fit to use Sling Metrics here to record your metrics (like # of submissions in your case). You could then use a custom reporter to expose the data to AppDynamics (not sure about the integration points there). In case you want to use a HC for that metrics you could implement some kind of delta reporter that simply reports the deltas of selected metrics to an internal store and then implement a HC checking these deltas against your thresholds (we are using this setup in one of our projects). Best regards, Bjoern On Tue, Jan 31, 2017 at 4:59 PM, Jason Bailey <jason.bai...@sas.com> wrote: > So I'm part of a team that I will characterize as being "highly > resource optimized" We have an AppDynamics instance that we use to > monitor the state of our instances as much as possible. One of the > OOTB features is the ability to tie into JMX and present graphs and > historical information on specific items. > > We have a variety of business processes and functions in Sling that > would be beneficial to us to monitor, and in particular graph, so that > we can do intelligent alarming. Where we are having problems is that > collection of state that would allow us to do intelligent monitoring. > > Example being submission processing. If the number of submissions each > instance is handling falls below a certain threshold or increases > beyond a certain number, it's an issue of concern, a warning. But > certain days and a particular time, it's a situation where need > someone looking at it immediately. > > Additionally having a value being returned would also allow us to > track trends or unusual events in a historical manner so that we can > hopefully identify issues before they happen. > > -Jason > > -Original Message- > From: Georg Henzler [mailto:slin...@ghenzler.de] > Sent: Tuesday, January 31, 2017 3:24 AM > To: users@sling.apache.org > Subject: Re: Sling Health Checks > > Hi Jason, > > no it is not possible at the moment - but nobody stops you to make the > HC component also provide an additional, custom MBean that shares some > additional result properties of the HC execution to other services. > > In theory the HC result could be extended to allow for custom > properties (that are then in turn exposed via JMX), but the idea > behind the HCs is that due to the clearly defined result type (with a > clear semantic for each > status) consumers can easily decide whether an instance is healthy or > not, additional properties might be confusing. Could you describe your > use case in a bit more detail? > > Regards > Georg > > On 2017-01-30 18:56, Jason Bailey wrote: > > Anyone know if it's possible to use the Sling Health Checks to > > expose a value via the MBean other than the ones explicitly defined > > in the Result Object? > > > > Thanks > > -Jason >
RE: Sling Health Checks
Yes, you are right. I have quite a few scenarios where beyond the indicator that something is wrong, that the healthcheck provides me, I need to capture a value that to represent the scale of the problem. So that I can have analysis. I was hoping to have the option to provide that as part of the healthcheck rather than writing two separate things. :) All good. -Original Message- From: Bertrand Delacretaz [mailto:bdelacre...@apache.org] Sent: Tuesday, January 31, 2017 11:59 AM To: users <users@sling.apache.org> Subject: Re: Sling Health Checks Hi, On Tue, Jan 31, 2017 at 4:59 PM, Jason Bailey <jason.bai...@sas.com> wrote: > ...We have an AppDynamics instance that we use to monitor the state of our > instances as much as possible... > ...If the number of submissions each instance is handling falls below > a certain threshold or increases beyond a certain number, it's an > issue of concern, a warning. But certain days and a particular time, it's a > situation where need someone looking at it immediately... Isn't this a case for an MBean that just reports the number of submissions, and a health check that checks that they are within range, maybe based on days and times? I think that would work with our standard health checks modules. -Bertrand
Sling Health Checks
Anyone know if it's possible to use the Sling Health Checks to expose a value via the MBean other than the ones explicitly defined in the Result Object? Thanks -Jason
json support
I found out recently through github that people are using json files to create content nodes in bundles. Is this something I can do downstream in AEM and/or in a package? Thanks -jason
RE: Not-sticky sessions with Sling?
Couldn't this be simplified to simply stating that the sticky session cookie only lasts for x amount of seconds? I like this idea, but I'm not sure this is really a sling solution rather than an API management or proxy solution. When you take an instance out of the pool, you would need to state that it's not available for new requests, but still honor it for x amount of time for those with the sticky session cookie that says they should go there. -Jason -Original Message- From: Chetan Mehrotra [mailto:chetan.mehro...@gmail.com] Sent: Wednesday, January 18, 2017 6:49 AM To: users@sling.apache.org Subject: Re: Not-sticky sessions with Sling? > Each time we remove an > instance, those users will go to a new Sling instance, and experience > the inconsistency. Each time we add an instance, we will invalidate > all stickiness and users will get re-assigned to a new Sling instance, > and experience the inconsistency. I can understand issue around when existing Sling server is removed from the pool. However adding a new instance should not cause existing users to be reassigned Now to your queries --- > 1) When a brand new Sling instance discovers an existing JCR (Mongo), does it > automatically and immediately go to the latest head revision? It sees the latest head revision > Increasing load increases the number of seconds before a "sync," however > it's always near-exactly a second interval. Yes there is a "asyncDelay" setting in DocumentNodeStore which defaults to 1 sec. Currently its not possible to modify it via OSGi config though. >- What event is causing it to "miss the window" and wait until the next 1 >second synch interval? this periodic read also involves some other work. Like local cache invalidation, computing the external changes for observation etc which cause this time to increase. More the changes done more would be the time spent on that kind of work Stickyness and Eventual Consistency - There are multiple level of eventual consistency [1]. If we go for sticky session then we are trying for "Session Consistency". However what we require in most cases is read-your-write consistency. We can discuss ways to do that efficiently with current Oak architecture. Something like this is best discuss on oak-dev though. One possible approach can be to use a temporary issued sticky cookie. Under this model 1. Sling cluster maintains a cluster wide service which records the current head revision of each cluster node and computes the minimum revision of them. 2. A Sling client (web browser) is free to connect to any server untill it performs a state change operation like POST or PUT 3. If it performs a state change operation then the server which performs that operation issues a cookie which is set to be sticky i.e. Load balancer is configured to treat that as cookie used to determine stickiness. So from now on all request from this browser would go to same server. This cookie lets say record the current head revision 4. In addition the Sling server would constantly get notified of minimum revision which is visible cluster wide. Once that revision becomes older than revision in #3 it removes the cookie on next response sent to that browser This state can be used to determine if server is safe to be taken out of the cluster or not. This is just a rough thought experiment which may or may not work and would require broader discussion! Chetan Mehrotra [1] http://www.allthingsdistributed.com/2008/12/eventually_consistent.html
RE: Sling models adaptTo taglib
IMHO the big selling point of OSGi, is the ability to add additional packages as you go. If the package is needing an api of a particular version that isn't in your environment it just won't turn on. If the bundle is defined correctly, which I admit, seems to be a difficult thing to do. Then the version of the bundle is less important then the package version of the api's that it exports. -Jason -Original Message- From: Roy Teeuwen [mailto:r...@teeuwen.be] Sent: Saturday, August 20, 2016 8:28 AM To: users@sling.apache.org Subject: Re: Sling models adaptTo taglib Hey Dan, Ok cool, thanks, I guess it is indeed just a patch version upgrade from 2.2.4 to 2.2.6, so it’s worth a shot :)! Greets Roy > On 19 Aug 2016, at 15:00, Daniel Klcowrote: > > Roy, > > You can pretty safely upgrade the version of Sling Taglibs without > upgrading the overall application version. If you include the newer > version of the bundle into your build package in a folder like > /apps/[app-name]/install, Sling will pick up the more recent version > of the bundle and install it. If you have any issues, you can force > Sling to recompile the JSP's from the OSGi console. > > Regards, > Dan > > On Fri, Aug 19, 2016 at 7:37 AM, Roy Teeuwen wrote: > >> Hey Júnior, >> >> Thanks! >> >> Darnit, it seems that I will have to wait until after the upgrade to >> AEM >> 6.2 ;). >> >> Greets, >> Roy >> >> >>> On 19 Aug 2016, at 13:34, Júnior wrote: >>> >>> Hi Roy, >>> >>> There is an Issue about the problem you are facing: >>> >>> https://issues.apache.org/jira/browse/SLING-5653 >>> >>> And it seems to be fixed. Not sure in which version it is included. >>> >>> Thanks >>> >>> >>> 2016-08-19 8:25 GMT-03:00 Roy Teeuwen : >>> Hello all, I am trying to use the sling models taglib, and I am using the following input: <%@ page import=“my.packages.TestModel" %> >>> var="model"/> ${model.testString} But when doing this, I get the following exception: java.lang.ClassCastException: java.lang.Object cannot be cast to java.lang.String at javax.servlet.jsp.tagext.TagData.getAttributeString( TagData.java:138) at org.apache.sling.scripting.jsp.taglib.tei.AdaptToTEI. getClassName(AdaptToTEI.java:26) at org.apache.sling.scripting.jsp.taglib.tei.AbstractVarTEI. getVariableInfo(AbstractVarTEI.java:78) I would expect this to work? Is there any way I could get it to work >> like this? It is nicer if I can import it so that my IDE has a clearer sight >> of which classes are used in the jsp’s instead of having to write the >> class as a plain string form: >>> var="model"/> ${model.testString} (I am used to working with slice from cognifide, and am not trying out sling models, in slice you could say >>> class=“<%=TestModel.class%>”/> without calling the getName but just >> using the class object ) Thanks! Roy >>> >>> >>> >>> >>> -- >>> Francisco Ribeiro >>> *SCEA|SCJP|SCWCD|IBM Certified SOA Associate* >> >>
RE: Creating a service user for your own bundle
The focus seems to be around providing a service user. Wouldn't it be preferable to have a system where the bundle defined the permissions it requires and then automatically associate an already existing system user? -Original Message- From: Robert Munteanu [mailto:romb...@apache.org] Sent: Monday, November 07, 2016 7:27 AM To: users@sling.apache.org Subject: Re: Creating a service user for your own bundle On Mon, 2016-11-07 at 12:06 +0100, Bertrand Delacretaz wrote: > On Mon, Nov 7, 2016 at 12:01 PM, Carsten Ziegelerrg> wrote: > > Bertrand Delacretaz wrote > > > ... That's a nice model but IIUC Carsten earlier in this thread > > > OSGi capabilities cannot be created at runtime so that won't work > > > for service users or access rights. > > > > I just had the crazy idea that we could generate them at runtime by > > creating an artifical bundle providing the capabilities. When the > > capabilities change, that bundle could be updated > > I like crazy ideas in general, but service users might appear later > during startup, at a time where bundles that need them are already > started so not sure if the dynamics would work. > > If we want to keep the usual dynamics of OSGi, the service model is > probably better - IIRC we are already using somewhere fake services > with properties that act like capabilities, something like depending > on a ServiceUserPresent(target="my-service-user") service. I forgot > where that is. We do this for the adapter factories https://github.com/apache/sling/blob/4df9ab2d6592422889c71fa13afd453a10 a5a626/bundles/extensions/adapter/src/main/java/org/apache/sling/adapte r/Adaption.java Robert
Re: JS Use API usability or limitations
I've experienced a variety of results between switching between a dynamic and static types languages I think a lot of it has to do with context. IMHO there's a certain rhythm to developing on any specific platform. Where using a certain set of technologies make more sense than others. Since everything in Sling is built on Java and you'll be dealing with Java API's, from a business logic perspective, I think you'll get the best results from writing that part In Java. I highly recommend the Sling Models as the starting point for that. >From the view perspective, which I'm using to identify that initial end point >service you're calling I don't think it matters as much, although I haven't >heard of a lot of people using ecma. I prefer to stick with JSPs since that's >what everything boils down to underneath anyways, sticking an abstraction >layer over it has always struck me as kind of wasteful. From: lancedolanSent: Wednesday, January 11, 2017 4:41 PM To: users@sling.apache.org Subject: RE: JS Use API usability or limitations No architectural reason - purely speed of development reasons. Our team has switched from Java to Node.js on our other projects and are seeing real gains in dev time. We believe we could see the same faster development with lightweight JS files as opposed to traditional type-safe Java. I think this is a popular opinion amongst developers, that JS is faster to write in than Java? The question currently on the table is whether the difficulty in debugging esoteric Rhino interactions will negate that speed, in which case we might as well stick to Java and enjoy stability of type safety. -- View this message in context: http://apache-sling.73963.n3.nabble.com/JS-Use-API-usability-or-limitations-tp4069490p4069526.html Sent from the Sling - Users mailing list archive at Nabble.com.
uses for Sling
I know that Sling is used for 2 downstream CMS applications. I was wondering if anyone could share other use cases that they have found Sling to be useful for. Thanks.
RE: JS Use API usability or limitations
Alright, I'll bite. If you're talking about model building logic. Is there some architectural constraint on why you don't just stick with java? -Jason -Original Message- From: lancedolan [mailto:lance.do...@gmail.com] Sent: Wednesday, January 11, 2017 2:37 PM To: users@sling.apache.org Subject: RE: JS Use API usability or limitations Thank you for your time everybody! For posterity: First to clarify, my very specific question is how to iterate an iterable in the model-building logic (what us old timers might call a "backing bean"). I do already know that I can use HTL to iterate the children, and I do recognize that in this contrived example it's a better separation of view/model concerns to do so. However I'm going to need to do lots of iterating on resources in my "backing beans" as I build model data for increasingly complex objects. Imagine a component that searches various parts of the JCR and filters on specific properties to generate a heterogenous list of content links... To suggest HTL just skirts around my development need in model-building logic. Vlad's syntax solved my problem. I'd love to understand why. It seems the Iterable contains a Map or List objects with a key and resource... Is that due to Rhino? The Sling docs say getChildren returns Iterable. I didn't expect this. I'm already feeling the pain of debugging JS Use API, which Stefan has warned about, and so did the sling docs on. I'm concluding that the JS Use API probably isn't ready and requires too much esoteric/idiomatic knowledge to give the sort of development speed one would expect with JS. I'm going to keep it as an option for very simple components. -- View this message in context: http://apache-sling.73963.n3.nabble.com/JS-Use-API-usability-or-limitations-tp4069490p4069521.html Sent from the Sling - Users mailing list archive at Nabble.com.
RE: Best Sling samples for a beginner to look at?
Bertrand, I can't you how relieved I am to here that there is a desire to be scripting language agnostic. I hope this continues. -Original Message- From: Bertrand Delacretaz [mailto:bdelacre...@apache.org] Sent: Wednesday, March 29, 2017 6:39 AM To: usersSubject: Re: Best Sling samples for a beginner to look at? On Tue, Mar 28, 2017 at 7:15 PM, Andreas Schaefer Sr. wrote: > ...Slingbucks is ok but it is outdated (as far as I can tell) using > ESPs and not using HTL and Sling Models FWIW it's always been important for Sling to avoid imposing too much in terms of scripting languages and let users select what works best for them. So although there's probably many more people using HTL and Sling Models than ESP today, I don't think this makes ESP outdated - it's different ways of working, for different purposes and styles. -Bertrand
bundle + war + sling
Wondering if anyone has done anything with creating a war that can be deployed as bundle and have its resources exposed as sling content. -Jason
RE: Sling models - Resource decorator
Hey Roy, Couple of Assumptions: For the Self resource you have it defined as: @Self public Resource resource; and for the @Model you have something like @Model(adaptables = RoysCustomDecorator.class) Am I close? -Jason -Original Message- From: Roy Teeuwen [mailto:r...@teeuwen.be] Sent: Tuesday, June 06, 2017 10:08 AM To: users@sling.apache.org Subject: Sling models - Resource decorator Hey all, I am using sling models version 1.2.2, and I have the following logic: - I find some resources with the resource resolver (resourceResolver.findResources) - The returned resources are the correct resources which are decorated by my custom resource decorator - I iterate the list to cast them to the sling model I want them to be, using a resource.adaptTo - The sling model itself has a field Resource resource, to inject itself What I notice now is that the injected resource is a JcrNodeResource and not my decorated resource class anymore. I guess this is a bug in the sling models implementation? Am I doing something wrong here or is this an actual bug in the sling models implementation? Is this maybe already fixed in any of the future versions? Greets, Roy
useful tip for jsp development
I've finally solved a nagging eclipse configuration issue with developing Sling JSP's and I wanted to share with the community. One of the pain points we've always found was the lack of a context root in a bundle package. That's the ability to reference a file in JSP via an include to another file in your code and have it resolve to the correct path. We've tried various tricks over the last couple of years and none of them really were as smooth or integrated as we'd like. Turns out, that at some point M2E integration started supporting the web-fragment facet/specification. We included a web-fragment.xml that looked like this at our root under /src/main/content/jcr_root http://java.sun.com/xml/ns/javaee; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd;> web.content.foo web_content_foo It then added an additional .settings file that sets a list of roots defined by the resource paths in your maven file. -Jason
RE: [ANN] New Apache Sling PMC Chair: Robert Munteanu
Congrats Robert! -Original Message- From: Georg Henzler [mailto:slin...@ghenzler.de] Sent: Friday, November 17, 2017 5:27 AM To: users@sling.apache.org Subject: Re: [ANN] New Apache Sling PMC Chair: Robert Munteanu EXTERNAL Congratulations also from my side! On 2017-11-17 10:26, Andrei Dulvac wrote: > Congratulations! > > > On Fri, Nov 17, 2017, 10:07 Julian Seddingwrote: > >> Congratulations Robert! >> >> Regards >> Julian >> >> On Thu, Nov 16, 2017 at 5:29 PM, Roy Teeuwen wrote: >> > Congratulations Robert! >> > >> > Greets, >> > Roy >> > >> >> On 16 Nov 2017, at 15:25, Carsten Ziegeler >> wrote: >> >> >> >> Hi, >> >> >> >> it's my pleasure to announce that Robert took up the role as our new PMC >> >> chair. >> >> >> >> Congrats Robert! >> >> >> >> Regards >> >> Carsten >> >> -- >> >> Carsten Ziegeler >> >> Adobe Research Switzerland >> >> cziege...@apache.org >> > >>
RE: sling with sso - with oauth2 / openid connect
Here are some authentication implementations and their source code https://github.com/apache?utf8=%E2%9C%93=sling+auth It's been a while since I touched this, so I hope I'm not too off base here. There are two parts to an access control system, authentication and authorization. It should be straightforward to tie in an external authentication mechanism, what might be confusing is that once you have an authenticated user you need to associate a user that is defined in Sling to that authenticated person. Because it's that user that's defined in Sling that provides the authorization for the content. There's a couple of ways of handling the users within Sling. If you had broad categories of access, say that you need them authenticated but once authenticated they don't have separate access rights. 1. You'd create a generic user and assign access controls to that user 2. Once authenticate you could then provide the credentials for that generic user you had created. If you wanted more fine grain control. Let's say a different user for each authenticated person, you would need to create or import that person into Sling at which point, on Authentication, you can associate the specific Sling user that matches their ID. Conceivably you could even, on authentication, create the user if that user is not there and then add that user to defined groups which have the ACLs defined. The last time I did that though, which was 6-7 years ago it was a bit labor intensive. Here's a bundle provides a way to manage users in Sling https://sling.apache.org/documentation/bundles/managing-users-and-groups-jackrabbit-usermanager.html#create-user -Jason -Original Message- From: Ioan Eugen Stan [mailto:ieu...@netdava.com] Sent: Tuesday, February 13, 2018 12:46 PM To: users@sling.apache.org Subject: sling with sso - with oauth2 / openid connect Hello, I have started evaluating Sling some time now and I've reached a point where the blocker is whether we can integrate it with Keycloak to provide single sign on. A more generic question is: can Sling delegate authentication/authorization to another system like Keycloak? Keycloak uses Openid Connect protocol for authentication and implements Oauth2 grant types. I imagine it should be possible and I'm willing to contribute some code and document this process. How Keycloak integrates with other applications is that it acts like a filter/proxy in front of the app. I believe that the flow would be like this: - User access protected Sling resources - Sling checks if user is authenticated by reading cookie (or maybe token) - If user is not authenticated, it is redirected to the Keycloak server - Keycloak handles auth. After successful authentication, it is redirected back to the Sling with an authorization code (in authorization code grant flow). - Sling will have to call Keycloak API to exchange that code with an access token (Oauth2) and an identity token (OpenID Connect). - Sling can use those tokens to determine access rights (reading from token in case of JWT or calling Keycloak API) Now I know that Sling needs to authenticate to Oak repository. My question is: should the integration with Keycloak (or any OpenID Connect / Oauth2 provider) happen just in Sling, just in Oak or in both? Could someone point out the places (modules, classes) where these integrations could be made? I've looked at Sling authentication [4] and [5] but I'm still a bit confused as to how Sling relates to authentication and authorization. From my understanding, Oak manages access and permissions (much like PostgreSQL and other RDBMS have support for these features). I will wait some answers here and based on that continue on Oak mailing list. [1] https://auth0.com/docs/api-auth/tutorials/authorization-code-grant [2] http://www.keycloak.org/docs/latest/securing_apps/index.html [3] http://jackrabbit.apache.org/oak/docs/security/authentication/preauthentication.html [4] https://sling.apache.org/documentation/the-sling-engine/authentication.html [5] https://sling.apache.org/documentation/the-sling-engine/authentication/authentication-framework.html