Package org.apache.sling.servlets.post
Klasse AbstractJakartaPostResponse
java.lang.Object
org.apache.sling.servlets.post.AbstractJakartaPostResponse
- Alle implementierten Schnittstellen:
JakartaPostResponse
- Bekannte direkte Unterklassen:
JakartaHtmlResponse,JakartaJSONResponse
The
AbstractPostResponse class provides a basic implementation
of the PostResponse interface maintaining properties to be
prepared for sending the response in an internal map.- Seit:
- 2.5.0
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungstatic final StringName of the error property set bysetError(Throwable)static final StringName of the create status property set bysetCreateRequest(boolean)static final StringName of the location property set bysetLocation(String)static final StringName of the parent location property set bysetParentLocation(String)static final StringName of the path property set bysetPath(String)static final StringName of the referer property set bysetReferer(String)static final StringName of the status code property set bysetStatus(int, String)static final StringName of the status message property set bysetStatus(int, String)static final StringName of the title property set bysetTitle(String) -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprotected abstract voiddoSend(jakarta.servlet.http.HttpServletResponse response) getError()Returns any recorded error ornullReturns the location of the modification.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.protected ObjectgetProperty(String name) Returns the generic response property with the given name and type ornullif no such property exists.protected <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 previously set byJakartaPostResponse.setReferer(String)intReturns the status code of this instance.Returns the status message ornullif no has been set with theJakartaPostResponse.setStatus(int, String)method.booleanReturnstrueif this was a create request.protected booleandetermines if the referer has a proper referer including protocolbooleanvoidRecords a 'copied' change.voidRecords a 'created' changevoidRecords a 'deleted' changevoidonModified(String path) Records a 'modified' changevoidRecords a 'moved' change.final voidsend(jakarta.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.voidSets the recorded error causing the operation to fail.voidsetLocation(String location) Sets the location of this modification.voidsetParentLocation(String parentLocation) Sets the parent location of the modification.voidSets the absolute path of the item upon which the request operated.protected 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 messageVon Klasse geerbte Methoden java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitVon Schnittstelle geerbte Methoden org.apache.sling.servlets.post.JakartaPostResponse
onChange
-
Felddetails
-
PN_TITLE
Name of the title property set bysetTitle(String)- Siehe auch:
-
PN_STATUS_CODE
Name of the status code property set bysetStatus(int, String)- Siehe auch:
-
PN_STATUS_MESSAGE
Name of the status message property set bysetStatus(int, String)- Siehe auch:
-
PN_LOCATION
Name of the location property set bysetLocation(String)- Siehe auch:
-
PN_PARENT_LOCATION
Name of the parent location property set bysetParentLocation(String)- Siehe auch:
-
PN_PATH
Name of the path property set bysetPath(String)- Siehe auch:
-
PN_REFERER
Name of the referer property set bysetReferer(String)- Siehe auch:
-
PN_IS_CREATED
Name of the create status property set bysetCreateRequest(boolean)- Siehe auch:
-
PN_ERROR
Name of the error property set bysetError(Throwable)- Siehe auch:
-
-
Konstruktordetails
-
AbstractJakartaPostResponse
public AbstractJakartaPostResponse()
-
-
Methodendetails
-
getReferer
Returns the referer previously set byJakartaPostResponse.setReferer(String)- Angegeben von:
getRefererin SchnittstelleJakartaPostResponse- Gibt zurück:
- the referer
-
setReferer
Sets the referer property- Angegeben von:
setRefererin SchnittstelleJakartaPostResponse- Parameter:
referer- the referer
-
getPath
Returns the absolute path of the item upon which the request operated.If the
JakartaPostResponse.setPath(String)method has not been called yet, this method returnsnull.- Angegeben von:
getPathin SchnittstelleJakartaPostResponse- Gibt zurück:
- the path (might be null)
-
setPath
Sets the absolute path of the item upon which the request operated.- Angegeben von:
setPathin SchnittstelleJakartaPostResponse- Parameter:
path- the path
-
isCreateRequest
public boolean isCreateRequest()Returnstrueif this was a create request.Before calling the
JakartaPostResponse.setCreateRequest(boolean)method, this method always returnsfalse.- Angegeben von:
isCreateRequestin SchnittstelleJakartaPostResponse- Gibt zurück:
- if this was a create request
-
setCreateRequest
public void setCreateRequest(boolean isCreateRequest) Sets whether the request was a create request or not.- Angegeben von:
setCreateRequestin SchnittstelleJakartaPostResponse- Parameter:
isCreateRequest- true if the request was a create request
-
getLocation
Returns the location of the modification.If the
JakartaPostResponse.setLocation(String)method has not been called yet, this method returnsnull.- Angegeben von:
getLocationin SchnittstelleJakartaPostResponse- Gibt zurück:
- the location
-
setLocation
Beschreibung aus Schnittstelle kopiert:JakartaPostResponseSets the location of this modification. This is the externalized form of thecurrent path.- Angegeben von:
setLocationin SchnittstelleJakartaPostResponse- Parameter:
location- the location
-
getParentLocation
Returns the parent location of the modification. this is the externalized form of the parent node of the current path.- Angegeben von:
getParentLocationin SchnittstelleJakartaPostResponse- Gibt zurück:
- the location of the modification.
-
setParentLocation
Beschreibung aus Schnittstelle kopiert:JakartaPostResponseSets the parent location of the modification. This is the externalized form of the parent node of thecurrent path.- Angegeben von:
setParentLocationin SchnittstelleJakartaPostResponse- Parameter:
parentLocation- the parent location of the modification
-
setTitle
Sets the title of the response message- Angegeben von:
setTitlein SchnittstelleJakartaPostResponse- Parameter:
title- the title
-
setStatus
sets the response status code properties- Angegeben von:
setStatusin SchnittstelleJakartaPostResponse- Parameter:
code- the codemessage- the message
-
getStatusCode
public int getStatusCode()Returns the status code of this instance. If the status code has never been set by calling thesetStatus(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.- Angegeben von:
getStatusCodein SchnittstelleJakartaPostResponse- Gibt zurück:
- the status code
-
getStatusMessage
Beschreibung aus Schnittstelle kopiert:JakartaPostResponseReturns the status message ornullif no has been set with theJakartaPostResponse.setStatus(int, String)method.- Angegeben von:
getStatusMessagein SchnittstelleJakartaPostResponse- Gibt zurück:
- the status message (might be null)
-
getError
Returns any recorded error ornull- Angegeben von:
getErrorin SchnittstelleJakartaPostResponse- Gibt zurück:
- an error or
null
-
setError
Beschreibung aus Schnittstelle kopiert:JakartaPostResponseSets the recorded error causing the operation to fail.- Angegeben von:
setErrorin SchnittstelleJakartaPostResponse- Parameter:
error- the throwable
-
isSuccessful
public boolean isSuccessful()- Angegeben von:
isSuccessfulin SchnittstelleJakartaPostResponse- Gibt zurück:
- true if the status code is 2xx
-
onModified
Records a 'modified' change- Angegeben von:
onModifiedin SchnittstelleJakartaPostResponse- Parameter:
path- path of the item that was modified
-
onCreated
Records a 'created' change- Angegeben von:
onCreatedin SchnittstelleJakartaPostResponse- Parameter:
path- path of the item that was created
-
onDeleted
Records a 'deleted' change- Angegeben von:
onDeletedin SchnittstelleJakartaPostResponse- Parameter:
path- path of the item that was deleted
-
onMoved
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.
- Angegeben von:
onMovedin SchnittstelleJakartaPostResponse- Parameter:
srcPath- source path of the node that was moveddstPath- destination path of the node that was moved.
-
onCopied
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.
- Angegeben von:
onCopiedin SchnittstelleJakartaPostResponse- Parameter:
srcPath- source path of the node that was copieddstPath- destination path of the node that was copied.
-
setProperty
Sets a generic response property with the given- Parameter:
name- name of the propertyvalue- value of the property
-
getProperty
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.- Typparameter:
Type- the return type- Parameter:
name- the name of the requetested propertytype- the type of the parameter which should be returned- Gibt zurück:
- the property as the requested type or null if not available at all or not in the requested type
-
getProperty
Returns the generic response property with the given name and type ornullif no such property exists.- Parameter:
name- the name of the response property- Gibt zurück:
- the requested property (might be null)
-
isSafeReferer
protected boolean isSafeReferer()determines if the referer has a proper referer including protocol- Gibt zurück:
- true if HTTP or HTTPS protocol information is available in the referer
-
doSend
protected abstract void doSend(jakarta.servlet.http.HttpServletResponse response) throws IOException - Löst aus:
IOException
-
send
public final void send(jakarta.servlet.http.HttpServletResponse response, boolean setStatus) throws 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.- Angegeben von:
sendin SchnittstelleJakartaPostResponse- Parameter:
response- to send tosetStatus- whether to set the status code on the response- Löst aus:
IOException- if an i/o exception occurs
-