Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

This page lists a series of common questions and answers. It is of course work in progress ...

Note
titleThis page is *not* meant for asking questions

Use the Sling users mailing lists for that, see http://sling.apache.org/project-information.html#mailing-lists - this page is about answers. Thanks!

If you find anything wrong in the Sling site or in and on the Wiki, do not hesitate to also contact the user's mailing list. Thanks.

Table of Contents
minLevel2
maxLevel3

...

Code Block
curl -F"greetings=Hello, World!" -F"multmulti=first" -F"multi=second" -F"translations/en=Hello" -F"translations/zh=你好" http://admin:admin@localhost:8080/content/../../..

...

Now you should be able to see an HTML version of the resource at http://localhost.local:8080/content/greet. This script matches the sling:resourceType we set and the HTTP method we used. Note that resourceType matches must be exact.

How

...

do I create a multi-value property with a single value, in HTTP?

Use this:

Code Block
curl -u admin:admin -F'foo=bar' -F'foo@TypeHint=String[]' http://localhost:8080/some/path

The TypeHint tells the Sling POST servlet to create a multi-value property for foo.

I cannot add a node under /content/config.author using a POST, the new node goes under /content/config

That happens if both the /content/config.author and /content/config nodes exist, and you do something like:

Code Block

$ curl -F try=first -u admin:admin http://localhost:8080/content/config.author/underauthor

The underauthor node goes under /content/config in that case, as Sling finds a resource at that path and considers .author as an extension or selector.

This is inherent to the way Sling matches URL paths to resources - to work around that, use

Code Block

$ curl -F underauthor/try=second -F "underauthor/jcr:primaryType=sling:Folder" -u admin:admin http://localhost:8080/content/config.author

Which correctly creates the underauthor node under /content/config.author. You can of course add more properties to the request, like -F underauthor/jcr:primaryType if needed.

Here's the resulting content of our example (including specifying the jcr:primaryType):

Code Block

$ curl http://localhost:8080/content.tidy.5.json
{
  "jcr:primaryType": "nt:unstructured",
  "config.author": {
    "foo": "bar",
    "jcr:primaryType": "nt:unstructured",
    "underauthor": {
      "try": "second",
      "jcr:createdBy": "admin",
      "jcr:created": "Fri Jan 25 2013 17:35:18 GMT+0100",
      "jcr:primaryType": "sling:Folder"
    }
  },
  "config": {
    "foo": "bar",
    "jcr:primaryType": "nt:unstructured",
    "underauthor": {
      "try": "first",
      "jcr:primaryType": "nt:unstructured"
    }
  }
}

Scripts and Servlets

How do I generate links to previous versions of a node?

...