Package org.apache.sling.jcr.contentloader

# Interface ContentCreator

@ProviderType public interface ContentCreator
The `ContentCreator` is used by the `ContentReader` to create the actual content.

Since:
  2.0.4

## Method Summary

Modifier and Type
Method
Description
`void`
`createAce(String principal, String[] grantedPrivileges, String[] deniedPrivileges, String order)`
Creates an Access Control Entry for the current node for the specified principal and privileges.
`default void`
`createAce(String principal, String[] grantedPrivileges, String[] deniedPrivileges, String order, Map<String,javax.jcr.Value> restrictions, Map<String,javax.jcr.Value[]> mvRestrictions, Set<String> removedRestrictionNames)`
Deprecated.
use `createAce(String, Collection, String)` instead
`default void`
`createAce(String principal, Collection<LocalPrivilege> privileges, String order)`
Creates an Access Control Entry for the current node for the specified principal and privileges.
`void`
`createFileAndResourceNode(String name, InputStream data, String mimeType, long lastModified)`
Create a file and a resource node.
`void`
`createGroup(String name, String[] members, Map<String,Object> extraProperties)`
Create a Group in the jackrabbit UserManager
`void`
`createNode(String name, String primaryNodeType, String[] mixinNodeTypes)`
Create a new node.
`void`
`createProperty(String name, int propertyType, String value)`
Create a new property to the current node.
`void`
`createProperty(String name, int propertyType, String[] values)`
Create a new multi value property to the current node.
`void`
`createProperty(String name, Object value)`
Add a new property to the current node.
`void`
`createProperty(String name, Object[] values)`
Add a new multi value property to the current node.
`void`
`createUser(String name, String password, Map<String,Object> extraProperties)`
Create a User in the jackrabbit UserManager
`void`
`finish()`
Indicates that the import is finished
`void`
`finishNode()`
Indicates that a node is finished.
`default javax.jcr.Node`
`getParent()`
Gets the current parent Node
`boolean`
`switchCurrentNode(String subPath, String newNodeType)`
Switch the current node to the path (which must be relative to the current node).

## Method Details

### createNode

void createNode(String name, String primaryNodeType, String[] mixinNodeTypes) throws javax.jcr.RepositoryException
Create a new node. To add properties to this node, one of the createProperty() methods should be called. To add child nodes, this method should be called to create a new child node. If all properties and child nodes have been added `finishNode()` must be called.

Parameters:
  `name` - The name of the node.
  `primaryNodeType` - The primary node type or null.
  `mixinNodeTypes` - The mixin node types or null.
Throws:
  `javax.jcr.RepositoryException` - If anything goes wrong.

### finishNode

void finishNode() throws javax.jcr.RepositoryException
Indicates that a node is finished. The parent node of the current node becomes the current node.

Throws:
  `javax.jcr.RepositoryException` - If anything goes wrong.

### finish

void finish() throws javax.jcr.RepositoryException
Indicates that the import is finished

Throws:
  `javax.jcr.RepositoryException` - If anything goes wrong.

### createProperty

void createProperty(String name, int propertyType, String value) throws javax.jcr.RepositoryException
Create a new property to the current node.

Parameters:
  `name` - The property name.
  `propertyType` - The type of the property.
  `value` - The string value.
Throws:
  `javax.jcr.RepositoryException` - If anything goes wrong.

### createProperty

void createProperty(String name, int propertyType, String[] values) throws javax.jcr.RepositoryException
Create a new multi value property to the current node.

Parameters:
  `name` - The property name.
  `propertyType` - The type of the property.
  `values` - The string values.
Throws:
  `javax.jcr.RepositoryException` - If anything goes wrong.

### createProperty

void createProperty(String name, Object value) throws javax.jcr.RepositoryException
Add a new property to the current node.

Parameters:
  `name` - The property name.
  `value` - The value.
Throws:
  `javax.jcr.RepositoryException` - If anything goes wrong.

### createProperty

void createProperty(String name, Object[] values) throws javax.jcr.RepositoryException
Add a new multi value property to the current node.

Parameters:
  `name` - The property name.
  `values` - The values.
Throws:
  `javax.jcr.RepositoryException` - If anything goes wrong.

### createFileAndResourceNode

void createFileAndResourceNode(String name, InputStream data, String mimeType, long lastModified) throws javax.jcr.RepositoryException
Create a file and a resource node. After the nodes have been created, the current node is the resource node. So this method call should be followed by two calls to `finishNode()` to be on the same level as before the file creation.

Parameters:
  `name` - The name of the file node
  `data` - The data of the file
  `mimeType` - The mime type or null
  `lastModified` - The last modified or -1
