Class HtmlResponseProxy

java.lang.Object
org.apache.sling.api.servlets.HtmlResponse
org.apache.sling.servlets.post.impl.helper.HtmlResponseProxy

public class HtmlResponseProxy extends HtmlResponse
The HtmlResponseProxy extends the Sling API HtmlResponse overwriting all public methods and redirecting to a proxied PostResponse. As a consequence the underlying (extended) Sling API HtmlResponse will not be fed with data and thus will remain "empty".

This class is mainly used by the deprecated AbstractSlingPostOperation for bridging into the new AbstractPostOperation.

  • Constructor Details

    • HtmlResponseProxy

      public HtmlResponseProxy(PostResponse postResponse)
  • Method Details

    • getPostResponse

      public PostResponse getPostResponse()
    • getProperty

      public <Type> Type getProperty(String name, Class<Type> type)
      Description copied from class: HtmlResponse
      Returns the generic response property with the given name and type or null if no such property exists or the property is not of the requested type.
      Overrides:
      getProperty in class HtmlResponse
      Type Parameters:
      Type - The type to get
      Parameters:
      name - The property name
      type - The type to get
      Returns:
      The property value or null.
    • getProperty

      public Object getProperty(String name)
      Description copied from class: HtmlResponse
      Returns the generic response property with the given name and type or null if no such property exists.
      Overrides:
      getProperty in class HtmlResponse
      Parameters:
      name - The property name
      Returns:
      The property value or null.
    • setProperty

      public void setProperty(String name, Object value)
      Description copied from class: HtmlResponse
      Sets a generic response property with the given
      Overrides:
      setProperty in class HtmlResponse
      Parameters:
      name - name of the property
      value - value of the property
    • getError

      public Throwable getError()
      Description copied from class: HtmlResponse
      Returns any recorded error or null
      Overrides:
      getError in class HtmlResponse
      Returns:
      an error or null
    • getLocation

      public String getLocation()
      Description copied from class: HtmlResponse
      Returns the location of the modification. this is the externalized form of the current path.
      Overrides:
      getLocation in class HtmlResponse
      Returns:
      the location of the modification.
    • getParentLocation

      public String getParentLocation()
      Description copied from class: HtmlResponse
      Returns the parent location of the modification. this is the externalized form of the parent node of the current path.
      Overrides:
      getParentLocation in class HtmlResponse
      Returns:
      the location of the modification.
    • getPath

      public String getPath()
      Description copied from class: HtmlResponse
      Returns the absolute path of the item upon which the request operated.

      If the HtmlResponse.setPath(String) method has not been called yet, this method returns null.

      Overrides:
      getPath in class HtmlResponse
      Returns:
      The path or null.
    • getReferer

      public String getReferer()
      Description copied from class: HtmlResponse
      Returns the referer as from the 'referer' request header.
      Overrides:
      getReferer in class HtmlResponse
      Returns:
      The referrer
    • getStatusCode

      public int getStatusCode()
      Description copied from class: HtmlResponse
      Returns the status code of this instance. If the status code has never been set by calling the HtmlResponse.setStatus(int, String) method, the status code is determined by checking if there was an error. If there was an error, the response is assumed to be unsuccessful and 500 is returned. If there is no error, the response is assumed to be successful and 200 is returned.
      Overrides:
      getStatusCode in class HtmlResponse
      Returns:
      The status code
    • getStatusMessage

      public String getStatusMessage()
      Description copied from class: HtmlResponse
      Get the status message
      Overrides:
      getStatusMessage in class HtmlResponse
      Returns:
      The status message
    • isCreateRequest

      public boolean isCreateRequest()
      Description copied from class: HtmlResponse
      Returns true if this was a create request.

      Before calling the HtmlResponse.setCreateRequest(boolean) method, this method always returns false.

      Overrides:
      isCreateRequest in class HtmlResponse
      Returns:
      true if this is a create request
    • isSuccessful

      public boolean isSuccessful()
      Description copied from class: HtmlResponse
      Returns true if no error is set and if the status code is one of the 2xx codes.
      Overrides:
      isSuccessful in class HtmlResponse
      Returns:
      true if successful
    • onChange

      public void onChange(String type, String... arguments)
      Description copied from class: HtmlResponse
      Records a generic change of the given type.

      The change is added to the internal list of changes with the syntax of a method call, where the type is the method name and the arguments are the string arguments to the method enclosed in double quotes. For example, the the call

       onChange("sameple", "arg1", "arg2");
       
      is aded as
       sample("arg1", "arg2")
       
      to the internal list of changes.
      Overrides:
      onChange in class HtmlResponse
      Parameters:
      type - The type of the modification
      arguments - The arguments to the modifications
    • onCopied

      public void onCopied(String srcPath, String dstPath)
      Description copied from class: HtmlResponse
      Records a 'copied' change.

      Note: the copy change only records the basic copy command. the implied changes on the copied properties and sub nodes are not recorded.

      Overrides:
      onCopied in class HtmlResponse
      Parameters:
      srcPath - source path of the node that was copied
      dstPath - destination path of the node that was copied.
    • onCreated

      public void onCreated(String path)
      Description copied from class: HtmlResponse
      Records a 'created' change
      Overrides:
      onCreated in class HtmlResponse
      Parameters:
      path - path of the item that was created
    • onDeleted

      public void onDeleted(String path)
      Description copied from class: HtmlResponse
      Records a 'deleted' change
      Overrides:
      onDeleted in class HtmlResponse
      Parameters:
      path - path of the item that was deleted
    • onModified

      public void onModified(String path)
      Description copied from class: HtmlResponse
      Records a 'modified' change
      Overrides:
      onModified in class HtmlResponse
      Parameters:
      path - path of the item that was modified
    • onMoved

      public void onMoved(String srcPath, String dstPath)
      Description copied from class: HtmlResponse
      Records a 'moved' change.

      Note: the moved change only records the basic move command. the implied changes on the moved properties and sub nodes are not recorded.

      Overrides:
      onMoved in class HtmlResponse
      Parameters:
      srcPath - source path of the node that was moved
      dstPath - destination path of the node that was moved.
    • send

      public void send(javax.servlet.http.HttpServletResponse response, boolean setStatus) throws IOException
      Description copied from class: HtmlResponse
      Writes the response to the given writer and replaces all ${var} patterns by the value of the respective property. if the property is not defined the pattern is not modified.
      Overrides:
      send in class HtmlResponse
      Parameters:
      response - to send to
      setStatus - whether to set the status code on the response
      Throws:
      IOException - if an i/o exception occurs
    • setCreateRequest

      public void setCreateRequest(boolean isCreateRequest)
      Description copied from class: HtmlResponse
      Sets whether the request was a create request or not.
      Overrides:
      setCreateRequest in class HtmlResponse
      Parameters:
      isCreateRequest - flag for the create request
    • setError

      public void setError(Throwable error)
      Description copied from class: HtmlResponse
      Set the error
      Overrides:
      setError in class HtmlResponse
      Parameters:
      error - The error
    • setLocation

      public void setLocation(String location)
      Description copied from class: HtmlResponse
      Set the location
      Overrides:
      setLocation in class HtmlResponse
      Parameters:
      location - The location
    • setParentLocation

      public void setParentLocation(String parentLocation)
      Description copied from class: HtmlResponse
      Set the parent location
      Overrides:
      setParentLocation in class HtmlResponse
      Parameters:
      parentLocation - The parent location
    • setPath

      public void setPath(String path)
      Description copied from class: HtmlResponse
      Sets the absolute path of the item upon which the request operated.
      Overrides:
      setPath in class HtmlResponse
      Parameters:
      path - The path
    • setReferer

      public void setReferer(String referer)
      Description copied from class: HtmlResponse
      Sets the referer property
      Overrides:
      setReferer in class HtmlResponse
      Parameters:
      referer - The referrer to set
    • setStatus

      public void setStatus(int code, String message)
      Description copied from class: HtmlResponse
      sets the response status code properties
      Overrides:
      setStatus in class HtmlResponse
      Parameters:
      code - the code
      message - the message
    • setTitle

      public void setTitle(String title)
      Description copied from class: HtmlResponse
      Sets the title of the response message
      Overrides:
      setTitle in class HtmlResponse
      Parameters:
      title - the title