Class ServletCall
- java.lang.Object
-
- org.bonitasoft.engine.api.internal.servlet.ServletCall
-
- Direct Known Subclasses:
HttpAPIServletCall
public abstract class ServletCall extends java.lang.Object- Author:
- Severin Moussel
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,java.lang.String>parametersThe parameters of the URL.
Result of the parsing of the query string : "?a=b&c=d&..."
-
Constructor Summary
Constructors Constructor Description ServletCall(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Default constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intcountParameters()Count the number of parameters passed in the URLjava.lang.Objectdeserialize(byte[] bytes)abstract voiddoDelete()Entry point for DELETEabstract voiddoGet()Entry point for GET and SEARCHabstract voiddoPost()Entry point for CREATEabstract voiddoPut()Entry point for UPDATEprotected voiderror(java.lang.String message, int errorCode)java.util.List<byte[]>getBinaryParameters()javax.servlet.http.HttpSessiongetHttpSession()Get the current call's HttpSessionjava.lang.StringgetInputStream()Read the input stream and set it in a Stringjava.lang.StringgetParameter(java.lang.String name)Get a parameter first value by its namejava.lang.StringgetParameter(java.lang.String name, java.lang.String defaultValue)Get a parameter first value by its namejava.util.List<java.lang.String>getParameterAsList(java.lang.String name)Get a parameter values by its namejava.util.List<java.lang.String>getParameterAsList(java.lang.String name, java.lang.String defaultValue)Get a parameter values by its namejava.lang.StringgetQueryString()java.lang.StringgetRequestURL()Reconstruct the URL the client used to make the request.protected java.lang.StringgetResponseContentType()protected voidhead(java.lang.String name, java.lang.String value)Write into the output header.protected voidoutput(java.io.File file)Output a fileprotected voidoutput(java.io.InputStream stream)Output a stream as a fileprotected voidoutput(java.io.InputStream stream, java.lang.String filename)Output a stream as a fileprotected voidoutput(java.lang.Object object)Write into the outputprotected voidoutput(java.lang.String string)Write into the outputbyte[]serialize(java.lang.Object obj)
-
-
-
Constructor Detail
-
ServletCall
public ServletCall(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws org.apache.commons.fileupload.FileUploadException, java.io.IOExceptionDefault constructor.- Parameters:
request- The request made to access this servletCall.response- The response to return.- Throws:
java.io.IOExceptionorg.apache.commons.fileupload.FileUploadException
-
-
Method Detail
-
getBinaryParameters
public java.util.List<byte[]> getBinaryParameters()
- Returns:
- the binaryParameters
-
serialize
public byte[] serialize(java.lang.Object obj) throws java.io.IOException- Throws:
java.io.IOException
-
deserialize
public java.lang.Object deserialize(byte[] bytes) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
getHttpSession
public javax.servlet.http.HttpSession getHttpSession()
Get the current call's HttpSession- Returns:
- This method returns the session from the current call.
-
getQueryString
public java.lang.String getQueryString()
- See Also:
HttpServletRequest.getQueryString()
-
getRequestURL
public final java.lang.String getRequestURL()
Reconstruct the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters.- Returns:
- This method returns the reconstructed URL
-
getInputStream
public final java.lang.String getInputStream()
Read the input stream and set it in a String
-
countParameters
public final int countParameters()
Count the number of parameters passed in the URL- Returns:
- This method returns the number of parameters in the URL
-
getParameterAsList
public final java.util.List<java.lang.String> getParameterAsList(java.lang.String name)
Get a parameter values by its name- Parameters:
name- The name of the parameter (case sensitive)- Returns:
- This method returns the values of a parameter as a list of String or null if the parameter isn't defined
-
getParameterAsList
public final java.util.List<java.lang.String> getParameterAsList(java.lang.String name, java.lang.String defaultValue)Get a parameter values by its name- Parameters:
name- The name of the parameter (case sensitive)defaultValue- The value to return if the parameter isn't define- Returns:
- This method returns the values of a parameter as a list of String
-
getParameter
public final java.lang.String getParameter(java.lang.String name)
Get a parameter first value by its name- Parameters:
name- The name of the parameter (case sensitive)- Returns:
- This method returns the first value of a parameter as a String or null if the parameter isn't define
-
getParameter
public final java.lang.String getParameter(java.lang.String name, java.lang.String defaultValue)Get a parameter first value by its name- Parameters:
name- The name of the parameter (case sensitive)defaultValue- The value to return if the parameter isn't define- Returns:
- This method returns the first value of a parameter as a String
-
head
protected final void head(java.lang.String name, java.lang.String value)Write into the output header.- Parameters:
name- The name of the header to write.value- The value of the header to write.
-
output
protected final void output(java.io.File file)
Output a file- Parameters:
file- The file to output
-
output
protected void output(java.io.InputStream stream, java.lang.String filename)Output a stream as a file- Parameters:
stream- The stream to outputfilename- The name of the file to retrieve with the stream.
-
output
protected void output(java.io.InputStream stream)
Output a stream as a file- Parameters:
stream- The stream to output
-
error
protected void error(java.lang.String message, int errorCode)
-
output
protected final void output(java.lang.String string)
Write into the output- Parameters:
string- The string to output
-
output
protected final void output(java.lang.Object object)
Write into the output- Parameters:
object- An object that will be transform into JSon
-
getResponseContentType
protected java.lang.String getResponseContentType()
-
doGet
public abstract void doGet()
Entry point for GET and SEARCH
-
doPost
public abstract void doPost()
Entry point for CREATE
-
doPut
public abstract void doPut()
Entry point for UPDATE
-
doDelete
public abstract void doDelete()
Entry point for DELETE
-
-