public abstract class AbstractPostResponse extends java.lang.Object implements PostResponse
AbstractPostResponse
class provides a basic implementation
of the PostResponse
interface maintaining properties to be
prepared for sending the response in an internal map.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PN_ERROR
Name of the error property set by
setError(Throwable) |
static java.lang.String |
PN_IS_CREATED
Name of the create status property set by
setCreateRequest(boolean) |
static java.lang.String |
PN_LOCATION
Name of the location property set by
setLocation(String) |
static java.lang.String |
PN_PARENT_LOCATION
Name of the parent location property set by
setParentLocation(String) |
static java.lang.String |
PN_PATH
Name of the path property set by
setPath(String) |
static java.lang.String |
PN_REFERER
Name of the referer property set by
setReferer(String) |
static java.lang.String |
PN_STATUS_CODE
Name of the status code property set by
setStatus(int, String) |
static java.lang.String |
PN_STATUS_MESSAGE
Name of the status message property set by
setStatus(int, String) |
static java.lang.String |
PN_TITLE
Name of the title property set by
setTitle(String) |
Constructor and Description |
---|
AbstractPostResponse() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
doSend(javax.servlet.http.HttpServletResponse response) |
java.lang.Throwable |
getError()
Returns any recorded error or
null |
java.lang.String |
getLocation()
Returns the location of the modification.
|
java.lang.String |
getParentLocation()
Returns the parent location of the modification.
|
java.lang.String |
getPath()
Returns the absolute path of the item upon which the request operated.
|
protected java.lang.Object |
getProperty(java.lang.String name)
Returns the generic response property with the given name and type or
null if no such property exists. |
protected <Type> Type |
getProperty(java.lang.String name,
java.lang.Class<Type> type)
Returns the generic response property with the given name and type or
null if no such property exists or the property is not of
the requested type. |
java.lang.String |
getReferer()
Returns the referer previously set by
PostResponse.setReferer(String) |
int |
getStatusCode()
Returns the status code of this instance.
|
java.lang.String |
getStatusMessage()
Returns the status message or
null if no has been set with
the PostResponse.setStatus(int, String) method. |
boolean |
isCreateRequest()
Returns
true if this was a create request. |
protected boolean |
isSafeReferer()
determines if the referer has a proper referer including protocol
|
boolean |
isSuccessful()
|
void |
onCopied(java.lang.String srcPath,
java.lang.String dstPath)
Records a 'copied' change.
|
void |
onCreated(java.lang.String path)
Records a 'created' change
|
void |
onDeleted(java.lang.String path)
Records a 'deleted' change
|
void |
onModified(java.lang.String path)
Records a 'modified' change
|
void |
onMoved(java.lang.String srcPath,
java.lang.String dstPath)
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.
|
void |
setCreateRequest(boolean isCreateRequest)
Sets whether the request was a create request or not.
|
void |
setError(java.lang.Throwable error)
Sets the recorded error causing the operation to fail.
|
void |
setLocation(java.lang.String location)
Sets the location of this modification.
|
void |
setParentLocation(java.lang.String parentLocation)
Sets the parent location of the modification.
|
void |
setPath(java.lang.String path)
Sets the absolute path of the item upon which the request operated.
|
protected void |
setProperty(java.lang.String name,
java.lang.Object value)
Sets a generic response property with the given
|
void |
setReferer(java.lang.String referer)
Sets the referer property
|
void |
setStatus(int code,
java.lang.String message)
sets the response status code properties
|
void |
setTitle(java.lang.String title)
Sets the title of the response message
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onChange
public static final java.lang.String PN_TITLE
setTitle(String)
public static final java.lang.String PN_STATUS_CODE
setStatus(int, String)
public static final java.lang.String PN_STATUS_MESSAGE
setStatus(int, String)
public static final java.lang.String PN_LOCATION
setLocation(String)
public static final java.lang.String PN_PARENT_LOCATION
setParentLocation(String)
public static final java.lang.String PN_PATH
setPath(String)
public static final java.lang.String PN_REFERER
setReferer(String)
public static final java.lang.String PN_IS_CREATED
setCreateRequest(boolean)
public static final java.lang.String PN_ERROR
setError(Throwable)
public java.lang.String getReferer()
PostResponse.setReferer(String)
getReferer
in interface PostResponse
public void setReferer(java.lang.String referer)
setReferer
in interface PostResponse
referer
- the refererpublic java.lang.String getPath()
If the PostResponse.setPath(String)
method has not been called yet, this
method returns null
.
getPath
in interface PostResponse
public void setPath(java.lang.String path)
setPath
in interface PostResponse
path
- the pathpublic boolean isCreateRequest()
true
if this was a create request.
Before calling the PostResponse.setCreateRequest(boolean)
method, this method
always returns false
.
isCreateRequest
in interface PostResponse
public void setCreateRequest(boolean isCreateRequest)
setCreateRequest
in interface PostResponse
isCreateRequest
- true if the request was a create requestpublic java.lang.String getLocation()
If the PostResponse.setLocation(String)
method has not been called yet, this
method returns null
.
getLocation
in interface PostResponse
public void setLocation(java.lang.String location)
PostResponse
current path
.setLocation
in interface PostResponse
location
- the locationpublic java.lang.String getParentLocation()
getParentLocation
in interface PostResponse
public void setParentLocation(java.lang.String parentLocation)
PostResponse
current path
.setParentLocation
in interface PostResponse
parentLocation
- the parent location of the modificationpublic void setTitle(java.lang.String title)
setTitle
in interface PostResponse
title
- the titlepublic void setStatus(int code, java.lang.String message)
setStatus
in interface PostResponse
code
- the codemessage
- the messagepublic int getStatusCode()
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.getStatusCode
in interface PostResponse
public java.lang.String getStatusMessage()
PostResponse
null
if no has been set with
the PostResponse.setStatus(int, String)
method.getStatusMessage
in interface PostResponse
public java.lang.Throwable getError()
null
getError
in interface PostResponse
null
public void setError(java.lang.Throwable error)
PostResponse
setError
in interface PostResponse
error
- the throwablepublic boolean isSuccessful()
isSuccessful
in interface PostResponse
public void onModified(java.lang.String path)
onModified
in interface PostResponse
path
- path of the item that was modifiedpublic void onCreated(java.lang.String path)
onCreated
in interface PostResponse
path
- path of the item that was createdpublic void onDeleted(java.lang.String path)
onDeleted
in interface PostResponse
path
- path of the item that was deletedpublic void onMoved(java.lang.String srcPath, java.lang.String dstPath)
Note: the moved change only records the basic move command. the implied changes on the moved properties and sub nodes are not recorded.
onMoved
in interface PostResponse
srcPath
- source path of the node that was moveddstPath
- destination path of the node that was moved.public void onCopied(java.lang.String srcPath, java.lang.String dstPath)
Note: the copy change only records the basic copy command. the implied changes on the copied properties and sub nodes are not recorded.
onCopied
in interface PostResponse
srcPath
- source path of the node that was copieddstPath
- destination path of the node that was copied.protected void setProperty(java.lang.String name, java.lang.Object value)
name
- name of the propertyvalue
- value of the propertyprotected <Type> Type getProperty(java.lang.String name, java.lang.Class<Type> type)
null
if no such property exists or the property is not of
the requested type.Type
- the return typename
- the name of the requetested propertytype
- the type of the parameter which should be returnedprotected java.lang.Object getProperty(java.lang.String name)
null
if no such property exists.name
- the name of the response propertyprotected boolean isSafeReferer()
protected abstract void doSend(javax.servlet.http.HttpServletResponse response) throws java.io.IOException
java.io.IOException
public final void send(javax.servlet.http.HttpServletResponse response, boolean setStatus) throws java.io.IOException
send
in interface PostResponse
response
- to send tosetStatus
- whether to set the status code on the responsejava.io.IOException
- if an i/o exception occursCopyright © 2022 The Apache Software Foundation. All rights reserved.