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 public abstract class AbstractPostOperation extends java.lang.Object implements PostOperation
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.TheAbstractPostOperationclass is a base implementation of thePostOperationservice 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 Modifier and Type Field Description protected org.slf4j.LoggerlogDeprecated.default log-
Fields inherited from interface org.apache.sling.servlets.post.PostOperation
PROP_OPERATION_NAME, SERVICE_NAME
-
-
Constructor Summary
Constructors Constructor Description AbstractPostOperation()Deprecated.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidcheckoutIfNecessary(javax.jcr.Node node, java.util.List<Modification> changes, VersioningConfiguration versioningConfiguration)Deprecated.protected abstract voiddoRun(org.apache.sling.api.SlingHttpServletRequest request, PostResponse response, java.util.List<Modification> changes)Deprecated.Actually performs the desired operation filling progress into thechangeslist and preparing and further information in theresponse.protected java.lang.StringexternalizePath(org.apache.sling.api.SlingHttpServletRequest request, java.lang.String path)Deprecated.Returns an external form of the given path prepending the context path and appending a display extension.protected javax.jcr.NodefindVersionableAncestor(javax.jcr.Node node)Deprecated.protected java.util.Iterator<org.apache.sling.api.resource.Resource>getApplyToResources(org.apache.sling.api.SlingHttpServletRequest request)Deprecated.Returns an iterator onResourceinstances addressed in theSlingPostConstants.RP_APPLY_TOrequest parameter.protected java.lang.StringgetItemPath(org.apache.sling.api.SlingHttpServletRequest request)Deprecated.Returns the path of the resource of the request as the item path.protected VersioningConfigurationgetVersioningConfiguration(org.apache.sling.api.SlingHttpServletRequest request)Deprecated.Get the versioning configuration.protected booleanhasItemPathPrefix(java.lang.String name)Deprecated.protected booleanisSessionSaveRequired(javax.jcr.Session session, org.apache.sling.api.SlingHttpServletRequest request)Deprecated.Check whether commit to the resource resolver should be called.protected booleanisSkipCheckin(org.apache.sling.api.SlingHttpServletRequest request)Deprecated.Check if checkin should be skippedprotected booleanisSkipSessionHandling(org.apache.sling.api.SlingHttpServletRequest request)Deprecated.Check whether changes should be written backprotected booleanisVersionable(javax.jcr.Node node)Deprecated.protected voidorderNode(org.apache.sling.api.SlingHttpServletRequest request, javax.jcr.Item item, java.util.List<Modification> changes)Deprecated.Orders the given node according to the specified command.protected java.lang.StringremoveAndValidateWorkspace(java.lang.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 booleanrequireItemPathPrefix(org.apache.sling.api.SlingHttpServletRequest request)Deprecated.Returns true if any of the request parameters starts with../protected java.lang.StringresolvePath(java.lang.String absPath, java.lang.String relPath)Deprecated.Resolves the given path with respect to the current root path.voidrun(org.apache.sling.api.SlingHttpServletRequest request, PostResponse response, SlingPostProcessor[] processors)Deprecated.Prepares and finalizes the actual operation.
-
-
-
Method Detail
-
run
public void run(org.apache.sling.api.SlingHttpServletRequest request, PostResponse response, SlingPostProcessor[] processors) throws PreconditionViolatedPersistenceException, TemporaryPersistenceExceptionDeprecated.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:
runin interfacePostOperation- Parameters:
request- the request to operate onresponse- ThePostResponseto record execution progress.processors- The array of processors- Throws:
PreconditionViolatedPersistenceExceptionTemporaryPersistenceException
-
doRun
protected abstract void doRun(org.apache.sling.api.SlingHttpServletRequest request, PostResponse response, java.util.List<Modification> changes) throws javax.jcr.RepositoryException, PreconditionViolatedPersistenceException, TemporaryPersistenceExceptionDeprecated.Actually performs the desired operation filling progress into thechangeslist and preparing and further information in theresponse.The
responsecomes prepared with the path, location and parent location set. Other properties are expected to be set by this implementation.- Parameters:
request- TheSlingHttpServletRequestproviding the input, mostly in terms of request parameters, to the operation.response- ThePostResponseto fill with response informationchanges- A container to addModificationinstances representing the operations done.- Throws:
javax.jcr.RepositoryException- Maybe thrown if any error occurrs while accessing the repository.TemporaryPersistenceExceptionPreconditionViolatedPersistenceException
-
getVersioningConfiguration
protected VersioningConfiguration getVersioningConfiguration(org.apache.sling.api.SlingHttpServletRequest request)
Deprecated.Get the versioning configuration.- Parameters:
request- The http request- Returns:
- The versioning configuration
-
isSkipCheckin
protected boolean isSkipCheckin(org.apache.sling.api.SlingHttpServletRequest request)
Deprecated.Check if checkin should be skipped- Parameters:
request- The http request- Returns:
trueif checkin should be skipped
-
isSkipSessionHandling
protected boolean isSkipSessionHandling(org.apache.sling.api.SlingHttpServletRequest request)
Deprecated.Check whether changes should be written back- Parameters:
request- The http request- Returns:
trueIf session handling should be skipped
-
isSessionSaveRequired
protected boolean isSessionSaveRequired(javax.jcr.Session session, org.apache.sling.api.SlingHttpServletRequest request) throws javax.jcr.RepositoryExceptionDeprecated.Check whether commit to the resource resolver should be called.- Parameters:
session- The JCR sessionrequest- The http request- Returns:
trueif a save is required.- Throws:
javax.jcr.RepositoryException
-
removeAndValidateWorkspace
protected java.lang.String removeAndValidateWorkspace(java.lang.String path, javax.jcr.Session session) throws javax.jcr.RepositoryExceptionDeprecated.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
-
getItemPath
protected java.lang.String getItemPath(org.apache.sling.api.SlingHttpServletRequest request)
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
protected java.util.Iterator<org.apache.sling.api.resource.Resource> getApplyToResources(org.apache.sling.api.SlingHttpServletRequest request)
Deprecated.Returns an iterator onResourceinstances addressed in theSlingPostConstants.RP_APPLY_TOrequest parameter. If the request parameter is not set,nullis returned. If the parameter is set with valid resources an empty iterator is returned. Any resources addressed in theSlingPostConstants.RP_APPLY_TOparameter is ignored.- Parameters:
request- TheSlingHttpServletRequestobject used to get theSlingPostConstants.RP_APPLY_TOparameter.- Returns:
- The iterator of resources listed in the parameter or
nullif the parameter is not set in the request.
-
externalizePath
protected final java.lang.String externalizePath(org.apache.sling.api.SlingHttpServletRequest request, java.lang.String path)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
protected final java.lang.String resolvePath(java.lang.String absPath, java.lang.String relPath)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
protected final boolean requireItemPathPrefix(org.apache.sling.api.SlingHttpServletRequest request)
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
protected boolean hasItemPathPrefix(java.lang.String name)
Deprecated.- Parameters:
name- The name- Returns:
trueif the name has a prefix
-
orderNode
protected void orderNode(org.apache.sling.api.SlingHttpServletRequest request, javax.jcr.Item item, java.util.List<Modification> changes) throws javax.jcr.RepositoryExceptionDeprecated.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.RepositoryExceptionDeprecated.- Throws:
javax.jcr.RepositoryException
-
isVersionable
protected boolean isVersionable(javax.jcr.Node node) throws javax.jcr.RepositoryExceptionDeprecated.- Throws:
javax.jcr.RepositoryException
-
checkoutIfNecessary
protected void checkoutIfNecessary(javax.jcr.Node node, java.util.List<Modification> changes, VersioningConfiguration versioningConfiguration) throws javax.jcr.RepositoryExceptionDeprecated.- Throws:
javax.jcr.RepositoryException
-
-