public class ResourceBuilderImpl extends Object implements ResourceBuilder
| Modifier and Type | Field and Description |
|---|---|
static String |
CANNOT_RESTART |
static String |
JCR_CONTENT |
static String |
JCR_DATA |
static String |
JCR_LASTMODIFIED |
static String |
JCR_MIMETYPE |
static String |
JCR_PRIMARYTYPE |
static String |
NT_FILE |
static String |
NT_RESOURCE |
DEFAULT_PRIMARY_TYPE| Constructor and Description |
|---|
ResourceBuilderImpl(org.apache.sling.api.resource.Resource parent,
org.apache.sling.commons.mime.MimeTypeService mts) |
| Modifier and Type | Method and Description |
|---|---|
ResourceBuilder |
atParent()
Reset the current parent Resource to the original one.
|
ResourceBuilder |
commit()
Commit created resources
|
protected org.apache.sling.api.resource.Resource |
ensureResourceExists(String path)
Create a Resource at the specified path if none exists yet,
using the current intermediate primary type.
|
ResourceBuilder |
file(String filename,
InputStream data)
Create a file under the current parent resource.
|
ResourceBuilder |
file(String relativePath,
InputStream data,
String mimeType,
long lastModified)
Create a file under the current parent resource
|
org.apache.sling.api.resource.Resource |
getCurrentParent()
Return the current parent resource
|
protected long |
getLastModified(long userSuppliedValue) |
protected String |
getMimeType(String filename,
String userSuppliedMimeType) |
ResourceBuilder |
hierarchyMode()
Set hierarchy mode (as opposed to siblings mode) where creating a resource
sets it as the current parent.
|
ResourceBuilder |
resource(String path,
Map<String,Object> properties)
Create a Resource, which optionally becomes the current
parent Resource.
|
ResourceBuilder |
resource(String path,
Object... properties)
Create a Resource, which optionally becomes the current
parent Resource.
|
ResourceBuilder |
siblingsMode()
Set siblings mode (as opposed to hierarchy mode) where creating a resource
doesn't change the current parent.
|
ResourceBuilder |
withIntermediatePrimaryType(String primaryType)
Set the primary type for intermediate resources created
when the parent of resource being created does not exist.
|
public static final String JCR_PRIMARYTYPE
public static final String JCR_MIMETYPE
public static final String JCR_LASTMODIFIED
public static final String JCR_DATA
public static final String JCR_CONTENT
public static final String NT_RESOURCE
public static final String NT_FILE
public static final String CANNOT_RESTART
public ResourceBuilderImpl(org.apache.sling.api.resource.Resource parent,
org.apache.sling.commons.mime.MimeTypeService mts)
public org.apache.sling.api.resource.Resource getCurrentParent()
ResourceBuildergetCurrentParent in interface ResourceBuilderpublic ResourceBuilder atParent()
ResourceBuilderatParent in interface ResourceBuilderpublic ResourceBuilder resource(String path, Map<String,Object> properties)
ResourceBuilderresource in interface ResourceBuilderpath - The path of the Resource to create.
If it's a relative path this builder's current resource is used as parent.
Otherwise the resource is created ad the given absoulte path.properties - Name-value pairspublic ResourceBuilder resource(String path, Object... properties)
ResourceBuilderresource in interface ResourceBuilderpath - The path of the Resource to create.
If it's a relative path this builder's current resource is used as parent.
Otherwise the resource is created ad the given absoulte path.properties - optional name-value pairsprotected final org.apache.sling.api.resource.Resource ensureResourceExists(String path)
path - Resource pathprotected long getLastModified(long userSuppliedValue)
public ResourceBuilder file(String relativePath, InputStream data, String mimeType, long lastModified)
ResourceBuilderfile in interface ResourceBuilderrelativePath - The name of the created filedata - The file datamimeType - If null, use the Sling MimeTypeService to set the mime typelastModified - if < 0, current time is usedpublic ResourceBuilder file(String filename, InputStream data)
ResourceBuilderfile in interface ResourceBuilderfilename - The name of the created filedata - The file datapublic ResourceBuilder withIntermediatePrimaryType(String primaryType)
ResourceBuilderwithIntermediatePrimaryType in interface ResourceBuilderprimaryType - If null the DEFAULT_PRIMARY_TYPE is used.public ResourceBuilder siblingsMode()
ResourceBuildersiblingsMode in interface ResourceBuilderpublic ResourceBuilder hierarchyMode()
ResourceBuilderhierarchyMode in interface ResourceBuilderpublic ResourceBuilder commit()
ResourceBuildercommit in interface ResourceBuilderCopyright © 2007–2016 The Apache Software Foundation. All rights reserved.