public abstract class AbstractPostResponse extends 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 String |
PN_ERROR
Name of the error property set by
setError(Throwable) |
static String |
PN_IS_CREATED
Name of the create status property set by
setCreateRequest(boolean) |
static String |
PN_LOCATION
Name of the location property set by
setLocation(String) |
static String |
PN_PARENT_LOCATION
Name of the parent location property set by
setParentLocation(String) |
static String |
PN_PATH
Name of the path property set by
setPath(String) |
static String |
PN_REFERER
Name of the referer property set by
setReferer(String) |
static String |
PN_STATUS_CODE
Name of the status code property set by
setStatus(int, String) |
static String |
PN_STATUS_MESSAGE
Name of the status message property set by
setStatus(int, String) |
static 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) |
Throwable |
getError()
Returns any recorded error or
null |
String |
getLocation()
Returns the location of the modification.
|
String |
getParentLocation()
Returns the parent location of the modification.
|
String |
getPath()
Returns the absolute path of the item upon which the request operated.
|
protected Object |
getProperty(String name)
Returns the generic response property with the given name and type or
null if no such property exists. |
protected <Type> Type |
getProperty(String name,
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. |
String |
getReferer()
Returns the referer as from the 'referer' request header.
|
int |
getStatusCode()
Returns the status code of this instance.
|
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() |
boolean |
isSuccessful()
|
void |
onCopied(String srcPath,
String dstPath)
Records a 'copied' change.
|
void |
onCreated(String path)
Records a 'created' change
|
void |
onDeleted(String path)
Records a 'deleted' change
|
void |
onModified(String path)
Records a 'modified' change
|
void |
onMoved(String srcPath,
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(Throwable error)
Sets the recorded error causing the operation to fail.
|
void |
setLocation(String location)
Sets the location of this modification.
|
void |
setParentLocation(String parentLocation)
Sets the parent location of the modification.
|
void |
setPath(String path)
Sets the absolute path of the item upon which the request operated.
|
protected void |
setProperty(String name,
Object value)
Sets a generic response property with the given
|
void |
setReferer(String referer)
Sets the referer property
|
void |
setStatus(int code,
String message)
sets the response status code properties
|
void |
setTitle(String title)
Sets the title of the response message
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onChange
public static final String PN_TITLE
setTitle(String)
public static final String PN_STATUS_CODE
setStatus(int, String)
public static final String PN_STATUS_MESSAGE
setStatus(int, String)
public static final String PN_LOCATION
setLocation(String)
public static final String PN_PARENT_LOCATION
setParentLocation(String)
public static final String PN_PATH
setPath(String)
public static final String PN_REFERER
setReferer(String)
public static final String PN_IS_CREATED
setCreateRequest(boolean)
public static final String PN_ERROR
setError(Throwable)
public String getReferer()
getReferer
in interface PostResponse
public void setReferer(String referer)
setReferer
in interface PostResponse
public String getPath()
If the setPath(String)
method has not been called yet, this
method returns null
.
getPath
in interface PostResponse
public void setPath(String path)
setPath
in interface PostResponse
public boolean isCreateRequest()
true
if this was a create request.
Before calling the setCreateRequest(boolean)
method, this method
always returns false
.
isCreateRequest
in interface PostResponse
public void setCreateRequest(boolean isCreateRequest)
setCreateRequest
in interface PostResponse
public String getLocation()
getLocation
in interface PostResponse
public void setLocation(String location)
PostResponse
current path
.setLocation
in interface PostResponse
public String getParentLocation()
getParentLocation
in interface PostResponse
public void setParentLocation(String parentLocation)
PostResponse
current path
.setParentLocation
in interface PostResponse
public void setTitle(String title)
setTitle
in interface PostResponse
title
- the titlepublic void setStatus(int code, 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 String getStatusMessage()
PostResponse
null
if no has been set with
the PostResponse.setStatus(int, String)
method.getStatusMessage
in interface PostResponse
public Throwable getError()
null
getError
in interface PostResponse
null
public void setError(Throwable error)
PostResponse
setError
in interface PostResponse
public boolean isSuccessful()
isSuccessful
in interface PostResponse
public void onModified(String path)
onModified
in interface PostResponse
path
- path of the item that was modifiedpublic void onCreated(String path)
onCreated
in interface PostResponse
path
- path of the item that was createdpublic void onDeleted(String path)
onDeleted
in interface PostResponse
path
- path of the item that was deletedpublic void onMoved(String srcPath, String dstPath)
onMoved
in interface PostResponse
srcPath
- source path of the node that was moveddstPath
- destination path of the node that was moved.public void onCopied(String srcPath, String dstPath)
onCopied
in interface PostResponse
srcPath
- source path of the node that was copieddstPath
- destination path of the node that was copied.protected void setProperty(String name, Object value)
name
- name of the propertyvalue
- value of the propertyprotected <Type> Type getProperty(String name, Class<Type> type)
null
if no such property exists or the property is not of
the requested type.protected Object getProperty(String name)
null
if no such property exists.protected boolean isSafeReferer()
protected abstract void doSend(javax.servlet.http.HttpServletResponse response) throws IOException
IOException
public final void send(javax.servlet.http.HttpServletResponse response, boolean setStatus) throws IOException
send
in interface PostResponse
response
- to send tosetStatus
- whether to set the status code on the responseIOException
- if an i/o exception occursCopyright © 2015 The Apache Software Foundation. All rights reserved.