Class ModifyOperation
java.lang.Object
org.apache.sling.servlets.post.impl.operations.AbstractPostOperation
org.apache.sling.servlets.post.impl.operations.ModifyOperation
- All Implemented Interfaces:
PostOperation
The
ModifyOperation
class implements the default operation
called by the Sling default POST servlet if no operation is requested by the
client. This operation is able to create and/or modify content.-
Field Summary
Fields inherited from class org.apache.sling.servlets.post.impl.operations.AbstractPostOperation
jcrSupport, log
Fields inherited from interface org.apache.sling.servlets.post.PostOperation
PROP_OPERATION_NAME, SERVICE_NAME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Map<String,
RequestProperty> collectContent
(SlingHttpServletRequest request, PostResponse response) Collects the properties that form the content to be written back to the resource tree.protected Resource
deepGetOrCreateResource
(ResourceResolver resolver, String path, Map<String, RequestProperty> reqProperties, List<Modification> changes, VersioningConfiguration versioningConfiguration) Deep gets or creates a resource, parent-padding with default resources.protected void
doRun
(SlingHttpServletRequest request, PostResponse response, List<Modification> changes) Actually performs the desired operation filling progress into thechanges
list and preparing and further information in theresponse
.protected String
generateName
(SlingHttpServletRequest request, String basePath) protected String
getResourcePath
(SlingHttpServletRequest request) Returns the path of the resource of the request as the resource path.protected void
processCreate
(ResourceResolver resolver, Map<String, RequestProperty> reqProperties, PostResponse response, List<Modification> changes, VersioningConfiguration versioningConfiguration) Create resource(s) according to current requestvoid
setDateParser
(DateParser dateParser) void
setDefaultNodeNameGenerator
(NodeNameGenerator defaultNodeNameGenerator) void
setExtraNodeNameGenerators
(NodeNameGenerator[] extraNodeNameGenerators) void
setIgnoredParameterNamePattern
(Pattern ignoredParameterNamePattern) void
setServletContext
(javax.servlet.ServletContext servletContext) protected void
updateMixins
(ResourceResolver resolver, String path, Map<String, RequestProperty> reqProperties, List<Modification> changes, VersioningConfiguration versioningConfiguration) protected void
updateNodeType
(ResourceResolver resolver, String path, Map<String, RequestProperty> reqProperties, List<Modification> changes, VersioningConfiguration versioningConfiguration) Methods inherited from class org.apache.sling.servlets.post.impl.operations.AbstractPostOperation
externalizePath, getApplyToResources, getVersioningConfiguration, isSkipCheckin, orderResource, run
-
Constructor Details
-
ModifyOperation
public ModifyOperation()
-
-
Method Details
-
setServletContext
public void setServletContext(javax.servlet.ServletContext servletContext) -
setDateParser
-
doRun
protected void doRun(SlingHttpServletRequest request, PostResponse response, List<Modification> changes) throws PersistenceException Description copied from class:AbstractPostOperation
Actually performs the desired operation filling progress into thechanges
list and preparing and further information in theresponse
.The
response
comes prepared with the path, location and parent location set. Other properties are expected to be set by this implementation.- Specified by:
doRun
in classAbstractPostOperation
- Parameters:
request
- TheSlingHttpServletRequest
providing the input, mostly in terms of request parameters, to the operation.response
- ThePostResponse
to fill with response informationchanges
- A container to addModification
instances representing the operations done.- Throws:
PersistenceException
- Maybe thrown if any error occurs while accessing the repository.
-
getResourcePath
Description copied from class:AbstractPostOperation
Returns the path of the resource of the request as the resource path.This method may be overwritten by extension if the operation has different requirements on path processing.
- Overrides:
getResourcePath
in classAbstractPostOperation
- Parameters:
request
- The http request- Returns:
- The resource path
-
setDefaultNodeNameGenerator
-
setExtraNodeNameGenerators
-
setIgnoredParameterNamePattern
-
processCreate
protected void processCreate(ResourceResolver resolver, Map<String, RequestProperty> reqProperties, PostResponse response, List<Modification> changes, VersioningConfiguration versioningConfiguration) throws PersistenceExceptionCreate resource(s) according to current request- Parameters:
resolver
- the resourceResolver to usereqProperties
- required propertiesresponse
- the responsechanges
- the changes to applyversioningConfiguration
- versioning configuration- Throws:
PersistenceException
- if a resource error occurs
-
updateNodeType
protected void updateNodeType(ResourceResolver resolver, String path, Map<String, RequestProperty> reqProperties, List<Modification> changes, VersioningConfiguration versioningConfiguration) throws PersistenceException- Throws:
PersistenceException
-
updateMixins
protected void updateMixins(ResourceResolver resolver, String path, Map<String, RequestProperty> reqProperties, List<Modification> changes, VersioningConfiguration versioningConfiguration) throws PersistenceException- Throws:
PersistenceException
-
collectContent
protected Map<String,RequestProperty> collectContent(SlingHttpServletRequest request, PostResponse response) Collects the properties that form the content to be written back to the resource tree.- Parameters:
request
- the requestresponse
- the response- Returns:
- the collected properties
-
deepGetOrCreateResource
protected Resource deepGetOrCreateResource(ResourceResolver resolver, String path, Map<String, RequestProperty> reqProperties, List<Modification> changes, VersioningConfiguration versioningConfiguration) throws PersistenceExceptionDeep gets or creates a resource, parent-padding with default resources. If the path is empty, the given parent resource is returned.- Parameters:
resolver
- the resource resolver to usepath
- path to resources that needs to be deep-createdreqProperties
- the properties to addchanges
- the changes to applyversioningConfiguration
- the versioning configuration- Returns:
- Resource at path
- Throws:
PersistenceException
- if an error occursIllegalArgumentException
- if the path is relative and parent isnull
-
generateName
protected String generateName(SlingHttpServletRequest request, String basePath) throws PersistenceException - Throws:
PersistenceException
-