Throws:
  `javax.jcr.RepositoryException` - If anything goes wrong.

### switchCurrentNode

boolean switchCurrentNode(String subPath, String newNodeType) throws javax.jcr.RepositoryException
Switch the current node to the path (which must be relative to the current node). If the path does not exist and a node type is supplied, the nodes are created with the given node type. If the path does not exist and node type is null, false is returned. When the changes to the node are finished, `finishNode()` must be called.

Parameters:
  `subPath` - The relative path
  `newNodeType` - Node type for newly created nodes.
Throws:
  `javax.jcr.RepositoryException` - If anything goes wrong.

### createUser

void createUser(String name, String password, Map<String,Object> extraProperties) throws javax.jcr.RepositoryException
Create a User in the jackrabbit UserManager

Parameters:
  `name` - the name of the user
  `password` - the password of the user
  `extraProperties` - extra properties to assign to the created user
Throws:
  `javax.jcr.RepositoryException` - If anything goes wrong.

### createGroup

void createGroup(String name, String[] members, Map<String,Object> extraProperties) throws javax.jcr.RepositoryException
Create a Group in the jackrabbit UserManager

Parameters:
  `name` - the name of the group
  `members` - the members of the group (principal names)
  `extraProperties` - extra properties to assign to the created group
Throws:
  `javax.jcr.RepositoryException`

### createAce

void createAce(String principal, String[] grantedPrivileges, String[] deniedPrivileges, String order) throws javax.jcr.RepositoryException
Creates an Access Control Entry for the current node for the specified principal and privileges.

Parameters:
  `principal` - the user or group id for the ACE
  `grantedPrivileges` - the set of privileges to grant the principal
  `deniedPrivileges` - the set of privileges to deny the principal (for users only)
  `order` - specifies the position of the ACE in the containing ACL. (may be null) Value should be one of these:

  Values
  first | Place the target ACE as the first amongst its siblings
  last | Place the target ACE as the last amongst its siblings
  before xyz | Place the target ACE immediately before the sibling whose name is xyz
  after xyz | Place the target ACE immediately after the sibling whose name is xyz
  numeric | Place the target ACE at the specified index

Throws:
  `javax.jcr.RepositoryException` - If anything goes wrong.

### createAce

@Deprecated default void createAce(String principal, String[] grantedPrivileges, String[] deniedPrivileges, String order, Map<String,javax.jcr.Value> restrictions, Map<String,javax.jcr.Value[]> mvRestrictions, Set<String> removedRestrictionNames) throws javax.jcr.RepositoryException
Deprecated.
use `createAce(String, Collection, String)` instead
Creates an Access Control Entry for the current node for the specified principal and privileges.

Parameters:
  `principal` - the user or group id for the ACE
  `grantedPrivileges` - the set of privileges to grant the principal
  `deniedPrivileges` - the set of privileges to deny the principal (for users only)
  `order` - specifies the position of the ACE in the containing ACL. (may be null) Value should be one of these:

  Values
  first | Place the target ACE as the first amongst its siblings
  last | Place the target ACE as the last amongst its siblings
  before xyz | Place the target ACE immediately before the sibling whose name is xyz
  after xyz | Place the target ACE immediately after the sibling whose name is xyz
  numeric | Place the target ACE at the specified index

  `restrictions` - specifies additional Map of single-value restrictions to apply. (optional)
  `mvRestrictions` - specifies additional Map of multi-value restrictions to apply. (optional)
  `removedRestrictionNames` - optional set of restriction names that should be removed (if they already exist).
Throws:
  `javax.jcr.RepositoryException` - If anything goes wrong.

### createAce

default void createAce(String principal, Collection<LocalPrivilege> privileges, String order) throws javax.jcr.RepositoryException
Creates an Access Control Entry for the current node for the specified principal and privileges.

Parameters:
  `principal` - the user or group id for the ACE
  `privileges` - the set of privileges to allow or deny for the principal
  `order` - specifies the position of the ACE in the containing ACL. (may be null) Value should be one of these:

  Values
  first | Place the target ACE as the first amongst its siblings
  last | Place the target ACE as the last amongst its siblings
  before xyz | Place the target ACE immediately before the sibling whose name is xyz
  after xyz | Place the target ACE immediately after the sibling whose name is xyz
  numeric | Place the target ACE at the specified index

Throws:
  `javax.jcr.RepositoryException` - If anything goes wrong.

### getParent

default javax.jcr.Node getParent()
Gets the current parent Node

Returns:
  the current parent node or null