Re: Exposing DB Data
Hi Andreas, Andreas Kollegger wrote: > Hi, > > I'd like to expose data stored in an external database as resource nodes > in Sling. Access to the database is already wrapped in an OSGi service > (MyService.java), and there is a Java model for the data (MyModel.java). > From what I can understand from reading the examples, searching the > mailing list and looking at documentation, the steps to integrate with > Sling could be: > > 1. MyResourceProvider implements ResourceProvider > - bridge to MyService for getting data rows > - provider.roots = /my/resources/ > - sub-path of root used to select row in table > (/my/resources/3245.html retrieves row index 3245 as Resource) > - listChildren() of root would list all database rows (probably add > query params to limit number of rows returned) > - getResource() returns a MyResourceWrapper > > 2. MyResourceWrapper implements Resource > - wraps MyModel > - resourceType = my/Model > - adaptable to javax.jcr.Node (exposing columns as node properties) it depends on your application (code) but I think making your resource adaptable to ValueMap (jcr resources are adaptable to value map as well) is more generic. It allows you to access different kind of resources (backed by jcr, backed by your db provider) in a unique way. And the ValueMap interface is easier to use than jcr Node :) > That would take care of read access to the data. I can then easily add > scripts to render the data as appropriate. Sounds good to me :) > > Write access is a little less clear to me. I'd like to have a servlet > which handles json, xml or form POSTs for anything submitted to the path > of my ResourceProvider. I think I need to do this: > > 1. MyResourceTypeProvider implements JcrResourceTypeProvider > - provider.roots = /my/resources > - any node below the root is returned as resourceType my/Model, > otherwise return null > > 2. MyPostServlet extends SlingAllMethodsServlet > - registered to handle nodes of type my/Model > - override doPost() to handle data based on content-type > - creates new database entries using MyService > > That would allow the creation of a new database row by posting an > appropriate json or xml file to /my/resource/*.html . For the form data, > I'd conform to the SlingPostServlet interface to remain compatible with > generic node editing. > > Am I thinking about this correctly, or is their a more appropriate > Sling-Way? Hmm not sure :) I guess your idea should work. Now, for updating db data it should already work if your resource is adaptable to PersistableValueMap. For adding/deleting resources something like the above might work. We are thinking of extending the resource provider interface to get better support for these use cases. This is one of the topics for the near future, so maybe we should start thinking about this (again) now :) Regards Carsten -- Carsten Ziegeler cziege...@apache.org
Re: Openid integration for Sling 3
Tanmay Barman wrote: > Hi all, > I was trying to integrate openid in my project that is based on sling 3. I > was trying with openid4java api. But I am having the following error > > java.lang.NoClassDefFoundError: > org/apache/commons/httpclient/methods/RequestEntity Hi, the class in question has been added to httpclient in version 3.0, so you need to add commons httpclient 3.1 or similar to your bundles. Regards Carsten > at > org.apache.sling.samples.jcrdev.servlets.SampleConsumerServlet.authRequest(SampleConsumerServlet.java:93) > at > org.apache.sling.samples.jcrdev.servlets.SampleConsumerServlet.doPost(SampleConsumerServlet.java:67) > at > org.apache.sling.samples.jcrdev.servlets.SampleConsumerServlet.doGet(SampleConsumerServlet.java:59) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) > at > org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:462) > at > org.apache.sling.engine.impl.SlingMainServlet.processRequest(SlingMainServlet.java:419) > at > org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:48) > at > org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:54) > at > org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:59) > at > org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:52) > at > org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:273) > at > org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:171) > at > org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487) > at > org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362) > at > org.ops4j.pax.web.service.internal.HttpServiceServletHandler.handle(HttpServiceServletHandler.java:51) > at > org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) > at > org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:722) > at > org.ops4j.pax.web.service.internal.HttpServiceContext.handle(HttpServiceContext.java:87) > at > org.ops4j.pax.web.service.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:63) > at > org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139) > at org.mortbay.jetty.Server.handle(Server.java:324) > at > org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505) > at > org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828) > at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514) > at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) > at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) > at > org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228) > at > org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450) > > I have also included commons-httpclient-2.0.2.jar in my felix > environment. If anyone has some idea about that problem please let me > know. > > > Regards, > > Tanmay > -- Carsten Ziegeler cziege...@apache.org
Openid integration for Sling 3
Hi all, I was trying to integrate openid in my project that is based on sling 3. I was trying with openid4java api. But I am having the following error java.lang.NoClassDefFoundError: org/apache/commons/httpclient/methods/RequestEntity at org.apache.sling.samples.jcrdev.servlets.SampleConsumerServlet.authRequest(SampleConsumerServlet.java:93) at org.apache.sling.samples.jcrdev.servlets.SampleConsumerServlet.doPost(SampleConsumerServlet.java:67) at org.apache.sling.samples.jcrdev.servlets.SampleConsumerServlet.doGet(SampleConsumerServlet.java:59) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:462) at org.apache.sling.engine.impl.SlingMainServlet.processRequest(SlingMainServlet.java:419) at org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:48) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:54) at org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:59) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:52) at org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:273) at org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:171) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362) at org.ops4j.pax.web.service.internal.HttpServiceServletHandler.handle(HttpServiceServletHandler.java:51) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:722) at org.ops4j.pax.web.service.internal.HttpServiceContext.handle(HttpServiceContext.java:87) at org.ops4j.pax.web.service.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:63) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139) at org.mortbay.jetty.Server.handle(Server.java:324) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228) at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450) I have also included commons-httpclient-2.0.2.jar in my felix environment. If anyone has some idea about that problem please let me know. Regards, Tanmay
Openid integration for Sling 3
Hi all, I was trying to integrate openid in my project that is based on sling 3. I was trying with openid4java api. But I am having the following error java.lang.NoClassDefFoundError: org/apache/commons/httpclient/methods/RequestEntity at org.apache.sling.samples.jcrdev.servlets.SampleConsumerServlet.authRequest(SampleConsumerServlet.java:93) at org.apache.sling.samples.jcrdev.servlets.SampleConsumerServlet.doPost(SampleConsumerServlet.java:67) at org.apache.sling.samples.jcrdev.servlets.SampleConsumerServlet.doGet(SampleConsumerServlet.java:59) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:462) at org.apache.sling.engine.impl.SlingMainServlet.processRequest(SlingMainServlet.java:419) at org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:48) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:54) at org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:59) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:52) at org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:273) at org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:171) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362) at org.ops4j.pax.web.service.internal.HttpServiceServletHandler.handle(HttpServiceServletHandler.java:51) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:722) at org.ops4j.pax.web.service.internal.HttpServiceContext.handle(HttpServiceContext.java:87) at org.ops4j.pax.web.service.internal.JettyServerHandlerCollection.handle(JettyServerHandlerCollection.java:63) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139) at org.mortbay.jetty.Server.handle(Server.java:324) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228) at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450) I have also included commons-httpclient-2.0.2.jar in my felix environment. If anyone has some idea about that problem please let me know. Regards, Tanmay
Content Packaging
Hello, Is anyone aware of content / node packaging built-in functionality? I found a url [1] on initial content loading with Sling, but may be a little incomplete. Respectfully, John [1] http://incubator.apache.org/sling/site/content-loading.html
Exposing DB Data
Hi, I'd like to expose data stored in an external database as resource nodes in Sling. Access to the database is already wrapped in an OSGi service (MyService.java), and there is a Java model for the data (MyModel.java). From what I can understand from reading the examples, searching the mailing list and looking at documentation, the steps to integrate with Sling could be: 1. MyResourceProvider implements ResourceProvider - bridge to MyService for getting data rows - provider.roots = /my/resources/ - sub-path of root used to select row in table (/my/resources/ 3245.html retrieves row index 3245 as Resource) - listChildren() of root would list all database rows (probably add query params to limit number of rows returned) - getResource() returns a MyResourceWrapper 2. MyResourceWrapper implements Resource - wraps MyModel - resourceType = my/Model - adaptable to javax.jcr.Node (exposing columns as node properties) That would take care of read access to the data. I can then easily add scripts to render the data as appropriate. Write access is a little less clear to me. I'd like to have a servlet which handles json, xml or form POSTs for anything submitted to the path of my ResourceProvider. I think I need to do this: 1. MyResourceTypeProvider implements JcrResourceTypeProvider - provider.roots = /my/resources - any node below the root is returned as resourceType my/Model, otherwise return null 2. MyPostServlet extends SlingAllMethodsServlet - registered to handle nodes of type my/Model - override doPost() to handle data based on content-type - creates new database entries using MyService That would allow the creation of a new database row by posting an appropriate json or xml file to /my/resource/*.html . For the form data, I'd conform to the SlingPostServlet interface to remain compatible with generic node editing. Am I thinking about this correctly, or is their a more appropriate Sling-Way? Thanks for your thoughts, Andreas
Re: Binding to a resource Type
The patch is re worked and refreshed at http://codereview.appspot.com/67146 but NonExistingResource needs to be non final (as does the getResourceType method) and reading the comments in that class, this might not be a good idea. Would it be better to use a synthetic ? Ian On 3 Jun 2009, at 16:46, Ian Boston wrote: Thanks, the points all make sense I will rework the patch. Ian On 3 Jun 2009, at 14:21, Felix Meschberger wrote: Hi Ian I have posted a review there. Regards Felix Ian Boston schrieb: I have pushed a patch for inspection at http://codereview.appspot.com/67146 Is this along the lines you were thinking ? Ian On 3 Jun 2009, at 10:14, Felix Meschberger wrote: It might be conceivable though to set the resourceSuperType of such non-existing resources to something configurable. To do this I would suggest to introduce a new service interface, which would be called when the ResourceResolver is about to create the NonExistingResource
[jira] Created: (SLING-994) DefaultGetServlet shoud not use sendError when response is already committed
DefaultGetServlet shoud not use sendError when response is already committed Key: SLING-994 URL: https://issues.apache.org/jira/browse/SLING-994 Project: Sling Issue Type: Bug Components: Servlets Get Affects Versions: Scripting JSP-Taglib 2.0.4 Reporter: Carsten Ziegeler Assignee: Carsten Ziegeler Fix For: Servlets Get 2.0.6 If no renderer servlet is found in the DefaultGetServlet, it calls sendError(). If this is an included request, sendError usually fails as the response is already committed. In this case it's hard to detect the underlying problem. Therefore I suggest to check if this is an included request and in this case throw a ServletException I'm not in favour of checking for response isCommitted as this is more unpredictable -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
Re: Binding to a resource Type
Thanks, the points all make sense I will rework the patch. Ian On 3 Jun 2009, at 14:21, Felix Meschberger wrote: Hi Ian I have posted a review there. Regards Felix Ian Boston schrieb: I have pushed a patch for inspection at http://codereview.appspot.com/67146 Is this along the lines you were thinking ? Ian On 3 Jun 2009, at 10:14, Felix Meschberger wrote: It might be conceivable though to set the resourceSuperType of such non-existing resources to something configurable. To do this I would suggest to introduce a new service interface, which would be called when the ResourceResolver is about to create the NonExistingResource
[jira] Updated: (SLING-993) Sling Explorer with jquery
[ https://issues.apache.org/jira/browse/SLING-993?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Renaud Richardet updated SLING-993: --- Attachment: Picture 2.png snapshot > Sling Explorer with jquery > -- > > Key: SLING-993 > URL: https://issues.apache.org/jira/browse/SLING-993 > Project: Sling > Issue Type: New Feature > Components: Launchpad > Environment: osx >Reporter: Renaud Richardet >Priority: Minor > Attachments: Picture 2.png, sling.zip > > > a jcr explorer based on jquery. goals: minimum install and dependencies -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
[jira] Updated: (SLING-993) Sling Explorer with jquery
[ https://issues.apache.org/jira/browse/SLING-993?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Renaud Richardet updated SLING-993: --- Attachment: sling.zip files to be copied to /app/sling > Sling Explorer with jquery > -- > > Key: SLING-993 > URL: https://issues.apache.org/jira/browse/SLING-993 > Project: Sling > Issue Type: New Feature > Components: Launchpad > Environment: osx >Reporter: Renaud Richardet >Priority: Minor > Attachments: sling.zip > > > a jcr explorer based on jquery. goals: minimum install and dependencies -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
[jira] Created: (SLING-993) Sling Explorer with jquery
Sling Explorer with jquery -- Key: SLING-993 URL: https://issues.apache.org/jira/browse/SLING-993 Project: Sling Issue Type: New Feature Components: Launchpad Environment: osx Reporter: Renaud Richardet Priority: Minor Attachments: sling.zip a jcr explorer based on jquery. goals: minimum install and dependencies -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
Re: Binding to a resource Type
Hi Ian I have posted a review there. Regards Felix Ian Boston schrieb: > I have pushed a patch for inspection at > http://codereview.appspot.com/67146 > > Is this along the lines you were thinking ? > Ian > > On 3 Jun 2009, at 10:14, Felix Meschberger wrote: > >> It might be conceivable though to set the resourceSuperType of such >> non-existing resources to something configurable. To do this I would >> suggest to introduce a new service interface, which would be called when >> the ResourceResolver is about to create the NonExistingResource > >
Re: Binding to a resource Type
I have pushed a patch for inspection at http://codereview.appspot.com/67146 Is this along the lines you were thinking ? Ian On 3 Jun 2009, at 10:14, Felix Meschberger wrote: It might be conceivable though to set the resourceSuperType of such non-existing resources to something configurable. To do this I would suggest to introduce a new service interface, which would be called when the ResourceResolver is about to create the NonExistingResource
Re: Binding to a resource Type
On 3 Jun 2009, at 10:14, Felix Meschberger wrote: Hi, Each ResourceProvider is responsible for setting up resources themselves, including setting the resource type. For example the BundleResourceProvider sets the resource type to nt:file or nt:folder depending on whether the resource is a file or folder. The JcrResourceProvider now uses the ResourceTypeProvider service to enhance its resource type resolution: (1) check sling:resourceType property (2) check ResourceTypeProvider services (3) take primary node type Ok, that makes sense, clearly changing ResourceTypeProvider would be the wrong thing to do thank you. Your (remaining) problem probably is the resource type of non-existing resources which is currently hard coded to sling:nonexisting and it is also defined in the API that a non existing resource has the sling:nonexisting resource type. It might be conceivable though to set the resourceSuperType of such non-existing resources to something configurable. To do this I would suggest to introduce a new service interface, which would be called when the ResourceResolver is about to create the NonExistingResource. Ok, I will give that a go, sounds like a far better than a ResourceProvider place to put this stuff. Thanks Ian Regards Felix Ian Boston schrieb: On 3 Jun 2009, at 09:26, Felix Meschberger wrote: Not in the sense of "inheriting the resource type from the parent node if none is set". But: We have a ResourceTypeProvider service interface, which you may implement. This provider is called by the JcrResourceProvider if a node has no sling:resourceType property. In a custom resource provider, you could find a sling:resourceType property up the ancestors of the node to build inheritance this way. HTH Felix, Yes It does to a degree I had a look at that interface and it works if there is a Node, but URL does not directly map to the JCR path either because the JCR path doesnt exist yet, or because there is mapping between the URL and the JCR path, then there is no Node, so the JcrResourceType doesnt get called. What *would* work is something like /** * Provide a resource type for resource paths which do not have * resourceType. */ public interface ResourceTypeProvider { /** * Return the resource type to use for the node. * @param absPath The node. * @return The resource type to use or null. */ String getResourceTypeForPath(String absPath) throws RepositoryException; } That would also get rid of the need for my patch local on ResourceProvider registrations (classifier) Ian Regards Felix
[jira] Created: (SLING-992) Document Servlet Resolution and Error Handling
Document Servlet Resolution and Error Handling -- Key: SLING-992 URL: https://issues.apache.org/jira/browse/SLING-992 Project: Sling Issue Type: Task Components: Documentation Reporter: Felix Meschberger The Sling Servlet Resovler bundle provides elaborate functionality to select a Script or Servlet to handle a request. In addition it provides nice functionality to select error handler Scripts or Servlets to handle HttpServletResponse.sendError calls. This functionality should be described. Some rough information has already been gathered on our wiki at [1] from mail conversations. This should be enhanced and extended. [1] http://cwiki.apache.org/confluence/display/SLING/URL+to+Script+Resolution -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
Re: Binding to a resource Type
Hi, Each ResourceProvider is responsible for setting up resources themselves, including setting the resource type. For example the BundleResourceProvider sets the resource type to nt:file or nt:folder depending on whether the resource is a file or folder. The JcrResourceProvider now uses the ResourceTypeProvider service to enhance its resource type resolution: (1) check sling:resourceType property (2) check ResourceTypeProvider services (3) take primary node type Your (remaining) problem probably is the resource type of non-existing resources which is currently hard coded to sling:nonexisting and it is also defined in the API that a non existing resource has the sling:nonexisting resource type. It might be conceivable though to set the resourceSuperType of such non-existing resources to something configurable. To do this I would suggest to introduce a new service interface, which would be called when the ResourceResolver is about to create the NonExistingResource. Regards Felix Ian Boston schrieb: > > On 3 Jun 2009, at 09:26, Felix Meschberger wrote: > >> Not in the sense of "inheriting the resource type from the parent node >> if none is set". >> >> But: We have a ResourceTypeProvider service interface, which you may >> implement. This provider is called by the JcrResourceProvider if a node >> has no sling:resourceType property. >> >> In a custom resource provider, you could find a sling:resourceType >> property up the ancestors of the node to build inheritance this way. >> >> HTH > > Felix, > > Yes It does to a degree > > I had a look at that interface and it works if there is a Node, but URL > does not directly map to the JCR path either because the JCR path doesnt > exist yet, or because there is mapping between the URL and the JCR path, > then there is no Node, so the JcrResourceType doesnt get called. > > What *would* work is something like > > /** > * Provide a resource type for resource paths which do not have > * resourceType. > */ > public interface ResourceTypeProvider { > > /** > * Return the resource type to use for the node. > * @param absPath The node. > * @return The resource type to use or null. > */ > String getResourceTypeForPath(String absPath) throws > RepositoryException; > } > > That would also get rid of the need for my patch local on > ResourceProvider registrations (classifier) > > Ian > > >> >> >> Regards >> Felix > >
Re: Binding to a resource Type
On 3 Jun 2009, at 09:26, Felix Meschberger wrote: Not in the sense of "inheriting the resource type from the parent node if none is set". But: We have a ResourceTypeProvider service interface, which you may implement. This provider is called by the JcrResourceProvider if a node has no sling:resourceType property. In a custom resource provider, you could find a sling:resourceType property up the ancestors of the node to build inheritance this way. HTH Felix, Yes It does to a degree I had a look at that interface and it works if there is a Node, but URL does not directly map to the JCR path either because the JCR path doesnt exist yet, or because there is mapping between the URL and the JCR path, then there is no Node, so the JcrResourceType doesnt get called. What *would* work is something like /** * Provide a resource type for resource paths which do not have * resourceType. */ public interface ResourceTypeProvider { /** * Return the resource type to use for the node. * @param absPath The node. * @return The resource type to use or null. */ String getResourceTypeForPath(String absPath) throws RepositoryException; } That would also get rid of the need for my patch local on ResourceProvider registrations (classifier) Ian Regards Felix
[jira] Commented: (SLING-990) Prototype for a Sling Explorer implementation based on GWT
[ https://issues.apache.org/jira/browse/SLING-990?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12715868#action_12715868 ] Felix Meschberger commented on SLING-990: - > I will modify the JSON scripts. Cool, so we get a Resource tree explorer ! > The resources (images, css & js) are under LGPL. I took those files from > Smart GWT 1.1 distribution. Maybe we can use others. Could these be extracted from the artifact downloaded from the maven repository on build time ? So that we don't have to store this in our SVN. > If LGPL is an issue, we cannot continue to use SmartGwt because the current > implementention requires 2 SmartGWT jars > (see the pom.xml). Those jars are also under LGPL. There are used to run the > application in the hosted mode and compile > de java code into js. Would it be a big problem to not be able to use SmartGWT ? > Prototype for a Sling Explorer implementation based on GWT > -- > > Key: SLING-990 > URL: https://issues.apache.org/jira/browse/SLING-990 > Project: Sling > Issue Type: New Feature > Components: Extensions >Reporter: Christophe Lombart > Attachments: Sling Explorer.zip > > > Following the Sling Explorer proposal [1], I have started an implementation > with the SwartGwt UI framework [2] (based on GWT and under LGPL licence). > Not sure but I think that LGPL is compatible with the Apache project. > Until now, it is just a prototype. Can you review the code and see if this > Gwt application is well integrated with Sling ? > [1] http://cwiki.apache.org/SLING/sling-based-jcr-explorer.html > [2] http://code.google.com/p/smartgwt/ -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
[jira] Commented: (SLING-990) Prototype for a Sling Explorer implementation based on GWT
[ https://issues.apache.org/jira/browse/SLING-990?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12715866#action_12715866 ] Christophe Lombart commented on SLING-990: -- I will modify the JSON scripts. Ok for LICENSE, NOTICE & DISCLAIMER. I will add them if we can resolve the license issue. The resources (images, css & js) are under LGPL. I took those files from Smart GWT 1.1 distribution. Maybe we can use others. If LGPL is an issue, we cannot continue to use SmartGwt because the current implementention requires 2 SmartGWT jars (see the pom.xml). Those jars are also under LGPL. There are used to run the application in the hosted mode and compile de java code into js. > Prototype for a Sling Explorer implementation based on GWT > -- > > Key: SLING-990 > URL: https://issues.apache.org/jira/browse/SLING-990 > Project: Sling > Issue Type: New Feature > Components: Extensions >Reporter: Christophe Lombart > Attachments: Sling Explorer.zip > > > Following the Sling Explorer proposal [1], I have started an implementation > with the SwartGwt UI framework [2] (based on GWT and under LGPL licence). > Not sure but I think that LGPL is compatible with the Apache project. > Until now, it is just a prototype. Can you review the code and see if this > Gwt application is well integrated with Sling ? > [1] http://cwiki.apache.org/SLING/sling-based-jcr-explorer.html > [2] http://code.google.com/p/smartgwt/ -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
Re: Binding to a resource Type
Hi, Ian Boston schrieb: > > On 3 Jun 2009, at 06:32, Felix Meschberger wrote: > >> Hi Ian, >> >> Ian Boston schrieb: >>> Should a servlet (with sling.servlet.resourceTypes value="x") bind to >>> JCR nodes where a parent node has a resourceType of x, or will it only >>> bind to JCR nodes where the node itself has the resourceType x ? >> >> I do not exactly understand what you mean by "bind to JCR nodes" ? >> > > > I mean, when I have servlet with >> sling.servlet.resourceTypes = "x" > > and send a request for node with a sling:resourceType=x the request will > get routed to the servlet (assuming it can handle the request method, > and selector) > > However, > If I send a request for a child node of the node with > sling:resourceType=x, the request does not get routed to the servlet. Correct. Each resource has its own resource type. > ie there is no resourceType inheritance by default in Sling. Not in the sense of "inheriting the resource type from the parent node if none is set". But: We have a ResourceTypeProvider service interface, which you may implement. This provider is called by the JcrResourceProvider if a node has no sling:resourceType property. In a custom resource provider, you could find a sling:resourceType property up the ancestors of the node to build inheritance this way. HTH Regards Felix > > Ian > > >> Registered servlets are not "bound to JCR nodes" but are added to the >> resource tree at predefined locations. For example a servlet >> registered with >> >> sling.servlet.resourceTypes = "x" >> sling.servlet.extensions = "html" >> >> is added to the resource tree (by default) at >> >> /apps/x/html.servlet >> >> This node (a leaf actually) in the resource tree is not backed by a JCR >> item and is only accessible through the resource resolver and only >> exists as long as the Servlet Resolver is active and the servlet is >> registered. >> >> Hope this helps. >> >> Regards >> Felix > >
Re: [CONF] Apache Sling Website: Discover Sling in 15 minutes (page edited)
sure thanks On Thu, May 28, 2009 at 11:13 PM, Mike Müller wrote: > Hi Benjamin > > Thank you for your corrections. I took it over to the Sling website. > If you have more updates/corrections or even new documenations/examples > feel free to contact me. > > best regards > mike > >> -Original Message- >> From: pub cog [mailto:pub@gmail.com] >> Sent: Thursday, May 28, 2009 3:53 PM >> To: sling-dev@incubator.apache.org >> Subject: Re: [CONF] Apache Sling Website: Discover Sling in 15 minutes >> (page edited) >> >> >> Done. You can review changes >> http://cwiki.apache.org/confluence/display/SLING/Discover+Slin >> g+in+15+minutes >> ;) >> http://cwiki.apache.org/confluence/pages/viewpreviouspageversi > ons.action?pageId=118769 > > Also, in http://incubator.apache.org/sling/site/architecture.html: > > "... Web Applications with Sling, *a an* API has been defined..." > there is an extra "a" > "... Web Applications with Sling, *an* API has been defined..." > > as I said minor ;) > >
Re: Geographical Datastore and Posgis integration
Thanks a lot, that's exactly the information I was looking for :) I'll dive into this and try to make a first prototype. Thanks again :) On Thu, May 28, 2009 at 11:52 PM, Paul Mietz Egli wrote: > Regarding importing KML into JCR: > >> If that's what you meant, I didn't thought of this, why not... I need >> to think about it... >> search may be easier but that means I need to make some kind of >> automatic parsing transformation to jcr ,nodes ? > > Try using Session.importXML() first and see if that meets your needs: > > http://www.day.com/maven/jsr170/javadocs/jcr-1.0/javax/jcr/Session.html#importXML(java.lang.String,%20java.io.InputStream,%20int) > > From the javadocs: > > "The tree of new items is built in the transient storage of the Session. In > order to persist the new content, save must be called. The advantage of this > through-the-session method is that (depending on what constraint checks the > implementation leaves until save) structures that violate node type > constraints can be imported, fixed and then saved. The disadvantage is that > a large import will result in a large cache of pending nodes in the session. > See Workspace.importXML(java.lang.String, java.io.InputStream, int) for a > version of this method that does not go through the Session." > >> On an architectural point of view, I thought about having a Sling >> server and a postgis database separate. >> - Sling: will actually store files and properties associated with them >> - Postgis: will store only a jcr path and 'geom' informations >> - Java: code some java component(s) (osgi bundle ?) to synchronize both > > > In Postgres, I'd suggest using a UUID of the root of the KML doc instead of > a JCR path since paths can change. You can then use Session.getNodeByUUID() > to look up the KML node. > >> Step n°1: I was thinking to use some kind of 'hook' on ressource >> creation/update to compute the geom and store a couple >> (path_in_jcr/geom) in postgres/postgis >> Should I do such a hook by "Extending the SlingPostServlet" describe >> in "Advanced Topic" (5) ?! > > Sounds like your KML is arriving in the body of an HTTP POST request. You > could extend the SlingPostServlet as described in the docs to handle > importing the KML (e.g. by passing the servlet input stream into > Session.importXML). If your geometry computations take more than a few > hundred milliseconds, you should consider doing them in a JCR EventListener > that gets called after your nodes are created rather than in-process with > the HTTP request. Rough code would be: > > > /** > * @scr.component metatype="false" enabled="true" immediate="true" > * @scr.service > interface="org.apache.sling.servlets.post.SlingPostOperation" > * @scr.property name="sling.post.operation" value="myoperation" > * > * @author Paul Mietz Egli > */ > public class MyPostOperation extends AbstractSlingPostOperation { > �...@override > protected void doRun(SlingHttpServletRequest request, HtmlResponse > response, List changes) throws RepositoryException { > String basepath = "/content/kml"; // TODO use @scr.property to set > actual value > Session session = > request.getResourceResolver().adaptTo(Session.class); > session.importXML(basepath, request.getInputStream(), > ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW); > // TODO maybe set a custom node type on the root of your KML doc that > you can use in the event listener > } > } > > * @scr.component metatype="true" enabled="true" immediate="true" > * @scr.service interface="javax.jcr.observation.EventListener" > * > * @author Paul Mietz Egli > */ > public class GeometryComputationEventListener implements EventListener { > /** > * @scr.reference > */ > private SlingRepository repository; > > protected void activate(ComponentContext context) { > try { > String path = "/content/kml"; > String[] nodeTypes = new String[] { "nt:unstructured" }; > session = repository.loginAdministrative(null); > ObservationManager observationManager = > session.getWorkspace().getObservationManager(); > observationManager.addEventListener(this, Event.NODE_ADDED, path, > true, null, nodeTypes, false); > } > catch (RepositoryException e) {} > } > > public void onEvent(EventIterator eventIterator) { > while (eventIterator.hasNext()) { > Event event = (Event) eventIterator.next(); > switch (event.getType()) { > case Event.NODE_ADDED: > // TODO test node type/location to make sure you're > seeing the root of the KML tree > // TODO pull placemarks out of KML tree and convert to > WKT for PostGIS > } > } > } > } > } > > > > > p.
Re: Binding to a resource Type
On 3 Jun 2009, at 06:32, Felix Meschberger wrote: Hi Ian, Ian Boston schrieb: Should a servlet (with sling.servlet.resourceTypes value="x") bind to JCR nodes where a parent node has a resourceType of x, or will it only bind to JCR nodes where the node itself has the resourceType x ? I do not exactly understand what you mean by "bind to JCR nodes" ? I mean, when I have servlet with sling.servlet.resourceTypes = "x" and send a request for node with a sling:resourceType=x the request will get routed to the servlet (assuming it can handle the request method, and selector) However, If I send a request for a child node of the node with sling:resourceType=x, the request does not get routed to the servlet. ie there is no resourceType inheritance by default in Sling. Ian Registered servlets are not "bound to JCR nodes" but are added to the resource tree at predefined locations. For example a servlet registered with sling.servlet.resourceTypes = "x" sling.servlet.extensions = "html" is added to the resource tree (by default) at /apps/x/html.servlet This node (a leaf actually) in the resource tree is not backed by a JCR item and is only accessible through the resource resolver and only exists as long as the Servlet Resolver is active and the servlet is registered. Hope this helps. Regards Felix
Re: JcrResoruceResolver2, by design ?
On 3 Jun 2009, at 06:26, Felix Meschberger wrote: Hi Ian, I could imagine two approaches to your problem: (1) Register a resource provider for the root node of your "hashed" tree. When asked for a resource, it will apply the mapping function to find the actual resource. Felix, This is the one I am working on, I have a patch that adds a "classifier" to the registration of a ResourceProvider that allows more more than one ResourceProvider to be registered per path (but only one per path/classifier). I don't believe I have this perfect at the moment since my OSGi container crashes after several reloads pointing to an unbind problem. Hashing inside the ResoruceProvider causes all sorts of problems with recursion especially where the hashed path does not exist in the JCR, including where the point of recursion is in JcrResourceResolver2. However a ResoruceProvider that creates a synthetic resource based on parent sling:resourceType that then triggers a set of servlets bound to that resource type looks more promising and simpler. (2) Employ the dynamic URL Rewriting patch you proposed in SLING-986: You attach that rewriter such that it resoloves and maps as required. I haven't tried this yet, but I suspect that it might be a better way of doing it, I was a little concerned about triggering a walk up the node hierarchy so early in the request lifecycle. (I also think that the API might need some extra parameters) The advantage of the second approach is, that you have a "free" two- way mapping for resolving URLs (incoming) and mapping resource paths to URLs (outgoing). The disadvantage of both approaches is, that it is actually configuration and a simple resource creation à-la curl -F"sling:resourceType:sakai/store" http://localhost:8080/ bigstore might not be enough and you would have some additional functionality (a listener maybe) to set this up on demand. I am not certain I understand this bit? I have found that resourceTypes are not inherited, but that can be handled in the ResourceProvider or the dynamic mapper. Thanks for thinking about this. Ian Regards Felix Ian Boston schrieb: On 2 Jun 2009, at 16:09, Paul Noden wrote: Hi Ian, 2009/6/2 Ian Boston AFAICT its impossible to virtualize paths (URI wrt JCR path) using this approach in the JCR. Unfortunately for me, its a use case I can't ignore as we have lots of situations where a non listable could contain millions of items. Back to square one. The current design and intention is, that for any one (root) path there may only be one resource provider registered. So for example, for a (root) path "/some/path", there may only one. Of course there may be another one at "/some" or at "/some/path/below". I want to be able to bind a special Resource to a node with a corresponding resourceType (created by the application) anywhere in the content system, so that all the standard Sling processing can access that Resource. For example: I want to be able to create a node anywhere in the content system, and under that node have a hashed store that is managed as if the entire node space was flattened. eg the URL /x/y/z/store/12312312/a/b/c is mapped to JCR space /x/y/z/store/content/aa/bb/cc/dd/12312312/a/b/c using the ResourceProducer mechanism. Can you go into some more detail regarding the requirements for this strategy? Paul, Sure, I need to create stores of potentially a large number of items single locations in URL space where the items can be accessed by a URL reference each other. be listed by paged search. The main requirement is that the collection should be addressable with the following form /x/y/z/1001 The path might extend further eg /x/y/z/1001/d/e/f the cannonical form being /x/y/z/n/** where n is one of a set of a large number of items (eg 10M) AFAIK, to make this work JCR n needs to be expanded to a hashed tree eg /x/y/z/aa/bb/cc/dd/n/** Having performed the hashing, I would ideally like to reuse the SlingPostServlet and related functionality, so that curl -F"sling:resourceType:sakai/store" http://localhost:8080/ bigstore creates a store (identified by the sakai/store resourceType) curl -F"status:stage1" http://localhost:8080/bigstore.create.html a redirect coming back to (ad23415g4 is an opaque token) http://localhost:8080/bigstore/ad23415g4 Which can then be used in further operations on that item. Could you use node representations in store to placehold/redirect to the nested content at "content/aa/bb/cc/dd/"? Provided that HTTP would never see content/aa/bb/cc/dd/, but I guess by redirect, you mean http redirect, in which case, no since relative URL's break at this point. eg ../ad23415g4/related_information.html Regards, Paul Noden
[jira] Closed: (SLING-991) JcrResourceResolver2.map does not handle resource paths with fragments and queries correctly
[ https://issues.apache.org/jira/browse/SLING-991?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Felix Meschberger closed SLING-991. --- This can be closed > JcrResourceResolver2.map does not handle resource paths with fragments and > queries correctly > > > Key: SLING-991 > URL: https://issues.apache.org/jira/browse/SLING-991 > Project: Sling > Issue Type: Bug > Components: JCR Resource >Affects Versions: JCR Resource 2.0.4 >Reporter: Felix Meschberger >Assignee: Felix Meschberger > Fix For: JCR Resource 2.0.6 > > > The JcrResourceResolver2.map(HttpServletRequest, String) method does not > handle any fragements and queries in the resource path correctly, when > mapping from the internal path to the external URL. > The intent of the map method is to take any string, which is prepared to act > as a link URL and to map the resource path to a valid URL, which may be > resovled by the resolve method. Any selectors, extension and suffix are > correctly cut of the path to get the raw resource path to map. But fragments > and queries are not handled correclty. > Consider the following examples based on an existing resource /content/home: > /content/home --> use as is, nothing to cut off > /content/home.html --> cut off extension before mapping > /content/home.sel.html --> cut off selector and extension before mapping > /content/home.html/some/suffix --> cut off extension and suffix before > mapping > /content/home.html#sec1?a:b=1 --> cut off extension, fragment and query > before mapping > The last part is not being done currently, which is a problem and might leed > to wrong mapping results, particularly if the query contains colons, which > would result in wrong namespace mangling. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.
[jira] Resolved: (SLING-991) JcrResourceResolver2.map does not handle resource paths with fragments and queries correctly
[ https://issues.apache.org/jira/browse/SLING-991?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Felix Meschberger resolved SLING-991. - Resolution: Fixed Applied fix to this problem in Rev. 781285: * Cut off fragment and/or query before applying mapping algorithm * Append fragment and/or query after the mapping * Remove special query handling from the mangleNameSpaces method introduced with SLING-906 * Add test cases > JcrResourceResolver2.map does not handle resource paths with fragments and > queries correctly > > > Key: SLING-991 > URL: https://issues.apache.org/jira/browse/SLING-991 > Project: Sling > Issue Type: Bug > Components: JCR Resource >Affects Versions: JCR Resource 2.0.4 >Reporter: Felix Meschberger >Assignee: Felix Meschberger > Fix For: JCR Resource 2.0.6 > > > The JcrResourceResolver2.map(HttpServletRequest, String) method does not > handle any fragements and queries in the resource path correctly, when > mapping from the internal path to the external URL. > The intent of the map method is to take any string, which is prepared to act > as a link URL and to map the resource path to a valid URL, which may be > resovled by the resolve method. Any selectors, extension and suffix are > correctly cut of the path to get the raw resource path to map. But fragments > and queries are not handled correclty. > Consider the following examples based on an existing resource /content/home: > /content/home --> use as is, nothing to cut off > /content/home.html --> cut off extension before mapping > /content/home.sel.html --> cut off selector and extension before mapping > /content/home.html/some/suffix --> cut off extension and suffix before > mapping > /content/home.html#sec1?a:b=1 --> cut off extension, fragment and query > before mapping > The last part is not being done currently, which is a problem and might leed > to wrong mapping results, particularly if the query contains colons, which > would result in wrong namespace mangling. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.