com.jalios.jcms.rest
Class RestUtil
java.lang.Object
com.jalios.jcms.rest.RestUtil
public class RestUtil
- extends Object
Provides utility static methods for both client and server side in REST communication.
- Since:
- JCMS-6.0
- Author:
- dissert
Method Summary |
static void |
displayResponse(org.restlet.data.Response response)
|
static String |
formatMsgToXml(javax.servlet.http.HttpServletRequest request)
Get the info, warning and error messages in the request and in the session and
returns a xml with all this informations. |
static String |
formatMsgToXml(javax.servlet.http.HttpServletRequest request,
boolean displayInfo,
boolean displayWarning,
boolean displayError)
Get the info, warning and error messages in the request and in the session and
returns a xml with all this informations. |
static String |
formatXmlEntityError(String code,
String message)
|
static boolean |
isRest(javax.servlet.http.HttpServletRequest request)
|
static void |
sendApplicationError(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Get the messages in request or in session and put it formatted in the entity body of the response
and set CLIENT_ERROR_BAD_REQUEST (400) HTTP error code. |
static void |
sendDetailedError(javax.servlet.http.HttpServletResponse response,
int errorCode,
String applicationErrorCode,
String applicationErrorMessage)
|
static void |
sendError(javax.servlet.http.HttpServletResponse response,
int errorCode)
|
static void |
sendError(javax.servlet.http.HttpServletResponse response,
int errorCode,
String message)
|
static void |
sendError(javax.servlet.http.HttpServletResponse response,
org.restlet.data.Status error)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
XML_UTF_8_STANDARD_BOM
public static final String XML_UTF_8_STANDARD_BOM
- See Also:
- Constant Field Values
RestUtil
public RestUtil()
isRest
public static final boolean isRest(javax.servlet.http.HttpServletRequest request)
sendError
public static void sendError(javax.servlet.http.HttpServletResponse response,
org.restlet.data.Status error)
throws IOException
- Throws:
IOException
sendError
public static void sendError(javax.servlet.http.HttpServletResponse response,
int errorCode,
String message)
throws IOException
- Throws:
IOException
sendError
public static void sendError(javax.servlet.http.HttpServletResponse response,
int errorCode)
throws IOException
- Throws:
IOException
sendDetailedError
public static void sendDetailedError(javax.servlet.http.HttpServletResponse response,
int errorCode,
String applicationErrorCode,
String applicationErrorMessage)
throws IOException
- Throws:
IOException
formatXmlEntityError
public static String formatXmlEntityError(String code,
String message)
displayResponse
public static void displayResponse(org.restlet.data.Response response)
throws IOException
- Throws:
IOException
formatMsgToXml
public static String formatMsgToXml(javax.servlet.http.HttpServletRequest request)
- Get the info, warning and error messages in the request and in the session and
returns a xml with all this informations.
The form of the XML is as follow :
message in the lang of the current logged member
message in the lang of the current logged member
message in the lang of the current logged member
message in the lang of the current logged member
message in the lang of the current logged member
message in the lang of the current logged member
If an XML element would be empty, it is not set.
- Parameters:
request
- the current request
- Returns:
- the formatted xml message.
formatMsgToXml
public static String formatMsgToXml(javax.servlet.http.HttpServletRequest request,
boolean displayInfo,
boolean displayWarning,
boolean displayError)
- Get the info, warning and error messages in the request and in the session and
returns a xml with all this informations.
But info, warning or error level messages may be skipped.
- Parameters:
request
- the current requestdisplayInfo
- if false, info message is skippeddisplayWarning
- if false, warning message is skippeddisplayError
- if false, error message is skipped
- Returns:
- the formatted message
sendApplicationError
public static void sendApplicationError(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws IOException
- Get the messages in request or in session and put it formatted in the entity body of the response
and set CLIENT_ERROR_BAD_REQUEST (400) HTTP error code.
- Parameters:
request
- the current requestresponse
- the current response
- Throws:
IOException
- if the printer is innaccessible
Copyright © 2001-2007 Jalios SA. All Rights Reserved.