I am testing Java scripts that will post content to Sling using the Apache Http Client 4.1 library.
When I run the test, I see the node in the JCR exporer (http://localhost:8080/.explorer.html) but I do not see any of the properties. When I get the node by http://localhost:8080/demo/path/demo01.json I see all of the properties. Am I doing something wrong in my post or is there a bug in the explorer? Here is my test. import java.util.ArrayList; import java.util.List; import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.auth.params.AuthPNames; import org.apache.http.client.AuthCache; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.params.AuthPolicy; import org.apache.http.client.protocol.ClientContext; import org.apache.http.entity.mime.FormBodyPart; import org.apache.http.entity.mime.MultipartEntity; import org.apache.http.entity.mime.content.StringBody; import org.apache.http.impl.auth.BasicScheme; import org.apache.http.impl.client.BasicAuthCache; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.protocol.BasicHttpContext; import org.apache.http.util.EntityUtils; import org.junit.Test; /** * Test Apache Http Client API 4.1 against Apache Sling. * * @author Ricker * */ public class TestLoader { @Test public void post() throws Exception { /* * create client */ HttpHost targetHost = new HttpHost("localhost", 8080, "http"); DefaultHttpClient httpclient = new DefaultHttpClient(); /* * authenticate */ List<String> authpref = new ArrayList<String>(); authpref.add(AuthPolicy.BASIC); httpclient.getParams().setParameter(AuthPNames.PROXY_AUTH_PREF, authpref); httpclient.getCredentialsProvider().setCredentials( new AuthScope(targetHost.getHostName(), targetHost.getPort()), new UsernamePasswordCredentials("admin", "admin")); /* * cache authentication */ AuthCache authCache = new BasicAuthCache(); BasicScheme basicAuth = new BasicScheme(); authCache.put(targetHost, basicAuth); BasicHttpContext localcontext = new BasicHttpContext(); localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache); /* * Create post message */ MultipartEntity entity = new MultipartEntity(); entity.addPart(new FormBodyPart("jcr:primaryType",new StringBody("nt:unstructured"))); entity.addPart(new FormBodyPart("jcr:created", new StringBody(""))); entity.addPart(new FormBodyPart("sling:resourceType", new StringBody("ricker/demo"))); entity.addPart(new FormBodyPart(":name", new StringBody("demo05"))); entity.addPart(new FormBodyPart("title", new StringBody("This is a demonstration of the posting"))); entity.addPart(new FormBodyPart("body", new StringBody("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "))); entity.addPart(new FormBodyPart("number", new StringBody("1.203"))); entity.addPart(new FormBodyPart("number@TypeHint", new StringBody("Double"))); /* * post */ HttpPost post = new HttpPost("/demo/path/"); post.setEntity(entity); HttpResponse response = httpclient.execute(targetHost, post, localcontext); EntityUtils.consume(response.getEntity()); /* * confirm post */ } } -- View this message in context: http://apache-sling.73963.n3.nabble.com/Sling-JCR-explorer-not-showing-posted-content-tp3006268p3006268.html Sent from the Sling - Users mailing list archive at Nabble.com.
