2011年3月28日 星期一

another example for query jcr data.

http://localhost:8080/content.query.json?statement=//*[@jcr:primaryType='nt:file']&property=jcr:content/jcr:mimeType

[{"name":"search.scala","jcr:path":"/apps/forum/search.scala","jcr:score":3408,"jcr:primaryType":"nt:file"},{"name":"blue.css","jcr:path":"/apps/forum/static/blue.css","jcr:score":3408,"jcr:primaryType":"nt:file"},{"name":"logo","jcr:path":"/content/forum/sling/logo","jcr:score":3408,"jcr:primaryType":"nt:file"},{"name":"logo","jcr:path":"/content/forum/scala/logo","jcr:score":3408,"jcr:primaryType":"nt:file"},{"name":"POST.scala","jcr:path":"/apps/forum/POST.scala","jcr:score":3408,"jcr:primaryType":"nt:file"},{"name":"thread.scala","jcr:path":"/apps/forum/thread.scala","jcr:score":3408,"jcr:primaryType":"nt:file"},{"name":"html.scala","jcr:path":"/apps/forum/html.scala","jcr:score":3408,"jcr:primaryType":"nt:file"},{"name":"html.scala","jcr:path":"/apps/helloworld/html.scala","jcr:score":3408,"jcr:primaryType":"nt:file"},{"name":"searchRunner$$anonfun$main$1.class","jcr:path":"/var/classes/forum/searchRunner$$anonfun$main$1.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"search$$anonfun$1.class","jcr:path":"/var/classes/forum/search$$anonfun$1.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"searchRunner.class","jcr:path":"/var/classes/forum/searchRunner.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"searchRunner$.class","jcr:path":"/var/classes/forum/searchRunner$.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"searchArgs.class","jcr:path":"/var/classes/forum/searchArgs.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"searchRunner$$anonfun$main$1$$anonfun$apply$mcV$sp$1.class","jcr:path":"/var/classes/forum/searchRunner$$anonfun$main$1$$anonfun$apply$mcV$sp$1.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"search.class","jcr:path":"/var/classes/forum/search.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"html.class","jcr:path":"/var/classes/helloworld/html.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"html$$anon$2.class","jcr:path":"/var/classes/helloworld/html$$anon$2.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"html$Tree$.class","jcr:path":"/var/classes/helloworld/html$Tree$.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"html$$anon$2$$anon$1.class","jcr:path":"/var/classes/helloworld/html$$anon$2$$anon$1.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"htmlArgs.class","jcr:path":"/var/classes/helloworld/htmlArgs.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"htmlRunner$$anonfun$main$1$$anonfun$apply$mcV$sp$1.class","jcr:path":"/var/classes/helloworld/htmlRunner$$anonfun$main$1$$anonfun$apply$mcV$sp$1.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"htmlRunner.class","jcr:path":"/var/classes/helloworld/htmlRunner.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"htmlRunner$.class","jcr:path":"/var/classes/helloworld/htmlRunner$.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"html$Tree.class","jcr:path":"/var/classes/helloworld/html$Tree.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"html$Tree$$anonfun$1.class","jcr:path":"/var/classes/helloworld/html$Tree$$anonfun$1.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"htmlRunner$$anonfun$main$1.class","jcr:path":"/var/classes/helloworld/htmlRunner$$anonfun$main$1.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"utils.class","jcr:path":"/var/classes/forum/utils.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"utils$.class","jcr:path":"/var/classes/forum/utils$.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"utils$RichJCR$$anon$4.class","jcr:path":"/var/classes/forum/utils$RichJCR$$anon$4.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"html.class","jcr:path":"/var/classes/forum/html.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"ThreadOverview$$anonfun$render$1$$anonfun$apply$1.class","jcr:path":"/var/classes/forum/ThreadOverview$$anonfun$render$1$$anonfun$apply$1.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"htmlArgs.class","jcr:path":"/var/classes/forum/htmlArgs.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"utils$RichJCR$$anon$7.class","jcr:path":"/var/classes/forum/utils$RichJCR$$anon$7.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"utils$RichJCR$$anon$1.class","jcr:path":"/var/classes/forum/utils$RichJCR$$anon$1.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"ThreadOverview$$anonfun$render$1.class","jcr:path":"/var/classes/forum/ThreadOverview$$anonfun$render$1.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"htmlRunner.class","jcr:path":"/var/classes/forum/htmlRunner.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"htmlRunner$.class","jcr:path":"/var/classes/forum/htmlRunner$.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"utils$RichJCR$$anon$3.class","jcr:path":"/var/classes/forum/utils$RichJCR$$anon$3.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"utils$RichJCR$.class","jcr:path":"/var/classes/forum/utils$RichJCR$.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"htmlRunner$$anonfun$main$1$$anonfun$apply$mcV$sp$1.class","jcr:path":"/var/classes/forum/htmlRunner$$anonfun$main$1$$anonfun$apply$mcV$sp$1.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"utils$RichJCR$$anon$6.class","jcr:path":"/var/classes/forum/utils$RichJCR$$anon$6.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"ThreadNewForm.class","jcr:path":"/var/classes/forum/ThreadNewForm.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"ThreadNewForm$.class","jcr:path":"/var/classes/forum/ThreadNewForm$.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"utils$RichJCR$$anon$5.class","jcr:path":"/var/classes/forum/utils$RichJCR$$anon$5.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"SearchBox.class","jcr:path":"/var/classes/forum/SearchBox.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"SearchBox$.class","jcr:path":"/var/classes/forum/SearchBox$.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"ThreadOverview$$anonfun$forum$ThreadOverview$$toListItem$1.class","jcr:path":"/var/classes/forum/ThreadOverview$$anonfun$forum$ThreadOverview$$toListItem$1.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"ThreadOverview.class","jcr:path":"/var/classes/forum/ThreadOverview.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"ThreadOverview$.class","jcr:path":"/var/classes/forum/ThreadOverview$.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"htmlRunner$$anonfun$main$1.class","jcr:path":"/var/classes/forum/htmlRunner$$anonfun$main$1.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"utils$RichJCR$$anon$2.class","jcr:path":"/var/classes/forum/utils$RichJCR$$anon$2.class","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"assert.js","jcr:path":"/sling-test/sling/assert.js","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"sling.css","jcr:path":"/sling.css","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"sling-test.html","jcr:path":"/sling-test/sling/sling-test.html","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"signup.html","jcr:path":"/signup.html","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"sling-logo.png","jcr:path":"/sling-logo.png","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"acl.html.esp","jcr:path":"/apps/sling/servlet/default/acl.html.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"ace.html.esp","jcr:path":"/apps/sling/servlet/default/ace.html.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"i.html","jcr:path":"/i.html","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"constants.esp","jcr:path":"/apps/espblog/constants.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"menu.esp","jcr:path":"/apps/espblog/menu.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"sling-logo.png","jcr:path":"/apps/espblog/sling-logo.png","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"edit.esp","jcr:path":"/apps/espblog/edit.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"admin.esp","jcr:path":"/apps/espblog/admin.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"espblog.css","jcr:path":"/apps/espblog/espblog.css","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"html.esp","jcr:path":"/apps/espblog/html.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"list.esp","jcr:path":"/apps/espblog/list.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"xml.esp","jcr:path":"/apps/espblog/xml.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"header.esp","jcr:path":"/apps/espblog/header.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"javashell.esp","jcr:path":"/apps/javashell/javashell.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"siblings.esp","jcr:path":"/apps/javashell/siblings.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"sling-logo.png","jcr:path":"/apps/javashell/sling-logo.png","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"javashell.css","jcr:path":"/apps/javashell/javashell.css","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"edit.esp","jcr:path":"/apps/javashell/edit.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"order.esp","jcr:path":"/apps/slingbucks/order/order.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"backoffice.esp","jcr:path":"/apps/slingbucks/order/backoffice.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"slingbucks.css","jcr:path":"/apps/slingbucks/common/slingbucks.css","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"options.esp","jcr:path":"/apps/slingbucks/options/options.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"head.esp","jcr:path":"/apps/slingbucks/common/head.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"confirmed.esp","jcr:path":"/apps/slingbucks/confirmed/confirmed.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"price.esp","jcr:path":"/apps/slingbucks/order/price.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"orders.esp","jcr:path":"/apps/slingbucks/orders/orders.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"slingbucks.js","jcr:path":"/apps/slingbucks/common/slingbucks.js","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"POST.esp","jcr:path":"/apps/sling/webloader/POST.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"html.esp","jcr:path":"/apps/sling/webloader/html.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"mustache.js","jcr:path":"/mustache.js","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"html.esp","jcr:path":"/apps/blog/html.esp","jcr:score":6816,"jcr:primaryType":"nt:file"},{"name":"index.html","jcr:path":"/index.html","jcr:score":6816,"jcr:primaryType":"nt:file"}]

