|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.sling.jcr.contentloader.internal.readers.JsonReader
public class JsonReader
The JsonReader Parses a Json document on content load and creates the
corresponding node structure with properties. Will not update protected nodes and
properties like rep:Policy and children.
Nodes, Properties and in fact complete subtrees may be described in JSON files
using the following skeleton structure (see http://www.json.org for information
on the syntax of JSON) :
# the name of the node is taken from the name of the file without the .json ext.
{
# optional primary node type, default "nt:unstructured"
"jcr:primaryType":"sling:ScriptedComponent",
# optional mixin node types as array
"jcr:mixinTypes": [ ],
# "properties" are added as key value pairs, the name of the key being the name
# of the property. The value is either the string property value, array for
# multi-values or an object whose value[s] property denotes the property
# value(s) and whose type property denotes the property type
"sling:contentClass": "com.day.sling.jcr.test.Test",
"sampleMulti": [ "v1", "v2" ],
"sampleStruct": 1,
"sampleStructMulti": [ 1, 2, 3 ],
# reference properties start with jcr:reference
"jcr:reference:sampleReference": "/test/content",
# path propertie start with jcr:path
"jcr:path:sampleReference": "/test/path",
# nested nodes are added as nested maps.
"sling:scripts": {
"jcr:primaryType": "sling:ScriptList",
"script1" :{
"primaryNodeType": "sling:Script",
"sling:name": "/test/content/jsp/start.jsp",
"sling:type": "jsp",
"sling:glob": "*"
}
}
}
| Field Summary | |
|---|---|
static ImportProvider |
PROVIDER
|
| Constructor Summary | |
|---|---|
JsonReader()
|
|
| Method Summary | |
|---|---|
protected void |
createAce(org.apache.sling.commons.json.JSONObject ace,
ContentCreator contentCreator)
Create or update an access control entry |
protected void |
createAcl(java.lang.Object obj,
ContentCreator contentCreator)
Create or update one or more access control entries for the current node. |
protected void |
createNode(java.lang.String name,
org.apache.sling.commons.json.JSONObject obj,
ContentCreator contentCreator)
|
protected void |
createPrincipal(org.apache.sling.commons.json.JSONObject json,
ContentCreator contentCreator)
Create or update a user or group |
protected void |
createPrincipals(java.lang.Object obj,
ContentCreator contentCreator)
Create or update one or more user and/or groups
{
"security:principals" : [
{
"name":"owner",
"isgroup":"true",
"members":[],
"dynamic":"true"
}
],
}
|
protected void |
createProperty(java.lang.String name,
java.lang.Object value,
ContentCreator contentCreator)
|
protected java.lang.String |
getName(java.lang.String name)
|
protected int |
getType(java.lang.String name,
java.lang.Object object)
|
void |
parse(java.io.InputStream ins,
ContentCreator contentCreator)
Read the content from the input stream and create the content using the provided content creator. |
void |
parse(java.net.URL url,
ContentCreator contentCreator)
Read the content from the URL and create the content using the provided content creator. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final ImportProvider PROVIDER
| Constructor Detail |
|---|
public JsonReader()
| Method Detail |
|---|
public void parse(java.net.URL url,
ContentCreator contentCreator)
throws java.io.IOException,
javax.jcr.RepositoryException
ContentReader
parse in interface ContentReaderurl - The input stream.
java.io.IOException
javax.jcr.RepositoryExceptionContentReader.parse(java.net.URL, org.apache.sling.jcr.contentloader.internal.ContentCreator)
public void parse(java.io.InputStream ins,
ContentCreator contentCreator)
throws java.io.IOException,
javax.jcr.RepositoryException
ContentReader
parse in interface ContentReaderins - the input stream.
java.io.IOException
javax.jcr.RepositoryException
protected void createNode(java.lang.String name,
org.apache.sling.commons.json.JSONObject obj,
ContentCreator contentCreator)
throws org.apache.sling.commons.json.JSONException,
javax.jcr.RepositoryException
org.apache.sling.commons.json.JSONException
javax.jcr.RepositoryException
protected void createProperty(java.lang.String name,
java.lang.Object value,
ContentCreator contentCreator)
throws org.apache.sling.commons.json.JSONException,
javax.jcr.RepositoryException
org.apache.sling.commons.json.JSONException
javax.jcr.RepositoryException
protected int getType(java.lang.String name,
java.lang.Object object)
protected java.lang.String getName(java.lang.String name)
protected void createPrincipals(java.lang.Object obj,
ContentCreator contentCreator)
throws org.apache.sling.commons.json.JSONException,
javax.jcr.RepositoryException
{
"security:principals" : [
{
"name":"owner",
"isgroup":"true",
"members":[],
"dynamic":"true"
}
],
}
org.apache.sling.commons.json.JSONException
javax.jcr.RepositoryException
protected void createPrincipal(org.apache.sling.commons.json.JSONObject json,
ContentCreator contentCreator)
throws org.apache.sling.commons.json.JSONException,
javax.jcr.RepositoryException
org.apache.sling.commons.json.JSONException
javax.jcr.RepositoryException
protected void createAcl(java.lang.Object obj,
ContentCreator contentCreator)
throws org.apache.sling.commons.json.JSONException,
javax.jcr.RepositoryException
{
"security:acl" : [
{
"principal" : "username1",
"granted" : [
"jcr:read",
"jcr:write"
],
"denied" : [
]
},
{
"principal" : "groupname1",
"granted" : [
"jcr:read",
"jcr:write"
]
}
]
}
org.apache.sling.commons.json.JSONException
javax.jcr.RepositoryException
protected void createAce(org.apache.sling.commons.json.JSONObject ace,
ContentCreator contentCreator)
throws org.apache.sling.commons.json.JSONException,
javax.jcr.RepositoryException
org.apache.sling.commons.json.JSONException
javax.jcr.RepositoryException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||