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


Reply via email to