You can use /system/sling.js It has Sling.removeContent() and Sling.getContent(). You just need to implement Sling.createContent(), Sling.updateContent(), Sling.query() using xhr.
Then you have something like couchdb. I don't think sling has RESTful API reference. It would be useful. On Thu, Jul 7, 2011 at 8:57 AM, Eric Norman <eric.d.nor...@gmail.com> wrote: > Hi Phil, > > It looks like your form inputs are missing the name attribute. Try > something like this: > > <html> > <head><title>Testing</title></head> > <body> > <form action="http://localhost:8080/newNode1" method="post"> > <label for="name1">Name1</label> <input type="text" id="name1" * > name="name1"* > value="Value1" /><br /> > <label for="name2">Name3</label> <input type="text" id="name2" * > name="name2"* > value="Value2" /><br /> > <label for="name3">Name4</label> <input type="text" id="name3" * > name="name3"* > value="Value3" /><br /> > <label for="name4">Name5</label> <input type="text" id="name4" * > name="name4"* > value="Value4" /><br /> > <button>Submit</button> > </form> > </body> > </html> > > > Also, take a look at the documentation of the sling post servlet bundle @ > > http://sling.apache.org/site/manipulating-content-the-slingpostservlet-servletspost.html > for > some examples of content manipulation. > > Regards, > Eric > > > On Thu, Jul 7, 2011 at 12:56 AM, Phil Rice < > phil.rice.erud...@googlemail.com > > wrote: > > > Thanks for the swift reply > > > > - I'll raise a bug about "Sling in 15 minutes" as soon as I can make a > > unit test to capture it. > > - I'm hoping someone can point me to a tutorial or reference materials > > for ESP. Playing with javascript through reflection is hard work! > > - Thanks for the idea of running Sling in the same OSGI container. I > > suspect that won't work for crowd sourcing (you want one central > > repository), but I think it would be an excellent way to learn how > > everything ties together > > - I was puzzled that PUT was the wrong method. As I understand it PUT > is > > the mechanism to "create or replace" in REST. However I replaced the > call > > to > > a post, and I just get internal server error 500s with nothing > appearing > > in > > the logs. I will chase that down when I have sorted out the next point: > > - Assuming that there is a problem in my understanding in what is going > > on, I reduced to the simplest thing that could wrong and produced the > > following HTML page > > > > <html> > > <head><title>Testing</title></head> > > <body> > > <form action="http://localhost:8080/newNode1" method="post"> > > <label for="name1">Name1</label> <input type="text" id="name1" > > value="Value1" /><br /> > > <label for="name2">Name3</label> <input type="text" id="name2" > > value="Value2" /><br /> > > <label for="name3">Name4</label> <input type="text" id="name3" > > value="Value3" /><br /> > > <label for="name4">Name5</label> <input type="text" id="name4" > > value="Value4" /><br /> > > <button>Submit</button> > > </form> > > </body> > > </html> > > My hope is that when I click the button this would create newNode1 with > > attributes name1 = Value1 etc. And indeed (after logging in) it created > > newNode1. However when I examine the node created using the url > > http://localhost:8080/newNode1.json I find the following page: > > > > {"jcr:primaryType":"nt:unstructured"} > > > > However if I use > > > > curl -u admin:admin -F"name1=value1" -F"name2=value2" > > http://localhost:8080/newNodeQ1 > > > > And surf to http://localhost:8080/newNodeQ1.json I find > > > > {"name2":"value2","jcr:primaryType":"nt:unstructured","name1":"value1"} > > > > I would appreciate some advice on how to get the HTML to work similar to > > curl > > > > Thanks again for the help > > --------------- > > > > My software stack is: > > > > - Windows 7 64 bit > > - JDK1.6.0_24 > > - Eclipse Indigo Release build 20110615-0604 > > - I am using jar "org.apache.sling.launchpad.base.jar", which I > > downloaded earlier this week. > > - I am running the jar using Eclipse using only defaults (no VM > > arguments, no program arguments). The main method is from > > class org.apache.sling.launchpad.app.Main > > > > The console output from sling is > > > > 07.07.2011 07:54:18.570 *INFO* [main] Setting sling.home=sling (default) > > 07.07.2011 07:54:18.572 *INFO* [main] Starting Sling in sling > > (C:\Users\Phil\workspace\Sling\sling) > > 07.07.2011 07:54:18.620 *INFO* [main] Checking launcher JAR in folder > sling > > 07.07.2011 07:54:18.640 *INFO* [main] Existing launcher is up to date, > > using > > it: 2.3.0 (org.apache.sling.launchpad.base.jar) > > 07.07.2011 07:54:18.642 *INFO* [main] Loading launcher class > > org.apache.sling.launchpad.base.app.MainDelegate from > > org.apache.sling.launchpad.base.jar > > 07.07.2011 07:54:18.662 *INFO* [main] Starting launcher ... > > 07.07.2011 07:54:18.666 *INFO* [main] HTTP server port: 8080 > > 07.07.2011 07:54:20.736 *INFO* [main] Startup completed > > > > > > > > > > On Wed, Jul 6, 2011 at 11:02 PM, Justin Edelson < > jus...@justinedelson.com > > >wrote: > > > > > > > > > > > On Jul 6, 2011, at 5:16 PM, Phil Rice < > phil.rice.erud...@googlemail.com> > > > wrote: > > > > > > > Hello everyone. > > > > > > Hi > > > > > > > > > > > I have just downloaded Sling, and am very impressed with it. I am > > > planning > > > > on using it in conjunction with an Eclipse plugin to crowd source > > > > information about open source projects. > > > > > > Sounds interesting. Are you able to reuse code between the server side > > and > > > client side as both Sling and Eclipse are OSGi based? > > > > > > > > > > > I am having the usual teething problems that I get whenever I use an > > open > > > > source product, and I am hoping to get some assistance. I have spent > > > three > > > > days getting going, so I have tried quite a few combinations. > > > > > > > > Some general information for you "getting going with sling in 15 > > minutes" > > > > was very helpful. I have a version of Sling built from the source > code > > > using > > > > Maven, and a second which is the standalone Jar. On both of them the > > > > following curl command didn't work: > > > > > > > > curl -u admin:admin -F"sling:resourceType=foo/bar" -F"title=some > > > > title" http://localhost:8080/content/mynode > > > > > > > > > > > > I had to replace it with: > > > > > > > > > > > > curl -u admin:admin -F"sling:resourceType=foo/bar" -F"title=some > > > > title" http://localhost:8080/mynode > > > > > > This should have worked. Can you file a bug report? > > > > > > > > > > > > > > > At the moment my Sling-fu is weak and I am not sure if this is some > > > > configuration problem. > > > > --------------- > > > > > > > > I am now at the point at which I feel the master of Sling (pride > comes > > > > before a fall) using Curl, so I have moved to Java. I have tried a > > number > > > of > > > > Java libraries include the Apache HttpClient, http-unit and > > Rest-assured. > > > I > > > > am now at the point at which I can get information out of Sling that > I > > > put > > > > in with Curl, but I am unable to programatically add it. Specifically > I > > > can > > > > create the node, but the attributes do not appear. Fairly obviously I > > am > > > > missing some critical configuration > > > > > > > > So I have the following questions: > > > > > > > > - ESP looks very nice. Where can I find information on how to use > it. > > I > > > > have found some samples using it, but have not been very successful > > in > > > > finding tutorials / reference material. > > > > - What is the Java side client software that you recommend for use > > with > > > > Sling, and do you have any example code? > > > > > > The majority of the Sling integration test suite is written with Apache > > > HttpClient 3.x. That's a good point if reference. > > > > > > > - Can you advise why the following code does not set param1=value1, > > > > param2=value2? > > > > > > > > > > You're doing a PUT. I'm assuming you are using the default servlets and > > the > > > functionality which accepts form parameters and sets node properties > from > > > them is in the default POST servlet. Of course, you're free to write > your > > > own servlet which accepts PUTs. > > > > > > HTH, > > > Justin > > > > > > > > import org.apache.http.*; > > > > public class PopulateRepository { > > > > public static void main(String[] args) throws Exception { > > > > BasicCredentialsProvider credentialsProvider = new > > > > BasicCredentialsProvider(); > > > > credentialsProvider.setCredentials(AuthScope.ANY, new > > > > UsernamePasswordCredentials("admin", "admin")); > > > > DefaultHttpClient client = new DefaultHttpClient(); > > > > client.setCredentialsProvider(credentialsProvider); > > > > > > > > String nodeName = "newNodeName"; > > > > List<NameValuePair> formParams = Arrays.<NameValuePair> asList(new > > > > BasicNameValuePair("param1", "value1"), new > > BasicNameValuePair("param2", > > > > "value2")); > > > > UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formParams, > > > "UTF-8"); > > > > HttpPut action = new HttpPut("http://localhost:8080/" + nodeName); > > > > HttpResponse response = client.execute(action); > > > > }} > > > > > > > > Thanks for making such an interesting product > > > > > > > > > > > >