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 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.
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 Details

    • log

      protected final org.slf4j.Logger log
      Deprecated.
      default log
  • Constructor Details

    • AbstractPostOperation

      public AbstractPostOperation()
      Deprecated.
  • Method Details

    • run

      Deprecated.
      Prepares and finalizes the actual operation. Preparation encompasses getting the absolute path of the item to operate on by calling the 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.
      Specified by:
      run in interface PostOperation
      Parameters:
      request - the request to operate on
      response - The PostResponse 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 the 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.

      Parameters:
      request - The SlingHttpServletRequest providing the input, mostly in terms of request parameters, to the operation.
      response - The PostResponse to fill with response information
      changes - A container to add Modification instances representing the operations done.
      Throws:
      javax.jcr.RepositoryException - Maybe thrown if any error occurrs while accessing the repository.
      TemporaryPersistenceException - if a retry could help
      PreconditionViolatedPersistenceException - if a retry doesn't make sense and some preconditions should be changed.
    • getVersioningConfiguration

      protected VersioningConfiguration getVersioningConfiguration(SlingHttpServletRequest request)
      Deprecated.
      Get the versioning configuration.
      Parameters:
      request - The http request
      Returns:
      The versioning configuration
    • isSkipCheckin

      protected boolean isSkipCheckin(SlingHttpServletRequest request)
      Deprecated.
      Check if checkin should be skipped
      Parameters:
      request - The http request
      Returns:
      true if checkin should be skipped
    • isSkipSessionHandling

      protected boolean isSkipSessionHandling(SlingHttpServletRequest request)
      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 session
      request - 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 path
      session - The JCR session
      Returns:
      The path without the workspace
      Throws:
      javax.jcr.RepositoryException - a repository exception
    • getItemPath

      protected String getItemPath(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 Iterator<Resource> getApplyToResources(SlingHttpServletRequest request)
      Deprecated.
      Returns an iterator on 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.
      Parameters:
      request - The SlingHttpServletRequest object used to get the SlingPostConstants.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

      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.
      Parameters:
      request - The http request
      path - the path to externalize
      Returns:
      the url
    • resolvePath

      protected final String resolvePath(String absPath, String relPath)
      Deprecated.
      Resolves the given path with respect to the current root path.
      Parameters:
      absPath - The absolute base path
      relPath - the path to resolve
      Returns:
      the given path if it starts with a '/'; a resolved path otherwise.
    • requireItemPathPrefix

      protected final boolean requireItemPathPrefix(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(String name)
      Deprecated.
      Returns true if the name starts with either of the prefixes ./, ../ and /.
      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 request
      item - node to order
      changes - 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