public abstract class AbstractPostOperation extends Object implements PostOperation
AbstractPostOperation
class is a base implementation of the
PostOperation
service interface providing actual implementations with
useful tooling and common functionality like preparing the change logs or
saving or refreshing the JCR Session.Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
log
default log
|
PROP_OPERATION_NAME, SERVICE_NAME
Constructor and Description |
---|
AbstractPostOperation() |
Modifier and Type | Method and Description |
---|---|
protected void |
checkoutIfNecessary(javax.jcr.Node node,
List<Modification> changes,
VersioningConfiguration versioningConfiguration) |
protected abstract void |
doRun(SlingHttpServletRequest request,
PostResponse response,
List<Modification> changes)
Actually performs the desired operation filling progress into the
changes list and preparing and further information in the
response . |
protected String |
externalizePath(SlingHttpServletRequest request,
String path)
Returns an external form of the given path prepending the context path
and appending a display extension.
|
protected javax.jcr.Node |
findVersionableAncestor(javax.jcr.Node node) |
protected Iterator<Resource> |
getApplyToResources(SlingHttpServletRequest request)
Returns an iterator on
Resource instances addressed in the
SlingPostConstants.RP_APPLY_TO request parameter. |
protected String |
getItemPath(SlingHttpServletRequest request)
Returns the path of the resource of the request as the item path.
|
protected VersioningConfiguration |
getVersioningConfiguration(SlingHttpServletRequest request)
Get the versioning configuration.
|
protected boolean |
hasItemPathPrefix(String name)
|
protected boolean |
isSessionSaveRequired(javax.jcr.Session session,
SlingHttpServletRequest request)
Check whether commit to the resource resolver should be called.
|
protected boolean |
isSkipCheckin(SlingHttpServletRequest request)
Check if checkin should be skipped
|
protected boolean |
isSkipSessionHandling(SlingHttpServletRequest request)
Check whether changes should be written back
|
protected boolean |
isVersionable(javax.jcr.Node node) |
protected void |
orderNode(SlingHttpServletRequest request,
javax.jcr.Item item,
List<Modification> changes)
Orders the given node according to the specified command.
|
protected String |
removeAndValidateWorkspace(String path,
javax.jcr.Session session)
Remove the workspace name, if any, from the start of the path and validate that the
session's workspace name matches the path workspace name.
|
protected boolean |
requireItemPathPrefix(SlingHttpServletRequest request)
Returns true if any of the request parameters starts with
. |
protected String |
resolvePath(String absPath,
String relPath)
Resolves the given path with respect to the current root path.
|
void |
run(SlingHttpServletRequest request,
PostResponse response,
SlingPostProcessor[] processors)
Prepares and finalizes the actual operation.
|
public void run(SlingHttpServletRequest request, PostResponse response, SlingPostProcessor[] processors)
getItemPath(SlingHttpServletRequest)
method and setting the
location and parent location on the response. After the operation has
been done in the doRun(SlingHttpServletRequest, PostResponse, List)
method the session is saved if there are unsaved modifications. In case
of errorrs, the unsaved changes in the session are rolled back.run
in interface PostOperation
request
- the request to operate onresponse
- The PostResponse
to record execution
progress.processors
- The SlingPostProcessor
services to be called
after applying the operation. This may be null
if
there are none.protected abstract void doRun(SlingHttpServletRequest request, PostResponse response, List<Modification> changes) throws javax.jcr.RepositoryException
changes
list and preparing and further information in the
response
.
The response
comes prepared with the path, location and
parent location set. Other properties are expected to be set by this
implementation.
request
- The SlingHttpServletRequest
providing the
input, mostly in terms of request parameters, to the
operation.response
- The PostResponse
to fill with response
informationchanges
- A container to add Modification
instances
representing the operations done.javax.jcr.RepositoryException
- Maybe thrown if any error occurrs while
accessing the repository.protected VersioningConfiguration getVersioningConfiguration(SlingHttpServletRequest request)
protected boolean isSkipCheckin(SlingHttpServletRequest request)
protected boolean isSkipSessionHandling(SlingHttpServletRequest request)
protected boolean isSessionSaveRequired(javax.jcr.Session session, SlingHttpServletRequest request) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
protected String removeAndValidateWorkspace(String path, javax.jcr.Session session) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
protected String getItemPath(SlingHttpServletRequest request)
This method may be overwritten by extension if the operation has different requirements on path processing.
protected Iterator<Resource> getApplyToResources(SlingHttpServletRequest request)
Resource
instances addressed in the
SlingPostConstants.RP_APPLY_TO
request parameter. If the request
parameter is not set, null
is returned. If the parameter
is set with valid resources an empty iterator is returned. Any resources
addressed in the SlingPostConstants.RP_APPLY_TO
parameter is
ignored.request
- The SlingHttpServletRequest
object used to
get the SlingPostConstants.RP_APPLY_TO
parameter.null
if the parameter is not set in the request.protected final String externalizePath(SlingHttpServletRequest request, String path)
path
- the path to externalizeprotected final String resolvePath(String absPath, String relPath)
relPath
- the path to resolveprotected final boolean requireItemPathPrefix(SlingHttpServletRequest request)
protected boolean hasItemPathPrefix(String name)
protected void orderNode(SlingHttpServletRequest request, javax.jcr.Item item, List<Modification> changes) throws javax.jcr.RepositoryException
item
- node to orderjavax.jcr.RepositoryException
- if an error occursprotected javax.jcr.Node findVersionableAncestor(javax.jcr.Node node) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
protected boolean isVersionable(javax.jcr.Node node) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
protected void checkoutIfNecessary(javax.jcr.Node node, List<Modification> changes, VersioningConfiguration versioningConfiguration) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
Copyright © 2014 The Apache Software Foundation. All rights reserved.