|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.sling.api.servlets.HtmlResponse
public class HtmlResponse
Generator for a HTML status response that displays the changes made in a post request. see HtmlResponse.html for the format.
Field Summary | |
---|---|
static java.lang.String |
PN_CHANGE_LOG
human readable changelog |
static java.lang.String |
PN_ERROR
The Throwable caught while processing the request. |
static java.lang.String |
PN_IS_CREATED
Indicating whether request processing created new data. |
static java.lang.String |
PN_LOCATION
externally mapped location url of the modified path |
static java.lang.String |
PN_PARENT_LOCATION
externally mapped location url of the parent of the modified path |
static java.lang.String |
PN_PATH
the path of the modified item. this is usually the addressed resource or in case of a creation request (eg: /foo/*) the path of the newly created node. |
static java.lang.String |
PN_REFERER
the referrer of the request |
static java.lang.String |
PN_STATUS_CODE
status code. more or less http response status codes |
static java.lang.String |
PN_STATUS_MESSAGE
some human readable status message |
static java.lang.String |
PN_TITLE
some human readable title like: 200 Created /foo/bar |
Constructor Summary | |
---|---|
HtmlResponse()
Creates a new html response with default settings, which is null for almost all properties except the
isCreateRequest() which defaults to false . |
Method Summary | ||
---|---|---|
java.lang.Throwable |
getError()
Returns any recorded error or null |
|
java.lang.String |
getLocation()
Returns the location of the modification. this is the externalized form of the current path. |
|
java.lang.String |
getParentLocation()
Returns the parent location of the modification. this is the externalized form of the parent node of the current path. |
|
java.lang.String |
getPath()
Returns the absolute path of the item upon which the request operated. |
|
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. |
|
|
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 as from the 'referer' request header. |
|
int |
getStatusCode()
Returns the status code of this instance. |
|
java.lang.String |
getStatusMessage()
|
|
boolean |
isCreateRequest()
Returns true if this was a create request. |
|
boolean |
isSuccessful()
Returns true if no error is set and if
the status code is one of the 2xx codes. |
|
void |
onChange(java.lang.String type,
java.lang.String... arguments)
Records a generic change of the given type . |
|
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. if the property is not defined the pattern is not modified. |
|
void |
setCreateRequest(boolean isCreateRequest)
Sets whether the request was a create request or not. |
|
void |
setError(java.lang.Throwable error)
|
|
void |
setLocation(java.lang.String location)
|
|
void |
setParentLocation(java.lang.String parentLocation)
|
|
void |
setPath(java.lang.String path)
Sets the absolute path of the item upon which the request operated. |
|
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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String PN_TITLE
public static final java.lang.String PN_STATUS_CODE
public static final java.lang.String PN_STATUS_MESSAGE
public static final java.lang.String PN_LOCATION
public static final java.lang.String PN_PARENT_LOCATION
public static final java.lang.String PN_PATH
public static final java.lang.String PN_REFERER
public static final java.lang.String PN_IS_CREATED
false
and may be changed by calling
the setCreateRequest(boolean)
method.
public static final java.lang.String PN_CHANGE_LOG
public static final java.lang.String PN_ERROR
setError(Throwable)
method is called.
Constructor Detail |
---|
public HtmlResponse()
null
for almost all properties except the
isCreateRequest()
which defaults to false
.
Method Detail |
---|
public java.lang.String getReferer()
public void setReferer(java.lang.String referer)
public java.lang.String getPath()
If the setPath(String)
method has not been called yet, this
method returns null
.
public void setPath(java.lang.String path)
public boolean isCreateRequest()
true
if this was a create request.
Before calling the setCreateRequest(boolean)
method, this method
always returns false
.
public void setCreateRequest(boolean isCreateRequest)
public java.lang.String getLocation()
public void setLocation(java.lang.String location)
public java.lang.String getParentLocation()
public void setParentLocation(java.lang.String parentLocation)
public void setTitle(java.lang.String title)
title
- the titlepublic void setStatus(int code, java.lang.String message)
code
- the codemessage
- the messagepublic int getStatusCode()
setStatus(int, String)
method, the
response is assumed to be successful and 200 is returned.
public java.lang.String getStatusMessage()
public java.lang.Throwable getError()
null
null
public void setError(java.lang.Throwable error)
public boolean isSuccessful()
true
if no error
is set and if
the status code
is one of the 2xx codes.
public void onModified(java.lang.String path)
path
- path of the item that was modifiedpublic void onCreated(java.lang.String path)
path
- path of the item that was createdpublic void onDeleted(java.lang.String path)
path
- path of the item that was deletedpublic void onMoved(java.lang.String srcPath, java.lang.String dstPath)
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)
srcPath
- source path of the node that was copieddstPath
- destination path of the node that was copied.public void onChange(java.lang.String type, java.lang.String... arguments)
type
.
The change is added to the internal list of changes with the syntax of a
method call, where the type
is the method name and the
arguments
are the string arguments to the method enclosed in
double quotes. For example, the the call
onChange("sameple", "arg1", "arg2");is aded as
sample("arg1", "arg2")to the internal list of changes.
type
- The type of the modificationarguments
- The arguments to the modificationspublic void setProperty(java.lang.String name, java.lang.Object value)
name
- name of the propertyvalue
- value of the propertypublic <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.
public java.lang.Object getProperty(java.lang.String name)
null
if no such property exists.
public void send(javax.servlet.http.HttpServletResponse response, boolean setStatus) throws java.io.IOException
response
- to send tosetStatus
- whether to set the status code on the response
java.io.IOException
- if an i/o exception occurs
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |