You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Philipp Koch (JIRA)" <ji...@apache.org> on 2008/03/04 14:38:44 UTC

[jira] Created: (SLING-307) QueryServlet

QueryServlet
------------

                 Key: SLING-307
                 URL: https://issues.apache.org/jira/browse/SLING-307
             Project: Sling
          Issue Type: New Feature
          Components: Default Servlets
            Reporter: Philipp Koch


it would be nice to have a way to specify a jcr query in the url in order to query the underlying jcr repository.

the attached patch works as follows:
The new query servlet is called if the extension is ".json" and the selector is set to "query". you can pass following parameters in the url:
statement: jcr query statement (XPATH or  SQL)
queryType: xpath or sql (of none is specified xpath is taken)
property: specifies which property (relative path) has to be "put" into the result set (this parameter can be added multiple times)
excerptPath: specifies the relative node path from where the excerpt has to be built.

the result is returned as json string. e.g.:
[
{"name":"ee0","rep:excerpt()":"<excerpt><fragment>geometrixx/components/contentpage ... ee<\/fragment><\/excerpt>","jcr:path":"/content/ee0","jcr:score":"528","cq:content/jcr:title":"ee"},
{"name":"news","rep:excerpt()":"<excerpt><fragment> ... geometrixx/components/contentpage ...  ...  ...  ... news about geometrix<\/fragment><\/excerpt>","jcr:path":"/content/geometrixx/en/about/news","jcr:score":"521","cq:content/jcr:title":"News"}
]

example query call:
http://localhost:8080/sling/myhome.query.json?statement=//element(*,cq:Page)[jcr:contains(.,'sling')]/(rep:excerpt(.))&property=cq:content/jcr:title&excerptPath=cq:content
 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SLING-307) QueryServlet

Posted by "Philipp Koch (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-307?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Philipp Koch updated SLING-307:
-------------------------------

    Attachment: queryservlet.patch

> QueryServlet
> ------------
>
>                 Key: SLING-307
>                 URL: https://issues.apache.org/jira/browse/SLING-307
>             Project: Sling
>          Issue Type: New Feature
>          Components: Default Servlets
>            Reporter: Philipp Koch
>         Attachments: queryservlet.patch
>
>
> it would be nice to have a way to specify a jcr query in the url in order to query the underlying jcr repository.
> the attached patch works as follows:
> The new query servlet is called if the extension is ".json" and the selector is set to "query". you can pass following parameters in the url:
> statement: jcr query statement (XPATH or  SQL)
> queryType: xpath or sql (of none is specified xpath is taken)
> property: specifies which property (relative path) has to be "put" into the result set (this parameter can be added multiple times)
> excerptPath: specifies the relative node path from where the excerpt has to be built.
> the result is returned as json string. e.g.:
> [
> {"name":"ee0","rep:excerpt()":"<excerpt><fragment>geometrixx/components/contentpage ... ee<\/fragment><\/excerpt>","jcr:path":"/content/ee0","jcr:score":"528","cq:content/jcr:title":"ee"},
> {"name":"news","rep:excerpt()":"<excerpt><fragment> ... geometrixx/components/contentpage ...  ...  ...  ... news about geometrix<\/fragment><\/excerpt>","jcr:path":"/content/geometrixx/en/about/news","jcr:score":"521","cq:content/jcr:title":"News"}
> ]
> example query call:
> http://localhost:8080/sling/myhome.query.json?statement=//element(*,cq:Page)[jcr:contains(.,'sling')]/(rep:excerpt(.))&property=cq:content/jcr:title&excerptPath=cq:content
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (SLING-307) QueryServlet

Posted by "Bertrand Delacretaz (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-307?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bertrand Delacretaz reassigned SLING-307:
-----------------------------------------

    Assignee: Bertrand Delacretaz

