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(@NotNull org.apache.sling.api.resource.Resource parent,
@NotNull org.apache.sling.commons.mime.MimeTypeService mts) |
Modifier and Type | Method and Description |
---|---|
@NotNull ResourceBuilder |
atParent()
Reset the current parent Resource to the original one.
|
@NotNull 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.
|
@NotNull ResourceBuilder |
file(@NotNull String filename,
@NotNull InputStream data)
Create a file under the current parent resource.
|
@NotNull ResourceBuilder |
file(@NotNull String relativePath,
@NotNull InputStream data,
@Nullable String mimeType,
long lastModified)
Create a file under the current parent resource
|
@NotNull org.apache.sling.api.resource.Resource |
getCurrentParent()
Return the current parent resource
|
protected long |
getLastModified(long userSuppliedValue) |
protected String |
getMimeType(String filename,
String userSuppliedMimeType) |
@NotNull ResourceBuilder |
hierarchyMode()
Set hierarchy mode (as opposed to siblings mode) where creating a resource
sets it as the current parent.
|
@NotNull ResourceBuilder |
resource(@NotNull String path,
@NotNull Map<String,Object> properties)
Create a Resource, which optionally becomes the current
parent Resource.
|
@NotNull ResourceBuilder |
resource(@NotNull String path,
Object... properties)
Create a Resource, which optionally becomes the current
parent Resource.
|
@NotNull ResourceBuilder |
siblingsMode()
Set siblings mode (as opposed to hierarchy mode) where creating a resource
doesn't change the current parent.
|
@NotNull ResourceBuilder |
withIntermediatePrimaryType(@Nullable 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(@NotNull @NotNull org.apache.sling.api.resource.Resource parent, @NotNull @NotNull org.apache.sling.commons.mime.MimeTypeService mts)
@NotNull public @NotNull org.apache.sling.api.resource.Resource getCurrentParent()
ResourceBuilder
getCurrentParent
in interface ResourceBuilder
@NotNull public @NotNull ResourceBuilder atParent()
ResourceBuilder
atParent
in interface ResourceBuilder
@NotNull public @NotNull ResourceBuilder resource(@NotNull @NotNull String path, @NotNull @NotNull Map<String,Object> properties)
ResourceBuilder
resource
in interface ResourceBuilder
path
- 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 absolute path.properties
- Name-value pairs@NotNull public @NotNull ResourceBuilder resource(@NotNull @NotNull String path, @NotNull Object... properties)
ResourceBuilder
resource
in interface ResourceBuilder
path
- 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 absolute path.properties
- optional name-value pairsprotected final org.apache.sling.api.resource.Resource ensureResourceExists(String path)
path
- Resource pathprotected long getLastModified(long userSuppliedValue)
@NotNull public @NotNull ResourceBuilder file(@NotNull @NotNull String relativePath, @NotNull @NotNull InputStream data, @Nullable @Nullable String mimeType, long lastModified)
ResourceBuilder
file
in interface ResourceBuilder
relativePath
- 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 used@NotNull public @NotNull ResourceBuilder file(@NotNull @NotNull String filename, @NotNull @NotNull InputStream data)
ResourceBuilder
file
in interface ResourceBuilder
filename
- The name of the created filedata
- The file data@NotNull public @NotNull ResourceBuilder withIntermediatePrimaryType(@Nullable @Nullable String primaryType)
ResourceBuilder
withIntermediatePrimaryType
in interface ResourceBuilder
primaryType
- If null the DEFAULT_PRIMARY_TYPE is used.@NotNull public @NotNull ResourceBuilder siblingsMode()
ResourceBuilder
siblingsMode
in interface ResourceBuilder
@NotNull public @NotNull ResourceBuilder hierarchyMode()
ResourceBuilder
hierarchyMode
in interface ResourceBuilder
@NotNull public @NotNull ResourceBuilder commit()
ResourceBuilder
commit
in interface ResourceBuilder
Copyright © 2007–2018 The Apache Software Foundation. All rights reserved.