Class AbstractPostResponse

  • All Implemented Interfaces:
    PostResponse
    Direct Known Subclasses:
    HtmlResponse, HtmlResponse, JSONResponse

    public abstract class AbstractPostResponse
    extends java.lang.Object
    implements PostResponse
    The AbstractPostResponse class provides a basic implementation of the PostResponse interface maintaining properties to be prepared for sending the response in an internal map.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Throwable getError()
      Returns any recorded error or null
      java.lang.String getLocation()
      Returns the location of the modification.
      java.lang.String getParentLocation()
      Returns the parent location of the modification.
      java.lang.String getPath()
      Returns the absolute path of the item upon which the request operated.
      java.lang.String getReferer()
      Returns the referer as from the 'referer' request header.
      int getStatusCode()
      Returns the status code of this instance.
      java.lang.String getStatusMessage()
      Returns the status message or null if no has been set with the PostResponse.setStatus(int, String) method.
      boolean isCreateRequest()
      Returns true if this was a create request.
      boolean isSuccessful()
      Returns true if no error is set and if the status code is one of the 2xx codes.
      void onCopied​(java.lang.String srcPath, java.lang.String dstPath)
      Records a 'copied' change.
      void onCreated​(java.lang.String path)
      Records a 'created' change
      void onDeleted​(java.lang.String path)
      Records a 'deleted' change
      void onModified​(java.lang.String path)
      Records a 'modified' change
      void onMoved​(java.lang.String srcPath, java.lang.String dstPath)
      Records a 'moved' change.
      void send​(HttpServletResponse response, boolean setStatus)
      Writes the response to the given writer and replaces all ${var} patterns by the value of the respective property.
      void setCreateRequest​(boolean isCreateRequest)
      Sets whether the request was a create request or not.
      void setError​(java.lang.Throwable error)
      Sets the recorded error causing the operation to fail.
      void setLocation​(java.lang.String location)
      Sets the location of this modification.
      void setParentLocation​(java.lang.String parentLocation)
      Sets the parent location of the modification.
      void setPath​(java.lang.String path)
      Sets the absolute path of the item upon which the request operated.
      void setReferer​(java.lang.String referer)
      Sets the referer property
      void setStatus​(int code, java.lang.String message)
      sets the response status code properties
      void setTitle​(java.lang.String title)
      Sets the title of the response message
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractPostResponse

        public AbstractPostResponse()
    • Method Detail

      • getReferer

        public java.lang.String getReferer()
        Returns the referer as from the 'referer' request header.
        Specified by:
        getReferer in interface PostResponse
      • setReferer

        public void setReferer​(java.lang.String referer)
        Sets the referer property
        Specified by:
        setReferer in interface PostResponse
      • getPath

        public java.lang.String getPath()
        Returns the absolute path of the item upon which the request operated.

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

        Specified by:
        getPath in interface PostResponse
      • setPath

        public void setPath​(java.lang.String path)
        Sets the absolute path of the item upon which the request operated.
        Specified by:
        setPath in interface PostResponse
      • setCreateRequest

        public void setCreateRequest​(boolean isCreateRequest)
        Sets whether the request was a create request or not.
        Specified by:
        setCreateRequest in interface PostResponse
      • getLocation

        public java.lang.String getLocation()
        Returns the location of the modification. this is the externalized form of the current path.
        Specified by:
        getLocation in interface PostResponse
        Returns:
        the location of the modification.
      • setLocation

        public void setLocation​(java.lang.String location)
        Description copied from interface: PostResponse
        Sets the location of this modification. This is the externalized form of the current path.
        Specified by:
        setLocation in interface PostResponse
      • getParentLocation

        public java.lang.String getParentLocation()
        Returns the parent location of the modification. this is the externalized form of the parent node of the current path.
        Specified by:
        getParentLocation in interface PostResponse
        Returns:
        the location of the modification.
      • setParentLocation

        public void setParentLocation​(java.lang.String parentLocation)
        Description copied from interface: PostResponse
        Sets the parent location of the modification. This is the externalized form of the parent node of the current path.
        Specified by:
        setParentLocation in interface PostResponse
      • setTitle

        public void setTitle​(java.lang.String title)
        Sets the title of the response message
        Specified by:
        setTitle in interface PostResponse
        Parameters:
        title - the title
      • setStatus

        public void setStatus​(int code,
                              java.lang.String message)
        sets the response status code properties
        Specified by:
        setStatus in interface PostResponse
        Parameters:
        code - the code
        message - the message
      • getStatusCode

        public int getStatusCode()
        Returns the status code of this instance. If the status code has never been set by calling the 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.
        Specified by:
        getStatusCode in interface PostResponse
      • getError

        public java.lang.Throwable getError()
        Returns any recorded error or null
        Specified by:
        getError in interface PostResponse
        Returns:
        an error or null
      • setError

        public void setError​(java.lang.Throwable error)
        Description copied from interface: PostResponse
        Sets the recorded error causing the operation to fail.
        Specified by:
        setError in interface PostResponse
      • onModified

        public void onModified​(java.lang.String path)
        Records a 'modified' change
        Specified by:
        onModified in interface PostResponse
        Parameters:
        path - path of the item that was modified
      • onCreated

        public void onCreated​(java.lang.String path)
        Records a 'created' change
        Specified by:
        onCreated in interface PostResponse
        Parameters:
        path - path of the item that was created
      • onDeleted

        public void onDeleted​(java.lang.String path)
        Records a 'deleted' change
        Specified by:
        onDeleted in interface PostResponse
        Parameters:
        path - path of the item that was deleted
      • onMoved

        public void onMoved​(java.lang.String srcPath,
                            java.lang.String dstPath)
        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.

        Specified by:
        onMoved in interface PostResponse
        Parameters:
        srcPath - source path of the node that was moved
        dstPath - destination path of the node that was moved.
      • onCopied

        public void onCopied​(java.lang.String srcPath,
                             java.lang.String dstPath)
        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.

        Specified by:
        onCopied in interface PostResponse
        Parameters:
        srcPath - source path of the node that was copied
        dstPath - destination path of the node that was copied.
      • send

        public final void send​(HttpServletResponse response,
                               boolean setStatus)
                        throws java.io.IOException
        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.
        Specified by:
        send in interface PostResponse
        Parameters:
        response - to send to
        setStatus - whether to set the status code on the response
        Throws:
        java.io.IOException - if an i/o exception occurs