Class HtmlResponseProxy
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
.
-
Field Summary
Fields inherited from class org.apache.sling.api.servlets.HtmlResponse
PN_CHANGE_LOG, PN_ERROR, PN_IS_CREATED, PN_LOCATION, PN_PARENT_LOCATION, PN_PATH, PN_REFERER, PN_STATUS_CODE, PN_STATUS_MESSAGE, PN_TITLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetError()
Returns any recorded error ornull
Returns the location of the modification. this is the externalized form of the current path.Returns the parent location of the modification. this is the externalized form of the parent node of the current path.getPath()
Returns the absolute path of the item upon which the request operated.getProperty
(String name) Returns the generic response property with the given name and type ornull
if no such property exists.<Type> Type
getProperty
(String name, Class<Type> type) Returns the generic response property with the given name and type ornull
if no such property exists or the property is not of the requested type.Returns the referer as from the 'referer' request header.int
Returns the status code of this instance.Get the status messageboolean
Returnstrue
if this was a create request.boolean
void
Records a generic change of the giventype
.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 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.void
setCreateRequest
(boolean isCreateRequest) Sets whether the request was a create request or not.void
Set the errorvoid
setLocation
(String location) Set the locationvoid
setParentLocation
(String parentLocation) Set the parent locationvoid
Sets the absolute path of the item upon which the request operated.void
setProperty
(String name, Object value) Sets a generic response property with the givenvoid
setReferer
(String referer) Sets the referer propertyvoid
sets the response status code propertiesvoid
Sets the title of the response message
-
Constructor Details
-
HtmlResponseProxy
-
-
Method Details
-
getPostResponse
-
getProperty
Description copied from class:HtmlResponse
Returns the generic response property with the given name and type ornull
if no such property exists or the property is not of the requested type.- Overrides:
getProperty
in classHtmlResponse
- Type Parameters:
Type
- The type to get- Parameters:
name
- The property nametype
- The type to get- Returns:
- The property value or
null
.
-
getProperty
Description copied from class:HtmlResponse
Returns the generic response property with the given name and type ornull
if no such property exists.- Overrides:
getProperty
in classHtmlResponse
- Parameters:
name
- The property name- Returns:
- The property value or
null
.
-
setProperty
Description copied from class:HtmlResponse
Sets a generic response property with the given- Overrides:
setProperty
in classHtmlResponse
- Parameters:
name
- name of the propertyvalue
- value of the property
-
getError
Description copied from class:HtmlResponse
Returns any recorded error ornull
- Overrides:
getError
in classHtmlResponse
- Returns:
- an error or
null
-
getLocation
Description copied from class:HtmlResponse
Returns the location of the modification. this is the externalized form of the current path.- Overrides:
getLocation
in classHtmlResponse
- Returns:
- the location of the modification.
-
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 classHtmlResponse
- Returns:
- the location of the modification.
-
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 returnsnull
.- Overrides:
getPath
in classHtmlResponse
- Returns:
- The path or
null
.
-
getReferer
Description copied from class:HtmlResponse
Returns the referer as from the 'referer' request header.- Overrides:
getReferer
in classHtmlResponse
- 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 theHtmlResponse.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 classHtmlResponse
- Returns:
- The status code
-
getStatusMessage
Description copied from class:HtmlResponse
Get the status message- Overrides:
getStatusMessage
in classHtmlResponse
- Returns:
- The status message
-
isCreateRequest
public boolean isCreateRequest()Description copied from class:HtmlResponse
Returnstrue
if this was a create request.Before calling the
HtmlResponse.setCreateRequest(boolean)
method, this method always returnsfalse
.- Overrides:
isCreateRequest
in classHtmlResponse
- Returns:
true
if this is a create request
-
isSuccessful
public boolean isSuccessful()Description copied from class:HtmlResponse
- Overrides:
isSuccessful
in classHtmlResponse
- Returns:
true
if successful
-
onChange
Description copied from class:HtmlResponse
Records a generic change of the giventype
.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 thearguments
are the string arguments to the method enclosed in double quotes. For example, the the callonChange("sameple", "arg1", "arg2");
is aded assample("arg1", "arg2")
to the internal list of changes.- Overrides:
onChange
in classHtmlResponse
- Parameters:
type
- The type of the modificationarguments
- The arguments to the modifications
-
onCopied
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 classHtmlResponse
- Parameters:
srcPath
- source path of the node that was copieddstPath
- destination path of the node that was copied.
-
onCreated
Description copied from class:HtmlResponse
Records a 'created' change- Overrides:
onCreated
in classHtmlResponse
- Parameters:
path
- path of the item that was created
-
onDeleted
Description copied from class:HtmlResponse
Records a 'deleted' change- Overrides:
onDeleted
in classHtmlResponse
- Parameters:
path
- path of the item that was deleted
-
onModified
Description copied from class:HtmlResponse
Records a 'modified' change- Overrides:
onModified
in classHtmlResponse
- Parameters:
path
- path of the item that was modified
-
onMoved
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 classHtmlResponse
- Parameters:
srcPath
- source path of the node that was moveddstPath
- 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 classHtmlResponse
- Parameters:
response
- to send tosetStatus
- 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 classHtmlResponse
- Parameters:
isCreateRequest
- flag for the create request
-
setError
Description copied from class:HtmlResponse
Set the error- Overrides:
setError
in classHtmlResponse
- Parameters:
error
- The error
-
setLocation
Description copied from class:HtmlResponse
Set the location- Overrides:
setLocation
in classHtmlResponse
- Parameters:
location
- The location
-
setParentLocation
Description copied from class:HtmlResponse
Set the parent location- Overrides:
setParentLocation
in classHtmlResponse
- Parameters:
parentLocation
- The parent location
-
setPath
Description copied from class:HtmlResponse
Sets the absolute path of the item upon which the request operated.- Overrides:
setPath
in classHtmlResponse
- Parameters:
path
- The path
-
setReferer
Description copied from class:HtmlResponse
Sets the referer property- Overrides:
setReferer
in classHtmlResponse
- Parameters:
referer
- The referrer to set
-
setStatus
Description copied from class:HtmlResponse
sets the response status code properties- Overrides:
setStatus
in classHtmlResponse
- Parameters:
code
- the codemessage
- the message
-
setTitle
Description copied from class:HtmlResponse
Sets the title of the response message- Overrides:
setTitle
in classHtmlResponse
- Parameters:
title
- the title
-