> QueryServlet
> ------------
>
>                 Key: SLING-307
>                 URL: https://issues.apache.org/jira/browse/SLING-307
>             Project: Sling
>          Issue Type: New Feature
>          Components: Default Servlets
>            Reporter: Philipp Koch
>            Assignee: Bertrand Delacretaz
>         Attachments: queryservlet.patch
>
>
> it would be nice to have a way to specify a jcr query in the url in order to query the underlying jcr repository.
> the attached patch works as follows:
> The new query servlet is called if the extension is ".json" and the selector is set to "query". you can pass following parameters in the url:
> statement: jcr query statement (XPATH or  SQL)
> queryType: xpath or sql (of none is specified xpath is taken)
> property: specifies which property (relative path) has to be "put" into the result set (this parameter can be added multiple times)
> excerptPath: specifies the relative node path from where the excerpt has to be built.
> the result is returned as json string. e.g.:
> [
> {"name":"ee0","rep:excerpt()":"<excerpt><fragment>geometrixx/components/contentpage ... ee<\/fragment><\/excerpt>","jcr:path":"/content/ee0","jcr:score":"528","cq:content/jcr:title":"ee"},
> {"name":"news","rep:excerpt()":"<excerpt><fragment> ... geometrixx/components/contentpage ...  ...  ...  ... news about geometrix<\/fragment><\/excerpt>","jcr:path":"/content/geometrixx/en/about/news","jcr:score":"521","cq:content/jcr:title":"News"}
> ]
> example query call:
> http://localhost:8080/sling/myhome.query.json?statement=//element(*,cq:Page)[jcr:contains(.,'sling')]/(rep:excerpt(.))&property=cq:content/jcr:title&excerptPath=cq:content
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (SLING-307) JsonQueryServlet

Posted by "Bertrand Delacretaz (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-307?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bertrand Delacretaz updated SLING-307:
--------------------------------------

    Summary: JsonQueryServlet  (was: QueryServlet)

> JsonQueryServlet
> ----------------
>
>                 Key: SLING-307
>                 URL: https://issues.apache.org/jira/browse/SLING-307
>             Project: Sling
>          Issue Type: New Feature
>          Components: Default Servlets
>            Reporter: Philipp Koch
>            Assignee: Bertrand Delacretaz
>         Attachments: queryservlet.patch
>
>
> it would be nice to have a way to specify a jcr query in the url in order to query the underlying jcr repository.
> the attached patch works as follows:
> The new query servlet is called if the extension is ".json" and the selector is set to "query". you can pass following parameters in the url:
> statement: jcr query statement (XPATH or  SQL)
> queryType: xpath or sql (of none is specified xpath is taken)
> property: specifies which property (relative path) has to be "put" into the result set (this parameter can be added multiple times)
> excerptPath: specifies the relative node path from where the excerpt has to be built.
> the result is returned as json string. e.g.:
> [
> {"name":"ee0","rep:excerpt()":"<excerpt><fragment>geometrixx/components/contentpage ... ee<\/fragment><\/excerpt>","jcr:path":"/content/ee0","jcr:score":"528","cq:content/jcr:title":"ee"},
> {"name":"news","rep:excerpt()":"<excerpt><fragment> ... geometrixx/components/contentpage ...  ...  ...  ... news about geometrix<\/fragment><\/excerpt>","jcr:path":"/content/geometrixx/en/about/news","jcr:score":"521","cq:content/jcr:title":"News"}
> ]
> example query call:
> http://localhost:8080/sling/myhome.query.json?statement=//element(*,cq:Page)[jcr:contains(.,'sling')]/(rep:excerpt(.))&property=cq:content/jcr:title&excerptPath=cq:content
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SLING-307) QueryServlet

Posted by "Bertrand Delacretaz (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-307?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12575337#action_12575337 ] 

Bertrand Delacretaz commented on SLING-307:
-------------------------------------------

Patch applied in revision 633842 with the following changes:

-Servlet renamed to JsonQueryServlet
-content-type was not set
-the "rows" parameter was off by one, rows=3 would return 4 rows

Also added a simple integration test, in launchpad/webapp, JsonQueryServletTest

Thanks for your contribution!

Leaving this issue open, as we might want to simplify the querying code by taking advantage of ResourceResolver.findResources()

> QueryServlet
> ------------
>
>                 Key: SLING-307
>                 URL: https://issues.apache.org/jira/browse/SLING-307
>             Project: Sling
>          Issue Type: New Feature
>          Components: Default Servlets
>            Reporter: Philipp Koch
>            Assignee: Bertrand Delacretaz
>         Attachments: queryservlet.patch
>
>
> it would be nice to have a way to specify a jcr query in the url in order to query the underlying jcr repository.
> the attached patch works as follows:
> The new query servlet is called if the extension is ".json" and the selector is set to "query". you can pass following parameters in the url:
> statement: jcr query statement (XPATH or  SQL)
> queryType: xpath or sql (of none is specified xpath is taken)
> property: specifies which property (relative path) has to be "put" into the result set (this parameter can be added multiple times)
> excerptPath: specifies the relative node path from where the excerpt has to be built.
> the result is returned as json string. e.g.:
> [
> {"name":"ee0","rep:excerpt()":"<excerpt><fragment>geometrixx/components/contentpage ... ee<\/fragment><\/excerpt>","jcr:path":"/content/ee0","jcr:score":"528","cq:content/jcr:title":"ee"},
> {"name":"news","rep:excerpt()":"<excerpt><fragment> ... geometrixx/components/contentpage ...  ...  ...  ... news about geometrix<\/fragment><\/excerpt>","jcr:path":"/content/geometrixx/en/about/news","jcr:score":"521","cq:content/jcr:title":"News"}
> ]
> example query call:
> http://localhost:8080/sling/myhome.query.json?statement=//element(*,cq:Page)[jcr:contains(.,'sling')]/(rep:excerpt(.))&property=cq:content/jcr:title&excerptPath=cq:content
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (SLING-307) JsonQueryServlet

