Package org.apache.sling.servlets.post
Class AbstractPostOperation
java.lang.Object
org.apache.sling.servlets.post.AbstractPostOperation
- All Implemented Interfaces:
PostOperation
- Direct Known Subclasses:
AbstractSlingPostOperation
Deprecated.
(SLING-6722): this class mixes Sling and JCR APIs which is not
optimal as nowadays we favor the Sling APIs. There's no intention to remove
it however, if you're using JCR APIs anyways in your project it's fine to
use it. Theres no public replacement for it as I write this.
The
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.-
Field Summary
Fields inherited from interface org.apache.sling.servlets.post.PostOperation
PROP_OPERATION_NAME, SERVICE_NAME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkoutIfNecessary
(javax.jcr.Node node, List<Modification> changes, VersioningConfiguration versioningConfiguration) Deprecated.protected abstract void
doRun
(SlingHttpServletRequest request, PostResponse response, List<Modification> changes) Deprecated.Actually performs the desired operation filling progress into thechanges
list and preparing and further information in theresponse
.protected final String
externalizePath
(SlingHttpServletRequest request, String path) Deprecated.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) Deprecated.Deprecated.Returns an iterator onResource
instances addressed in theSlingPostConstants.RP_APPLY_TO
request parameter.protected String
getItemPath
(SlingHttpServletRequest request) Deprecated.Returns the path of the resource of the request as the item path.protected VersioningConfiguration
Deprecated.Get the versioning configuration.protected boolean
hasItemPathPrefix
(String name) protected boolean
isSessionSaveRequired
(javax.jcr.Session session, SlingHttpServletRequest request) Deprecated.Check whether commit to the resource resolver should be called.protected boolean
isSkipCheckin
(SlingHttpServletRequest request) Deprecated.Check if checkin should be skippedprotected boolean
Deprecated.Check whether changes should be written backprotected boolean
isVersionable
(javax.jcr.Node node) Deprecated.protected void
orderNode
(SlingHttpServletRequest request, javax.jcr.Item item, List<Modification> changes) Deprecated.Orders the given node according to the specified command.protected String
removeAndValidateWorkspace
(String path, javax.jcr.Session session) Deprecated.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 final boolean
Deprecated.Returns true if any of the request parameters starts with./
.protected final String
resolvePath
(String absPath, String relPath) Deprecated.Resolves the given path with respect to the current root path.void
run
(SlingHttpServletRequest request, PostResponse response, SlingPostProcessor[] processors) Deprecated.Prepares and finalizes the actual operation.
-
Field Details
-
log
protected final org.slf4j.Logger logDeprecated.default log
-
-
Constructor Details
-
AbstractPostOperation
public AbstractPostOperation()Deprecated.
-
-
Method Details
-
run
public void run(SlingHttpServletRequest request, PostResponse response, SlingPostProcessor[] processors) throws PreconditionViolatedPersistenceException, TemporaryPersistenceException Deprecated.Prepares and finalizes the actual operation. Preparation encompasses getting the absolute path of the item to operate on by calling thegetItemPath(SlingHttpServletRequest)
method and setting the location and parent location on the response. After the operation has been done in thedoRun(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.- Specified by:
run
in interfacePostOperation
- Parameters:
request
- the request to operate onresponse
- ThePostResponse
to record execution progress.processors
- The array of processors- Throws:
PreconditionViolatedPersistenceException
- when a necessary precondition failed, and a retry without further changes doesn't make sense.TemporaryPersistenceException
- when a commit failed, but a retry could make the operation work successfully.
-
doRun
protected abstract void doRun(SlingHttpServletRequest request, PostResponse response, List<Modification> changes) throws javax.jcr.RepositoryException, PreconditionViolatedPersistenceException, TemporaryPersistenceException Deprecated.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.- 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:
javax.jcr.RepositoryException
- Maybe thrown if any error occurrs while accessing the repository.TemporaryPersistenceException
- if a retry could helpPreconditionViolatedPersistenceException
- if a retry doesn't make sense and some preconditions should be changed.
-
getVersioningConfiguration
Deprecated.Get the versioning configuration.- Parameters:
request
- The http request- Returns:
- The versioning configuration
-
isSkipCheckin
Deprecated.Check if checkin should be skipped- Parameters:
request
- The http request- Returns:
true
if checkin should be skipped
-
isSkipSessionHandling
Deprecated.Check whether changes should be written back- Parameters:
request
- The http request- Returns:
true
If session handling should be skipped
-
isSessionSaveRequired
protected boolean isSessionSaveRequired(javax.jcr.Session session, SlingHttpServletRequest request) throws javax.jcr.RepositoryException Deprecated.Check whether commit to the resource resolver should be called.- Parameters:
session
- The JCR sessionrequest
- The http request- Returns:
true
if a save is required.- Throws:
javax.jcr.RepositoryException
- a repository exception
-
removeAndValidateWorkspace
protected String removeAndValidateWorkspace(String path, javax.jcr.Session session) throws javax.jcr.RepositoryException Deprecated.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.- Parameters:
path
- The pathsession
- The JCR session- Returns:
- The path without the workspace
- Throws:
javax.jcr.RepositoryException
- a repository exception
-
getItemPath
Deprecated.Returns the path of the resource of the request as the item path.This method may be overwritten by extension if the operation has different requirements on path processing.
- Parameters:
request
- The http request- Returns:
- The item path
-
getApplyToResources
Deprecated.Returns an iterator onResource
instances addressed in theSlingPostConstants.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 theSlingPostConstants.RP_APPLY_TO
parameter is ignored.- Parameters:
request
- TheSlingHttpServletRequest
object used to get theSlingPostConstants.RP_APPLY_TO
parameter.- Returns:
- The iterator of resources listed in the parameter or
null
if the parameter is not set in the request.
-
externalizePath
Deprecated.Returns an external form of the given path prepending the context path and appending a display extension.- Parameters:
request
- The http requestpath
- the path to externalize- Returns:
- the url
-
resolvePath
Deprecated.Resolves the given path with respect to the current root path.- Parameters:
absPath
- The absolute base pathrelPath
- the path to resolve- Returns:
- the given path if it starts with a '/'; a resolved path otherwise.
-
requireItemPathPrefix
Deprecated.Returns true if any of the request parameters starts with./
. In this case only parameters starting with either of the prefixes./
,../
and/
are considered as providing content to be stored. Otherwise all parameters not starting with the command prefix:
are considered as parameters to be stored.- Parameters:
request
- The http request- Returns:
- If a prefix is required.
-
hasItemPathPrefix
Deprecated.- Parameters:
name
- The name- Returns:
true
if the name has a prefix
-
orderNode
protected void orderNode(SlingHttpServletRequest request, javax.jcr.Item item, List<Modification> changes) throws javax.jcr.RepositoryException Deprecated.Orders the given node according to the specified command. The following syntax is supported: <xmp> | first | before all child nodes | before A | before child node A | after A | after child node A | last | after all nodes | N | at a specific position, N being an integer </xmp>- Parameters:
request
- The http requestitem
- node to orderchanges
- The list of modifications- Throws:
javax.jcr.RepositoryException
- if an error occurs
-
findVersionableAncestor
protected javax.jcr.Node findVersionableAncestor(javax.jcr.Node node) throws javax.jcr.RepositoryException Deprecated.- Throws:
javax.jcr.RepositoryException
-
isVersionable
protected boolean isVersionable(javax.jcr.Node node) throws javax.jcr.RepositoryException Deprecated.- Throws:
javax.jcr.RepositoryException
-
checkoutIfNecessary
protected void checkoutIfNecessary(javax.jcr.Node node, List<Modification> changes, VersioningConfiguration versioningConfiguration) throws javax.jcr.RepositoryException Deprecated.- Throws:
javax.jcr.RepositoryException
-