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 ornullReturns 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 ornullif no such property exists.<Type> TypegetProperty(String name, Class<Type> type) Returns the generic response property with the given name and type ornullif no such property exists or the property is not of the requested type.Returns the referer as from the 'referer' request header.intReturns the status code of this instance.Get the status messagebooleanReturnstrueif this was a create request.booleanvoidRecords a generic change of the giventype.voidRecords a 'copied' change.voidRecords a 'created' changevoidRecords a 'deleted' changevoidonModified(String path) Records a 'modified' changevoidRecords a 'moved' change.voidsend(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.voidsetCreateRequest(boolean isCreateRequest) Sets whether the request was a create request or not.voidSet the errorvoidsetLocation(String location) Set the locationvoidsetParentLocation(String parentLocation) Set the parent locationvoidSets the absolute path of the item upon which the request operated.voidsetProperty(String name, Object value) Sets a generic response property with the givenvoidsetReferer(String referer) Sets the referer propertyvoidsets the response status code propertiesvoidSets the title of the response message
-
Constructor Details
-
HtmlResponseProxy
-
-
Method Details
-
getPostResponse
-
getProperty
Description copied from class:HtmlResponseReturns the generic response property with the given name and type ornullif no such property exists or the property is not of the requested type.- Overrides:
getPropertyin 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:HtmlResponseReturns the generic response property with the given name and type ornullif no such property exists.- Overrides:
getPropertyin classHtmlResponse- Parameters:
name- The property name- Returns:
- The property value or
null.
-
setProperty
Description copied from class:HtmlResponseSets a generic response property with the given- Overrides:
setPropertyin classHtmlResponse- Parameters:
name- name of the propertyvalue- value of the property
-
getError
Description copied from class:HtmlResponseReturns any recorded error ornull- Overrides:
getErrorin classHtmlResponse- Returns:
- an error or
null
-
getLocation
Description copied from class:HtmlResponseReturns the location of the modification. this is the externalized form of the current path.- Overrides:
getLocationin classHtmlResponse- Returns:
- the location of the modification.
-
getParentLocation
Description copied from class:HtmlResponseReturns the parent location of the modification. this is the externalized form of the parent node of the current path.- Overrides:
getParentLocationin classHtmlResponse- Returns:
- the location of the modification.
-
getPath
Description copied from class:HtmlResponseReturns 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:
getPathin classHtmlResponse- Returns:
- The path or
null.
-
getReferer
Description copied from class:HtmlResponseReturns the referer as from the 'referer' request header.- Overrides:
getRefererin classHtmlResponse- Returns:
- The referrer
-
getStatusCode
public int getStatusCode()Description copied from class:HtmlResponseReturns 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:
getStatusCodein classHtmlResponse- Returns:
- The status code
-
getStatusMessage
Description copied from class:HtmlResponseGet the status message- Overrides:
getStatusMessagein classHtmlResponse- Returns:
- The status message
-
isCreateRequest
public boolean isCreateRequest()Description copied from class:HtmlResponseReturnstrueif this was a create request.Before calling the
HtmlResponse.setCreateRequest(boolean)method, this method always returnsfalse.- Overrides:
isCreateRequestin classHtmlResponse- Returns:
trueif this is a create request
-
isSuccessful
public boolean isSuccessful()Description copied from class:HtmlResponse- Overrides:
isSuccessfulin classHtmlResponse- Returns:
trueif successful
-
onChange
Description copied from class:HtmlResponseRecords 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
typeis the method name and theargumentsare 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:
onChangein classHtmlResponse- Parameters:
type- The type of the modificationarguments- The arguments to the modifications
-
onCopied
Description copied from class:HtmlResponseRecords 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:
onCopiedin classHtmlResponse- Parameters:
srcPath- source path of the node that was copieddstPath- destination path of the node that was copied.
-
onCreated
Description copied from class:HtmlResponseRecords a 'created' change- Overrides:
onCreatedin classHtmlResponse- Parameters:
path- path of the item that was created
-
onDeleted
Description copied from class:HtmlResponseRecords a 'deleted' change- Overrides:
onDeletedin classHtmlResponse- Parameters:
path- path of the item that was deleted
-
onModified
Description copied from class:HtmlResponseRecords a 'modified' change- Overrides:
onModifiedin classHtmlResponse- Parameters:
path- path of the item that was modified
-
onMoved
Description copied from class:HtmlResponseRecords 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:
onMovedin 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:HtmlResponseWrites 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:
sendin 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:HtmlResponseSets whether the request was a create request or not.- Overrides:
setCreateRequestin classHtmlResponse- Parameters:
isCreateRequest- flag for the create request
-
setError
Description copied from class:HtmlResponseSet the error- Overrides:
setErrorin classHtmlResponse- Parameters:
error- The error
-
setLocation
Description copied from class:HtmlResponseSet the location- Overrides:
setLocationin classHtmlResponse- Parameters:
location- The location
-
setParentLocation
Description copied from class:HtmlResponseSet the parent location- Overrides:
setParentLocationin classHtmlResponse- Parameters:
parentLocation- The parent location
-
setPath
Description copied from class:HtmlResponseSets the absolute path of the item upon which the request operated.- Overrides:
setPathin classHtmlResponse- Parameters:
path- The path
-
setReferer
Description copied from class:HtmlResponseSets the referer property- Overrides:
setRefererin classHtmlResponse- Parameters:
referer- The referrer to set
-
setStatus
Description copied from class:HtmlResponsesets the response status code properties- Overrides:
setStatusin classHtmlResponse- Parameters:
code- the codemessage- the message
-
setTitle
Description copied from class:HtmlResponseSets the title of the response message- Overrides:
setTitlein classHtmlResponse- Parameters:
title- the title
-