Posted by "Bertrand Delacretaz (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-307?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bertrand Delacretaz closed SLING-307.
-------------------------------------


Verified that all tests pass, closing, thanks!

> JsonQueryServlet
> ----------------
>
>                 Key: SLING-307
>                 URL: https://issues.apache.org/jira/browse/SLING-307
>             Project: Sling
>          Issue Type: New Feature
>          Components: Default Servlets
>            Reporter: Philipp Koch
>            Assignee: Bertrand Delacretaz
>             Fix For: 2.0.0
>
>         Attachments: queryservlet.patch
>
>
> it would be nice to have a way to specify a jcr query in the url in order to query the underlying jcr repository.
> the attached patch works as follows:
> The new query servlet is called if the extension is ".json" and the selector is set to "query". you can pass following parameters in the url:
> statement: jcr query statement (XPATH or  SQL)
> queryType: xpath or sql (of none is specified xpath is taken)
> property: specifies which property (relative path) has to be "put" into the result set (this parameter can be added multiple times)
> excerptPath: specifies the relative node path from where the excerpt has to be built.
> the result is returned as json string. e.g.:
> [
> {"name":"ee0","rep:excerpt()":"<excerpt><fragment>geometrixx/components/contentpage ... ee<\/fragment><\/excerpt>","jcr:path":"/content/ee0","jcr:score":"528","cq:content/jcr:title":"ee"},
> {"name":"news","rep:excerpt()":"<excerpt><fragment> ... geometrixx/components/contentpage ...  ...  ...  ... news about geometrix<\/fragment><\/excerpt>","jcr:path":"/content/geometrixx/en/about/news","jcr:score":"521","cq:content/jcr:title":"News"}
> ]
> example query call:
> http://localhost:8080/sling/myhome.query.json?statement=//element(*,cq:Page)[jcr:contains(.,'sling')]/(rep:excerpt(.))&property=cq:content/jcr:title&excerptPath=cq:content
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (SLING-307) JsonQueryServlet

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-307?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger resolved SLING-307.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.0.0

After adapting the JsonQueryServlet to the Resource paradigm in Rev. 636656 I think this issue can be resolved.

And of course the integration tests still succeed ;-)

Please close if it works ok for you. Thanks.

> JsonQueryServlet
> ----------------
>
>                 Key: SLING-307
>                 URL: https://issues.apache.org/jira/browse/SLING-307
>             Project: Sling
>          Issue Type: New Feature
>          Components: Default Servlets
>            Reporter: Philipp Koch
>            Assignee: Bertrand Delacretaz
>             Fix For: 2.0.0
>
>         Attachments: queryservlet.patch
>
>
> it would be nice to have a way to specify a jcr query in the url in order to query the underlying jcr repository.
> the attached patch works as follows:
> The new query servlet is called if the extension is ".json" and the selector is set to "query". you can pass following parameters in the url:
> statement: jcr query statement (XPATH or  SQL)
> queryType: xpath or sql (of none is specified xpath is taken)
> property: specifies which property (relative path) has to be "put" into the result set (this parameter can be added multiple times)
> excerptPath: specifies the relative node path from where the excerpt has to be built.
> the result is returned as json string. e.g.:
> [
> {"name":"ee0","rep:excerpt()":"<excerpt><fragment>geometrixx/components/contentpage ... ee<\/fragment><\/excerpt>","jcr:path":"/content/ee0","jcr:score":"528","cq:content/jcr:title":"ee"},
> {"name":"news","rep:excerpt()":"<excerpt><fragment> ... geometrixx/components/contentpage ...  ...  ...  ... news about geometrix<\/fragment><\/excerpt>","jcr:path":"/content/geometrixx/en/about/news","jcr:score":"521","cq:content/jcr:title":"News"}
> ]
> example query call:
> http://localhost:8080/sling/myhome.query.json?statement=//element(*,cq:Page)[jcr:contains(.,'sling')]/(rep:excerpt(.))&property=cq:content/jcr:title&excerptPath=cq:content
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.