Package org.apache.sling.servlets.post
Class AbstractPostResponseWrapper
java.lang.Object
org.apache.sling.servlets.post.AbstractPostResponseWrapper
- All Implemented Interfaces:
PostResponse
Provides a simple implementation of PostResponse that can be subclassed by developers wishing to provide specialized behavior
to an existing PostResponse instance. The default implementation of all methods is to call through to the wrapped
PostResponse instance.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetError()
Returns any recorded error ornull
Returns the location of the modification.Returns the parent location of the modification.getPath()
Returns the absolute path of the item upon which the request operated.Returns the referer previously set byPostResponse.setReferer(String)
int
Returns the status code of this instance.Returns the status message ornull
if no has been set with thePostResponse.setStatus(int, String)
method.abstract PostResponse
Use this method to return an instance of the class being wrapped.boolean
Returnstrue
if this was a create request.boolean
void
Records a generic change of the giventype
with arguments.void
Records a 'copied' change.void
Records a 'created' changevoid
Records a 'deleted' changevoid
onModified
(String path) Records a 'modified' changevoid
Records a 'moved' change.void
send
(javax.servlet.http.HttpServletResponse response, boolean setStatus) Writes the response back over the provided HTTP channel.void
setCreateRequest
(boolean isCreateRequest) Sets whether the request was a create request or not.void
Sets the recorded error causing the operation to fail.void
setLocation
(String location) Sets the location of this modification.void
setParentLocation
(String parentLocation) Sets the parent location of the modification.void
Sets the absolute path of the item upon which the request operated.void
setReferer
(String referer) Sets the referer propertyvoid
Sets the response status code propertiesvoid
Sets the title of the response message
-
Constructor Details
-
AbstractPostResponseWrapper
public AbstractPostResponseWrapper()
-
-
Method Details
-
getWrapped
Use this method to return an instance of the class being wrapped.- Returns:
- the wrapped PostResponse instance
-
setReferer
Description copied from interface:PostResponse
Sets the referer property- Specified by:
setReferer
in interfacePostResponse
- Parameters:
referer
- the referer
-
getReferer
Description copied from interface:PostResponse
Returns the referer previously set byPostResponse.setReferer(String)
- Specified by:
getReferer
in interfacePostResponse
- Returns:
- the referer
-
setPath
Description copied from interface:PostResponse
Sets the absolute path of the item upon which the request operated.- Specified by:
setPath
in interfacePostResponse
- Parameters:
path
- the path
-
getPath
Description copied from interface:PostResponse
Returns the absolute path of the item upon which the request operated.If the
PostResponse.setPath(String)
method has not been called yet, this method returnsnull
.- Specified by:
getPath
in interfacePostResponse
- Returns:
- the path (might be null)
-
setCreateRequest
public void setCreateRequest(boolean isCreateRequest) Description copied from interface:PostResponse
Sets whether the request was a create request or not.- Specified by:
setCreateRequest
in interfacePostResponse
- Parameters:
isCreateRequest
- true if the request was a create request
-
isCreateRequest
public boolean isCreateRequest()Description copied from interface:PostResponse
Returnstrue
if this was a create request.Before calling the
PostResponse.setCreateRequest(boolean)
method, this method always returnsfalse
.- Specified by:
isCreateRequest
in interfacePostResponse
- Returns:
- if this was a create request
-
setLocation
Description copied from interface:PostResponse
Sets the location of this modification. This is the externalized form of thecurrent path
.- Specified by:
setLocation
in interfacePostResponse
- Parameters:
location
- the location
-
getLocation
Description copied from interface:PostResponse
Returns the location of the modification.If the
PostResponse.setLocation(String)
method has not been called yet, this method returnsnull
.- Specified by:
getLocation
in interfacePostResponse
- Returns:
- the location
-
setParentLocation
Description copied from interface:PostResponse
Sets the parent location of the modification. This is the externalized form of the parent node of thecurrent path
.- Specified by:
setParentLocation
in interfacePostResponse
- Parameters:
parentLocation
- the parent location of the modification
-
getParentLocation
Description copied from interface:PostResponse
Returns the parent location of the modification.If the
PostResponse.setParentLocation(String)
method has not been called yet, this method returnsnull
.- Specified by:
getParentLocation
in interfacePostResponse
- Returns:
- the parent location
-
setTitle
Description copied from interface:PostResponse
Sets the title of the response message- Specified by:
setTitle
in interfacePostResponse
- Parameters:
title
- the title
-
setStatus
Description copied from interface:PostResponse
Sets the response status code properties- Specified by:
setStatus
in interfacePostResponse
- Parameters:
code
- the codemessage
- the message
-
getStatusCode
public int getStatusCode()Description copied from interface:PostResponse
Returns the status code of this instance. If the status code has never been set by calling thePostResponse.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 interfacePostResponse
- Returns:
- the status code
-
getStatusMessage
Description copied from interface:PostResponse
Returns the status message ornull
if no has been set with thePostResponse.setStatus(int, String)
method.- Specified by:
getStatusMessage
in interfacePostResponse
- Returns:
- the status message (might be null)
-
setError
Description copied from interface:PostResponse
Sets the recorded error causing the operation to fail.- Specified by:
setError
in interfacePostResponse
- Parameters:
error
- the throwable
-
getError
Description copied from interface:PostResponse
Returns any recorded error ornull
- Specified by:
getError
in interfacePostResponse
- Returns:
- an error or
null
-
isSuccessful
public boolean isSuccessful()Description copied from interface:PostResponse
- Specified by:
isSuccessful
in interfacePostResponse
- Returns:
- true if the status code is 2xx
-
onCreated
Description copied from interface:PostResponse
Records a 'created' change- Specified by:
onCreated
in interfacePostResponse
- Parameters:
path
- path of the item that was created
-
onModified
Description copied from interface:PostResponse
Records a 'modified' change- Specified by:
onModified
in interfacePostResponse
- Parameters:
path
- path of the item that was modified
-
onDeleted
Description copied from interface:PostResponse
Records a 'deleted' change- Specified by:
onDeleted
in interfacePostResponse
- Parameters:
path
- path of the item that was deleted
-
onMoved
Description copied from interface:PostResponse
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 interfacePostResponse
- Parameters:
srcPath
- source path of the node that was moveddstPath
- destination path of the node that was moved.
-
onCopied
Description copied from interface:PostResponse
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 interfacePostResponse
- Parameters:
srcPath
- source path of the node that was copieddstPath
- destination path of the node that was copied.
-
onChange
Description copied from interface:PostResponse
Records a generic change of the giventype
with arguments.- Specified by:
onChange
in interfacePostResponse
- Parameters:
type
- The type of the modificationarguments
- The arguments to the modifications
-
send
public void send(javax.servlet.http.HttpServletResponse response, boolean setStatus) throws IOException Description copied from interface:PostResponse
Writes the response back over the provided HTTP channel. The actual format of the response is implementation dependent.- Specified by:
send
in interfacePostResponse
- Parameters:
response
- to send tosetStatus
- whether to set the status code on the response- Throws:
IOException
- if an i/o exception occurs
-