Have you had a look at this: http://sling.apache.org/site/discover-sling-in-15-minutes.html
Might give you some ideas. I believe if you just want to create a folder, you can just POST to the url with the folder name at the end (shouldn't require that multipartentity). Try it out with curl first. Just curious, are you writing a standalone java app that communicates with sling via HTTP? Sarwar On Tue, May 8, 2012 at 6:54 PM, Günther Schmidt <[email protected]> wrote: > Hello, > > I'm trying to create a directory using Apaches HTTP components HTTPClient. > > I've tried for a couple of days now to figure out how authentication is > meant to be used but keep getting Access Denied Errors. > > Here's my code: > > package de.kmmd.jcr; > > import org.apache.http.auth.**AuthScope; > import org.apache.http.auth.**UsernamePasswordCredentials; > import org.apache.http.client.**methods.HttpPost; > import org.apache.http.entity.mime.**HttpMultipartMode; > import org.apache.http.entity.mime.**MultipartEntity; > import org.apache.http.entity.mime.**content.StringBody; > import org.apache.http.impl.client.**BasicResponseHandler; > import org.apache.http.impl.client.**DefaultHttpClient; > > public class ClientTest { > > > public static void main(String[] args) { > > DefaultHttpClient httpClient = new DefaultHttpClient(); > HttpPost httpPost = new > HttpPost("http://localhost:**8080/testDir<http://localhost:8080/testDir> > "); > MultipartEntity mp = new MultipartEntity(** > HttpMultipartMode.BROWSER_**COMPATIBLE); > > httpClient.**getCredentialsProvider().**setCredentials( > AuthScope.ANY, > new UsernamePasswordCredentials("**admin", "admin")); > > try { > mp.addPart("jcr:primaryType", new StringBody("nt:folder")); > httpPost.setEntity(mp); > httpClient.execute(httpPost, new BasicResponseHandler()); > } catch (Exception e) { > e.printStackTrace(); > } > } > > } > > The apache sling's code base is so complex that I was unable so far to > figure out how to use the test cases. In some of the test scenarios > DefaultHttpClient with authentication is also used but I'm unable to follow > the code so that I could use it as a guide. > > Günther >
