On Fri, Jul 8, 2011 at 7:31 AM, Julian Sedding <jsedd...@gmail.com> wrote: > Hi Phil > > Typically when working with Sling you don't access it via HTTP a lot.
How do you figure? Seem to me that Sling applications are almost always accessed via HTTP. Justin > Rather you work "within" Sling. I.e. you write scripts that run within > an authenticated request (which typically originates from a browser). > I believe that getting "inside" Sling can be a little tricky at the > beginning and that's where CRX with its tooling can certainly help. > > Assuming you know roughly what Jackrabbit/JCR is, the first steps I > recommend are: > * understand resource resolution[0]: how does Sling map URL paths to > Sling resources > * understand script resolution[1]: in Sling you address content, the > content knows where to find its rendering script(s) via the > sling:resourceType property > * once you understand these two concepts, you can look at the > FileSystem Provider[2], which allows you to map a filesystem path into > Sling's resource tree. This can be helpful for editing rendering > scripts outside the repository, which is easier without more > sophisticated tooling. > > Hope that helps more than it confuses ;) > > Regards > Julian > > > [0] http://sling.apache.org/site/url-decomposition.html > [1] http://dev.day.com/content/ddc/blog/2008/07/cheatsheet.html > [2] http://sling.apache.org/site/downloads.cgi -> download FileSystem > Provider bundle and install in /system/console/bundles > > > > > On Fri, Jul 8, 2011 at 1:09 PM, sam lee <skyn...@gmail.com> wrote: >> Out of curiosity, why are you using Java and access Sling through HTTP? >> >> If you really like Java, you can create an OSGi bundle and deploy the bundle >> to Sling (felix, /system/console). >> >> You can put Servlets and other useful utilities in the bundle. >> And, you can access the repository directly without going through HTTP, but >> through JCR or Sling API. >> >> >> >> >> On Fri, Jul 8, 2011 at 6:43 AM, Phil Rice >> <phil.rice.erud...@googlemail.com>wrote: >> >>> Thanks for the help Alex. Unfortunately that is one of the things that has >>> changed in the new API. Its no longer a method available from the >>> parameters. However the advice to follow the test framework was very good >>> and the following now works. I can rip this apart and reduce to to the >>> minimum working, which I will post for the benefit of anyone else trying to >>> do this. >>> >>> DefaultHttpClient httpClient = new DefaultHttpClient(); >>> RequestExecutor executor = new RequestExecutor(httpClient); >>> >>> String nodeName = "slingNode1"; >>> >>> List<NameValuePair> formParams = Arrays.<NameValuePair> asList(new >>> BasicNameValuePair("param1", "value1"), new BasicNameValuePair("param2", >>> "value2")); >>> UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formParams, >>> "UTF-8"); >>> >>> System.out.println(executor.execute(requestBuilder.buildPostRequest(nodeName).withEntity(entity).withCredentials("admin", >>> "admin")).getContent()); >>> System.out.println(executor.execute(requestBuilder.buildGetRequest(nodeName >>> + ".json")).getContent()); >>> >>> Once again thanks for all the help, and I look forward to seeing some of >>> you >>> in September at Berlin. >>> >>> Phil >>> >>> On Fri, Jul 8, 2011 at 10:19 AM, Alexander Klimetschek >>> <aklim...@adobe.com>wrote: >>> >>> > On 08.07.11 10:39, "Phil Rice" <phil.rice.erud...@googlemail.com> wrote: >>> > >DefaultHttpClient client = new DefaultHttpClient(); >>> > >client.getCredentialsProvider().setCredentials(new >>> AuthScope("localhost", >>> > >8080), new UsernamePasswordCredentials("admin", "admin")); >>> > >>> > I guess you need to use preemptive auth: >>> > >>> > client.getParams().setAuthenticationPreemptive(true); >>> > >>> > http://hc.apache.org/httpclient-3.x/authentication.html >>> > >>> > >>> > Regards, >>> > Alex >>> > >>> > -- >>> > Alexander Klimetschek >>> > Developer // Adobe (Day) // Berlin - Basel >>> > >>> > >>> > >>> > >>> > >>> >> >