public class ControllerHelper extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ATTRIBUTE_NAME_ERROR_PAGE_CUSTOM_MESSAGE
Name of the request attribute to provide a custom localized error message.
|
static String |
ATTRIBUTE_NAME_ERROR_PAGE_NEXT_TARGET
Name of the request attribute to provide the target URL for the "Next" button on the error
page
|
Modifier and Type | Method and Description |
---|---|
static String |
appendTimestamp(String url,
String urlPath)
Append a timestamp to the given URL.
|
static void |
dumpSession(javax.servlet.http.HttpServletRequest request)
Dumps the session.
|
static void |
forwardRequest(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
String urlPath)
Makes a forward on the current client to the specified relative URL path.
|
static String |
getRssFeedLink(RssSupportWidget rssSupportWidget)
Gets the rss feed link.
|
static org.springframework.web.servlet.ModelAndView |
prepareModelAndViewForJsonResponse(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
org.codehaus.jackson.node.ObjectNode json,
boolean writeJsonDirectly)
Prepare a model and view with a view named "core.ajax.response".
|
static String |
renderAbsoluteUrl(javax.servlet.http.HttpServletRequest request,
String clientId,
String urlPath,
boolean forceHttps,
boolean staticResource,
boolean staticResourceByDispatcher)
Renders an absolute URL for the provided URL path.
|
static String |
renderAbsoluteUrl(javax.servlet.http.HttpServletRequest request,
String clientId,
String urlPath,
boolean forceHttps,
ChannelType channelTyp,
boolean staticResource,
boolean staticResourceByDispatcher)
Renders an absolute URL for the provided URL path.
|
static String |
renderAbsoluteUrlIgnoreRequestProtocol(javax.servlet.http.HttpServletRequest request,
String clientId,
String urlPath,
boolean forceHttps,
boolean staticResource,
boolean staticResourceByDispatcher)
Renders an absolute URL for the provided URL path.
|
static String |
renderRelativeUrl(javax.servlet.http.HttpServletRequest request,
String urlPath,
boolean staticResource,
boolean staticResourceByDispatcher)
Renders a relative URL for the provided URL path that leads to the referenced resource on the
current client.
|
static String |
renderRelativeUrl(javax.servlet.http.HttpServletRequest request,
String clientId,
String urlPath,
boolean staticResource,
boolean staticResourceByDispatcher)
Renders a relative URL for the provided URL path that leads to the referenced resource on the
given client.
|
static String |
renderUrl(javax.servlet.http.HttpServletRequest request,
String urlPath,
String baseUrl,
boolean absolute,
boolean secure,
Boolean renderSessionId,
String clientId,
boolean staticResource,
boolean staticResourceByDispatcher)
Renders the URL for the specified urlPath.
|
static org.springframework.web.servlet.ModelAndView |
replaceModuleInMAV(org.springframework.web.servlet.ModelAndView mav)
Replace 'MODULE' in the view name of the MAV with the current module.
|
static String |
replaceModuleInViewName(String viewName)
Replace the module in the view name.
|
static void |
sendInternalRedirect(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String relativeUrl)
Send a redirect within the web application.
|
static void |
sendInternalRedirect(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String clientId,
String relativeUrl)
Send a redirect within the web application.
|
static void |
sendInternalRedirectToLogoutUrl(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Sends a redirect to the logout URL of the current client.
|
static void |
sendInternalRedirectToStartPage(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Send a redirect within the web application.
|
static void |
sendRedirect(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String url)
Send a redirect using the provided URL.
|
static void |
setApplicationFailure(javax.servlet.http.HttpServletResponse response)
Sets the application failure.
|
static void |
setApplicationSuccess(javax.servlet.http.HttpServletResponse response)
Sets the application success.
|
public static final String ATTRIBUTE_NAME_ERROR_PAGE_NEXT_TARGET
public static final String ATTRIBUTE_NAME_ERROR_PAGE_CUSTOM_MESSAGE
public static String appendTimestamp(String url, String urlPath)
url
- The URL to append the timestamp to.urlPath
- The URL path which was used for generating the URL. Can be null to force usage of
the build timestamp.public static void dumpSession(javax.servlet.http.HttpServletRequest request)
request
- the requestpublic static void forwardRequest(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, String urlPath) throws javax.servlet.ServletException, IOException
request
- the current request to be forwardedresponse
- the response for forwardingurlPath
- path leading to the target resource. Client and module information will be added.IOException
- in case the forward failsjavax.servlet.ServletException
- in case the forward failspublic static String getRssFeedLink(RssSupportWidget rssSupportWidget)
rssSupportWidget
- the rss support widgetpublic static org.springframework.web.servlet.ModelAndView prepareModelAndViewForJsonResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.codehaus.jackson.node.ObjectNode json, boolean writeJsonDirectly) throws IOException
request
- the current requestresponse
- the responsejson
- the JSON to writewriteJsonDirectly
- whether to write the JSON directly or let the view handle it. In case this is
false the view must check for the attribute htmlResponse and if set to false
directly write the JSON object.IOException
- in case of an exception while serializing the JSON object to the responsepublic static String renderAbsoluteUrl(javax.servlet.http.HttpServletRequest request, String clientId, String urlPath, boolean forceHttps, boolean staticResource, boolean staticResourceByDispatcher)
ChannelManagement.isForceSsl()
returns true or
the current request was received via HTTPS. If the latter condition does not hold but one of
the others does, the returned URL might still be using the HTTP protocol if the property
ApplicationProperty.WEB_HTTPS_SUPPORTED
is set to false.request
- the current requestclientId
- the client ID to include. Can be null which will lead to including the ID of the
current client.urlPath
- the URL path referencing a resource. The path doesn't have to start with a '/' and
can be null.forceHttps
- whether to force an HTTPS URLstaticResource
- true if the url should be rendered as a resource not to be delivered by the
dispatcher servletstaticResourceByDispatcher
- true if the url should be rendered as a resource BUT delivered by the dispatcher
servlet (see KenmeiForwardFilter)public static String renderAbsoluteUrl(javax.servlet.http.HttpServletRequest request, String clientId, String urlPath, boolean forceHttps, ChannelType channelTyp, boolean staticResource, boolean staticResourceByDispatcher)
ChannelManagement#isForceSsl(ChannelType))
returns true for the provided channel or
the current request was received via HTTPS. If the latter condition does not hold but one of
the others does, the returned URL might still be using the HTTP protocol if the property
ApplicationProperty.WEB_HTTPS_SUPPORTED
is set to false.request
- the current requestclientId
- the client ID to include. Can be null which will lead to including the ID of the
current client.urlPath
- the URL path referencing a resource. The path doesn't have to start with a '/' and
can be null.forceHttps
- whether to force an HTTPS URLchannelTyp
- the channel to check for a forced SSL connection, instead of using the current
channelstaticResource
- true if the url should be rendered as a resource not to be delivered by the
dispatcher servletstaticResourceByDispatcher
- true if the url should be rendered as a resource BUT delivered by the dispatcher
servlet (see KenmeiForwardFilter)public static String renderAbsoluteUrlIgnoreRequestProtocol(javax.servlet.http.HttpServletRequest request, String clientId, String urlPath, boolean forceHttps, boolean staticResource, boolean staticResourceByDispatcher)
ChannelManagement.isForceSsl()
returns true.
the returned URL might still be using the HTTP protocol if the property
ApplicationProperty.WEB_HTTPS_SUPPORTED
is set to false. In contrast to
#renderAbsoluteUrl(HttpServletRequest, String, String, boolean)
the protocol used for
the current request will not be evaluated.request
- the current requestclientId
- the client ID to include. Can be null which will lead to including the ID of the
current client.urlPath
- the URL path referencing a resource. The path doesn't have to start with a '/' and
can be null.forceHttps
- whether to force an HTTPS URLstaticResource
- true if the url should be rendered as a resource not to be delivered by the
dispatcher servletstaticResourceByDispatcher
- true if the url should be rendered as a resource BUT delivered by the dispatcher
servlet (see KenmeiForwardFilter)public static String renderRelativeUrl(javax.servlet.http.HttpServletRequest request, String urlPath, boolean staticResource, boolean staticResourceByDispatcher)
request
- the current requesturlPath
- the URL path referencing a resource. The path doesn't have to start with a '/' and
can be null.staticResource
- true if the url should be rendered as a resource not to be delivered by the
dispatcher servletstaticResourceByDispatcher
- true if the url should be rendered as a resource BUT delivered by the dispatcher
servlet (see KenmeiForwardFilter)public static String renderRelativeUrl(javax.servlet.http.HttpServletRequest request, String clientId, String urlPath, boolean staticResource, boolean staticResourceByDispatcher)
request
- the current requestclientId
- the client ID to include. Can be null which will lead to including the ID of the
current client.urlPath
- the URL path referencing a resource. The path doesn't have to start with a '/' and
can be null.staticResource
- true if the URL should be rendered as a resource which will not be delivered by
the dispatcher servletstaticResourceByDispatcher
- true if the url should be rendered as a resource BUT delivered by the dispatcher
servlet (see KenmeiForwardFilter)public static String renderUrl(javax.servlet.http.HttpServletRequest request, String urlPath, String baseUrl, boolean absolute, boolean secure, Boolean renderSessionId, String clientId, boolean staticResource, boolean staticResourceByDispatcher)
request
- the current request to retrieve session dataurlPath
- the URL pathbaseUrl
- optional string with a URL that should be prefixed to the urlPath. If set, the
parameters absolute, secure and clientId will be ignored.absolute
- whether the URL should be rendered as an absolute URL. Will be ignored if baseUrl
is not null.secure
- whether the URL should be rendered with the HTTPS protocol. Will be ignored if
absolute is false or baseUrl is not null.renderSessionId
- optional parameter to force inclusion of the current session ID. If null the
session ID will be included if the request asked for an existing session and the
session ID was not received via a cookie. If not null and true the ID of the
current session will be included. In case there is no session the session will be
created. If baseUrl is not null the session ID won't be included.clientId
- the ID of the client to be included in the URL. If null the ID of the current
client will be used. Will be ignored if baseUrl is not null.staticResource
- true if the url should be rendered as a resource not to be delivered by the
dispatcher servletstaticResourceByDispatcher
- true if the url should be rendered as a resource BUT delivered by the dispatcher
servlet (see KenmeiForwardFilter)public static org.springframework.web.servlet.ModelAndView replaceModuleInMAV(org.springframework.web.servlet.ModelAndView mav)
mav
- the mav to checkpublic static String replaceModuleInViewName(String viewName)
viewName
- the view namepublic static void sendInternalRedirect(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String relativeUrl) throws IOException
request
- the current requestresponse
- the response for the redirectrelativeUrl
- a relative URL to append. can be nullIOException
- in case the redirect failspublic static void sendInternalRedirect(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String clientId, String relativeUrl) throws IOException
request
- the current requestresponse
- the response for the redirectclientId
- the ID of the client to redirect to. If this parameter is null the redirect will
be sent to the current client.relativeUrl
- a relative URL to append. can be nullIOException
- in case the redirect failspublic static void sendInternalRedirectToLogoutUrl(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
request
- the current requestresponse
- the response for the redirectIOException
- in case the redirect failspublic static void sendInternalRedirectToStartPage(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
request
- the current requestresponse
- the response for the redirectIOException
- in case the redirect failspublic static void sendRedirect(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String url) throws IOException
request
- the current requestresponse
- the response for the redirecturl
- the URL. Can be absolute or relative. In case it is relative the redirect will be
on the server, but no client ID will be included.IOException
- in case of an errorpublic static void setApplicationFailure(javax.servlet.http.HttpServletResponse response)
response
- the responsepublic static void setApplicationSuccess(javax.servlet.http.HttpServletResponse response)
response
- the responseCopyright © 2019 Communote team. All rights reserved.