Interface PostResponse
-
- All Known Implementing Classes:
AbstractPostResponse,AbstractPostResponseWrapper,HtmlResponse,HtmlResponse,JSONResponse
public interface PostResponseThePostResponseinterface defines the API of a response container which can (and should) be used byPostOperationservices to prepare responses to be sent back to the client.This bundle provides a preconfigured
HtmlResponseand aJSONResponseimplementation of this interface. Clients may extend theAbstractPostResponseclass to provide their own response implementations.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.ThrowablegetError()Returns any recorded error ornulljava.lang.StringgetLocation()Returns the location of the modification.java.lang.StringgetParentLocation()Returns the parent location of the modification.java.lang.StringgetPath()Returns the absolute path of the item upon which the request operated.java.lang.StringgetReferer()Returns the referer previously set bysetReferer(String)intgetStatusCode()Returns the status code of this instance.java.lang.StringgetStatusMessage()Returns the status message ornullif no has been set with thesetStatus(int, String)method.booleanisCreateRequest()Returnstrueif this was a create request.booleanisSuccessful()voidonChange(java.lang.String type, java.lang.String... arguments)Records a generic change of the giventypewith arguments.voidonCopied(java.lang.String srcPath, java.lang.String dstPath)Records a 'copied' change.voidonCreated(java.lang.String path)Records a 'created' changevoidonDeleted(java.lang.String path)Records a 'deleted' changevoidonModified(java.lang.String path)Records a 'modified' changevoidonMoved(java.lang.String srcPath, java.lang.String dstPath)Records a 'moved' change.voidsend(HttpServletResponse response, boolean setStatus)Writes the response back over the provided HTTP channel.voidsetCreateRequest(boolean isCreateRequest)Sets whether the request was a create request or not.voidsetError(java.lang.Throwable error)Sets the recorded error causing the operation to fail.voidsetLocation(java.lang.String location)Sets the location of this modification.voidsetParentLocation(java.lang.String parentLocation)Sets the parent location of the modification.voidsetPath(java.lang.String path)Sets the absolute path of the item upon which the request operated.voidsetReferer(java.lang.String referer)Sets the referer propertyvoidsetStatus(int code, java.lang.String message)Sets the response status code propertiesvoidsetTitle(java.lang.String title)Sets the title of the response message
-
-
-
Method Detail
-
setReferer
void setReferer(java.lang.String referer)
Sets the referer property- Parameters:
referer- the referer
-
getReferer
java.lang.String getReferer()
Returns the referer previously set bysetReferer(String)- Returns:
- the referer
-
setPath
void setPath(java.lang.String path)
Sets the absolute path of the item upon which the request operated.- Parameters:
path- the path
-
getPath
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 returnsnull.- Returns:
- the path (might be null)
-
setCreateRequest
void setCreateRequest(boolean isCreateRequest)
Sets whether the request was a create request or not.- Parameters:
isCreateRequest- true if the request was a create request
-
isCreateRequest
boolean isCreateRequest()
Returnstrueif this was a create request.Before calling the
setCreateRequest(boolean)method, this method always returnsfalse.- Returns:
- if this was a create request
-
setLocation
void setLocation(java.lang.String location)
Sets the location of this modification. This is the externalized form of thecurrent path.- Parameters:
location- the location
-
getLocation
java.lang.String getLocation()
Returns the location of the modification.If the
setLocation(String)method has not been called yet, this method returnsnull.- Returns:
- the location
-
setParentLocation
void setParentLocation(java.lang.String parentLocation)
Sets the parent location of the modification. This is the externalized form of the parent node of thecurrent path.- Parameters:
parentLocation- the parent location of the modification
-
getParentLocation
java.lang.String getParentLocation()
Returns the parent location of the modification.If the
setParentLocation(String)method has not been called yet, this method returnsnull.- Returns:
- the parent location
-
setTitle
void setTitle(java.lang.String title)
Sets the title of the response message- Parameters:
title- the title
-
setStatus
void setStatus(int code, java.lang.String message)Sets the response status code properties- Parameters:
code- the codemessage- the message
-
getStatusCode
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.- Returns:
- the status code
-
getStatusMessage
java.lang.String getStatusMessage()
Returns the status message ornullif no has been set with thesetStatus(int, String)method.- Returns:
- the status message (might be null)
-
setError
void setError(java.lang.Throwable error)
Sets the recorded error causing the operation to fail.- Parameters:
error- the throwable
-
getError
java.lang.Throwable getError()
Returns any recorded error ornull- Returns:
- an error or
null
-
isSuccessful
boolean isSuccessful()
- Returns:
- true if the status code is 2xx
-
onCreated
void onCreated(java.lang.String path)
Records a 'created' change- Parameters:
path- path of the item that was created
-
onModified
void onModified(java.lang.String path)
Records a 'modified' change- Parameters:
path- path of the item that was modified
-
onDeleted
void onDeleted(java.lang.String path)
Records a 'deleted' change- Parameters:
path- path of the item that was deleted
-
onMoved
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.
- Parameters:
srcPath- source path of the node that was moveddstPath- destination path of the node that was moved.
-
onCopied
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.
- Parameters:
srcPath- source path of the node that was copieddstPath- destination path of the node that was copied.
-
onChange
void onChange(java.lang.String type, java.lang.String... arguments)Records a generic change of the giventypewith arguments.- Parameters:
type- The type of the modificationarguments- The arguments to the modifications
-
send
void send(HttpServletResponse response, boolean setStatus) throws java.io.IOException
Writes the response back over the provided HTTP channel. The actual format of the response is implementation dependent.- Parameters:
response- to send tosetStatus- whether to set the status code on the response- Throws:
java.io.IOException- if an i/o exception occurs
-
-