json query jcr data in sling

http://localhost:8080/content.query.json?queryType=xpath&statement=//*[jcr:contains(.,'sling')]/(rep:excerpt(.))

result:

[{"name":"forum","jcr:path":"/content/forum","rep:excerpt()":"
Scala for Sling<\/strong><\/span><\/div>","jcr:score":2257},{"name":"scala4sling","jcr:path":"/content/forum/scala4sling","rep:excerpt()":"
Sling<\/strong>. We use its DSL capability and support for XML literals to create type ...<\/span><\/div>","jcr:score":564},{"name":"sling","jcr:path":"/content/forum/sling","rep:excerpt()":"
Sling<\/strong> Apache Sling<\/strong> is an innovative web framework that is intended to bring back the fun to ...<\/span><\/div>","jcr:score":997},{"name":"jcr:content","jcr:path":"/var/classes/forum/searchArgs.class/jcr:content","rep:excerpt()":"
... currentSession;\n private org.apache.sling.scripting.core.ScriptHelper sling<\/strong>;\n private Object currentNode;\n private java.io.BufferedReader<\/span>... public org.apache.sling.scripting.core.ScriptHelper sling<\/strong>();\n public Object currentNode();\n public javax.jcr.Node ...<\/span><\/div>","jcr:score":499},{"name":"jcr:content","jcr:path":"/sling-test/sling/sling-test.html/jcr:content","rep:excerpt()":"
admin Sling<\/strong> client library test page\n\nAutomated Sling<\/strong> client library tests\n\nLoading this page executes some simple automated<\/span>\n\nMore info\n\nAfter running the tests at least once, /sling<\/strong>-test/testhtml-nodes.json\nshould show the JSON data of the nodes created ...<\/span><\/div>","jcr:score":846},{"name":"jcr:content","jcr:path":"/signup.html/jcr:content","rep:excerpt()":"
admin Sign Up to the Sling<\/strong> Launchpad\n \n \n \n \n \n <\/span>... \n\n \n \n \n \n \n \n Create a new accont in the Sling<\/strong> Launchpad\n\n \n \n We are sorry! This functionality ...<\/span><\/div>","jcr:score":1197},{"name":"jcr:content","jcr:path":"/i.html/jcr:content","rep:excerpt()":"
... ??? | Logout\n \n\n \n \n \n \n Welcome to the Sling<\/strong> Launchpad\n\n \n \n Apache Sling<\/strong> is a web framework that uses a Java Content Repository, \n such<\/span> \n\n \n The Sling<\/strong> Launchpad is a ready-to-run Sling<\/strong> configuration, providing an embedded \n JCR content repository<\/span>... our \n \n mailing lists\n to contact the Sling<\/strong> developers team.\n \n \n \n The Sling<\/strong> OSGi management console is available at system/console,\n use ...<\/span><\/div>","jcr:score":1018},{"name":"jcr:content","jcr:path":"/apps/javashell/javashell.esp/jcr:content","rep:excerpt()":"
... \t\tthe result of executing the above code, it probably means that the Sling<\/strong> - Scripting - Java Support\n\t\tbundle is not installed or not active ...<\/span><\/div>","jcr:score":564},{"name":"jcr:content","jcr:path":"/apps/sling/webloader/html.esp/jcr:content","rep:excerpt()":"
admin \n \n Sling<\/strong> Webloader\n\n \n \n \n \tThis page reloads itself<\/span>It is based on the\n \tthe Jackrabbit populate.jsp example, ported to Sling<\/strong> text/javascript<\/span><\/div>","jcr:score":798},{"name":"webloader","jcr:path":"/bin/sling/webloader","rep:excerpt()":"
sling<\/strong>/webloader<\/span><\/div>","jcr:score":2821},{"name":"jcr:content","jcr:path":"/var/classes/forum/htmlArgs.class/jcr:content","rep:excerpt()":"
... currentSession;\n private org.apache.sling.scripting.core.ScriptHelper sling<\/strong>;\n private Object currentNode;\n private java.io.BufferedReader<\/span>... public org.apache.sling.scripting.core.ScriptHelper sling<\/strong>();\n public Object currentNode();\n public javax.jcr.Node ...<\/span><\/div>","jcr:score":499},{"name":"jcr:content","jcr:path":"/var/classes/helloworld/htmlArgs.class/jcr:content","rep:excerpt()":"
... currentSession;\n private org.apache.sling.scripting.core.ScriptHelper sling<\/strong>;\n private Object currentNode;\n private java.io.BufferedReader<\/span>... public org.apache.sling.scripting.core.ScriptHelper sling<\/strong>();\n public Object currentNode();\n public javax.jcr.Node ...<\/span><\/div>","jcr:score":499},{"name":"jcr:content","jcr:path":"/apps/blog/html.esp/jcr:content","rep:excerpt()":"
admin Sling<\/strong> microblog\n\n \n \n \n Title:\n\n \n \n ...<\/span><\/div>","jcr:score":1410},{"name":"","jcr:path":"/","rep:excerpt()":"
sling<\/strong>:redirect /index.html<\/span><\/div>","jcr:score":2257},{"name":"jcr:frozenNode","jcr:path":"/jcr:system/jcr:versionStorage/c6/a3/9f/c6a39f69-5a20-4730-a48c-59d802df9b27/1.0/jcr:frozenNode","rep:excerpt()":"
Sling<\/strong>. We use its DSL capability and support for XML literals to create type ...<\/span><\/div>","jcr:score":564},{"name":"jcr:frozenNode","jcr:path":"/jcr:system/jcr:versionStorage/bb/47/3f/bb473f19-14fb-4bd1-90e3-bf1ff1ac268f/1.0/jcr:frozenNode","rep:excerpt()":"
bb473f19-14fb-4bd1-90e3-bf1ff1ac268f Sling<\/strong> Apache Sling<\/strong> is an innovative web framework that is intended to bring back the fun to ...<\/span><\/div>","jcr:score":997}]

2011年3月17日 星期四

how to change admin password for jakrabbit and sling

curl -F"oldPwd=admin" -F"newPwd=xxxx" -F"newPwdConfirm=xxxx" http://admin:admin@url0.info/system/userManager/user/admin.changePassword.html

How to create your own repository.xml for bundles.

0. download bindex.jar from http://www.osgi.org/Repository/BIndex to orb/
1. put all your bundles to bundles/ (where you want to release for download, such as http://xxx.xxx.xxx/orb/bundles/).
2. cd to orb/ and type java -jar bindex.jar bundles/*.jar
3. repostory.xml will be generated under the same directory (where is orb).

Now you can add this repository location to sling service using web console-> OSGi Repository.

2011年3月15日 星期二

Using Scala with Sling

https://cwiki.apache.org/SLING/using-scala-with-sling.html

it works fine after a couple days of struggling.
The reason It not working based on above URL steps.
1. You have to install all bundles (about 4) and demos (2 bundles, forum and helloworld) with (1 dependent bundle) before run the demo.

2. If you forum is not working. Read this: The form application is the available at http://localhost:8888/content/forum.html?sling:authRequestLogin=true. When prompted for credentials use admin/admin (you have to login as "admin", "admin" first for posting.

2011年3月14日 星期一

change http port sling with -p option.

refer to http://sling.apache.org/site/the-sling-launchpad.html

"java -jar target/org.apache.sling.launchpad-7-SNAPSHOT-standalone.jar -p 80"