public interface WebContext extends Adaptable
Modifier and Type | Field and Description |
---|---|
static String |
NUXEO_WEBENGINE_BASE_PATH
This variable is used in a proxy setting.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkGuard(String guard)
Check the given expression in this context and return true if the expression is verified or false otherwise.
|
String |
getBasePath()
Gets the path of the servlet.
|
String |
getBaseURL()
Gets the URL of the base path.
|
String |
getCookie(String name)
Convenience method to get a cookie value.
|
String |
getCookie(String name,
String defaultValue)
Convenience method to get a cookie value using a default value.
|
CoreSession |
getCoreSession()
Gets the Core Session (or Repository Session) corresponding to that request.
|
WebEngine |
getEngine()
Gets the web engine instance.
|
ScriptFile |
getFile(String path)
Resolves the given path into a file.
|
FormData |
getForm()
Gets the representation of the data form submitted by the user.
|
javax.ws.rs.core.HttpHeaders |
getHttpHeaders()
Gets HTTP Headers as defined by JAX-RS.
|
Locale |
getLocale()
Gets the context locale.
|
org.apache.commons.logging.Log |
getLog()
Gets a logger to be used by scripts for logging.
|
String |
getLoginPath()
Gets the login path for the current context.
|
String |
getMessage(String key)
Gets the i18n message for the given key.
|
String |
getMessage(String key,
List<Object> args)
The same as
getMessage(String) but with parameter support |
String |
getMessage(String key,
Object... args)
The same as
getMessage(String) but with parameter support |
String |
getMessageL(String key,
String locale)
Same as
getMessage(String) but uses the given locale. |
String |
getMessageL(String key,
String locale,
List<Object> args)
The same as
getMessage(String) but uses the given locale, with parameter support. |
String |
getMessageL(String key,
String locale,
Object... args)
The same as
getMessage(String) but uses the given locale, with parameter support |
String |
getMethod()
Get HTTP Method.
|
Module |
getModule()
Gets the current web application.
|
String |
getModulePath()
Get the path prefix that identify the current web application.
|
Principal |
getPrincipal()
Gets the principal identifying the user that originated the request.
|
Object |
getProperty(String key)
Gets a context variable.
|
Object |
getProperty(String key,
Object defaultValue)
Gets a context variable.
|
javax.servlet.http.HttpServletRequest |
getRequest()
Gets the underlying HTTP servlet request object.
|
Resource |
getRoot()
Gets the root resource if any resource was defined as being the root
|
com.sun.jersey.api.core.HttpContext |
getServerHttpContext()
Gets the jersey server http context
|
com.sun.jersey.server.impl.inject.ServerInjectableProviderContext |
getServerInjectableProviderContext()
Gets the jersey server injection context
|
StringBuilder |
getServerURL()
Gets the server URL without any path or trailing /.
|
AdapterResource |
getTargetAdapter() |
Resource |
getTargetObject() |
String |
getURI()
Returns the part of this request's URL from the protocol name up to the query string in the first line of the
HTTP request.
|
javax.ws.rs.core.UriInfo |
getUriInfo()
Gets the JAX-RS UriInfo.
|
String |
getURL()
Gets the URL requested by the client.
|
String |
getUrlPath()
Gets the path portion of the request URL.
|
String |
getUrlPath(DocumentModel document)
Get a suitable URI path for the given Nuxeo document, that can be used to invoke this document.
|
UserSession |
getUserSession()
Gets the current user session.
|
Resource |
head() |
AdapterResource |
newAdapter(Resource ctx,
String adapterName,
Object... args) |
Resource |
newObject(ResourceType type,
Object... args) |
Resource |
newObject(String typeName,
Object... args) |
Resource |
pop() |
Resource |
push(Resource obj) |
void |
render(ScriptFile script,
Object args,
Writer writer)
Renders the given template using the rendering engine registered in that web engine.
|
void |
render(String template,
Object args,
Writer writer)
Renders the given template using the rendering engine registered in that web engine.
|
void |
render(String template,
Writer writer)
Renders the given template using the rendering engine registered in that web engine.
|
Object |
runScript(ScriptFile script,
Map<String,Object> args)
Runs the script using given arguments
|
Object |
runScript(String script)
Runs the given script.
|
Object |
runScript(String script,
Map<String,Object> args)
Runs the given script.
|
void |
setLocale(Locale locale)
Sets the current locale, that will be kept in context.
|
void |
setProperty(String key,
Object value)
Sets a context variable.
|
void |
setRepositoryName(String repoName)
Sets the repository name that will be used by
getCoreSession() . |
void |
setRoot(Resource root)
Set the root resource of this context
|
Resource |
tail() |
getAdapter
static final String NUXEO_WEBENGINE_BASE_PATH
This variable is used in a proxy setting. The proxy should send a header with this name. Webengine will assume that the base path of the application is this value.
If your application is on server localhost:8080/nuxeo/site/myapp and you proxy it via mysite.com/myapp, then the header should have an empty string value.
Module getModule()
com.sun.jersey.server.impl.inject.ServerInjectableProviderContext getServerInjectableProviderContext()
com.sun.jersey.api.core.HttpContext getServerHttpContext()
Resource getRoot()
A root resource can be any resource from the resource chain.
String getMessage(String key)
The current module i18n messages are queried first then if no message is found the global message pool is queried (the one living in WEB-INF/i18n). If no message is found the key surrounded by exclamation marks is returned.
key
- the message keyString getMessage(String key, Object... args)
getMessage(String)
but with parameter supportString getMessage(String key, List<Object> args)
getMessage(String)
but with parameter supportString getMessageL(String key, String locale)
getMessage(String)
but uses the given locale.key
- the message keylocale
- the locale to useString getMessageL(String key, String locale, Object... args)
getMessage(String)
but uses the given locale, with parameter supportString getMessageL(String key, String locale, List<Object> args)
getMessage(String)
but uses the given locale, with parameter support.Locale getLocale()
If the locale has been set using setLocale(Locale)
, returns the last locale set. Otherwise, compute it
from the Accept-Language language sent by the client, using ServletRequest.getLocale()
.
WebEngine getEngine()
UserSession getUserSession()
The user session is a WebEngine abstraction for the current user session and can be used to retrieve current login, core session, and to set or get user session variables.
CoreSession getCoreSession()
Principal getPrincipal()
javax.ws.rs.core.UriInfo getUriInfo()
javax.ws.rs.core.HttpHeaders getHttpHeaders()
javax.servlet.http.HttpServletRequest getRequest()
FormData getForm()
This provides access to both POST and GET parameters, or to multipart form data requests.
String getURL()
HttpServletRequest.getRequestURL()
.String getURI()
HttpServletRequest.getRequestURI()
.String getUrlPath()
String getLoginPath()
This is the path you can use as a login form action to perform a login or a logout. After the login/logout is done the current page in that context will be served.
String getModulePath()
The application path will include the base path (context + servlet path).
String getBasePath()
String getBaseURL()
getURL()
after removing the path segments over the
base path.StringBuilder getServerURL()
String getUrlPath(DocumentModel document)
ModuleResource
document
- the nuxeo documentClassCastException
- if the module root does not implementing ModuleResource
void setProperty(String key, Object value)
key
- the variable keyvalue
- the variable valuegetProperty(String)
Object getProperty(String key)
Context variables can be used to share data between the scripts that are called in that request (and between Java code too of course).
key
- the variable keyObject getProperty(String key, Object defaultValue)
Context variables can be used to share data between the scripts that are called in that request (and between java code too of course).
key
- the variable keydefaultValue
- the default value to use if the property doesn't existsString getCookie(String name)
name
- the cookie nameString getCookie(String name, String defaultValue)
name
- the cookie namedefaultValue
- the value to return when cookie is not setorg.apache.commons.logging.Log getLog()
Resource newObject(ResourceType type, Object... args)
AdapterResource newAdapter(Resource ctx, String adapterName, Object... args)
Resource getTargetObject()
AdapterResource getTargetAdapter()
ScriptFile getFile(String path)
The path is resolved as following:
Module.getFile(String)
that will try to resolve the path
relative to each directory in the directory stack
path
- the path to resolve into a filevoid render(String template, Writer writer)
This is similar to the render(String, Object, Writer)
method with a null value for the args
argument.
template
- the template to render. Can be a path absolute to the web directory or relative to the caller
script if any.writer
- the writer to userender(String, Object, Writer)
void render(String template, Object args, Writer writer)
template
- the template to renderargs
- the arguments to passwriter
- the writer to usevoid render(ScriptFile script, Object args, Writer writer)
The given arguments are passed to the rendering process as context variables.
script
- the template to renderargs
- the arguments to passwriter
- the writer to useObject runScript(String script, Map<String,Object> args)
script
- the script path. Can be a path absolute to the web directory or relative to the caller script if
any.args
- the arguments to passObject runScript(String script)
This is similar to runScript(String, Map)
with a null value for the args argument
script
- the script path. Can be a path absolute to the web directory or relative to the caller script if
any.runScript(String, Map)
Object runScript(ScriptFile script, Map<String,Object> args)
This is similar to runScript(String, Map)
with a null value for the args argument
script
- the script path. Can be a path absolute to the web directory or relative to the caller script if
any.args
- a map of argumentsrunScript(String, Map)
boolean checkGuard(String guard) throws ParseException
guard
- the guard to checkParseException
Guard
void setRepositoryName(String repoName)
getCoreSession()
.repoName
- IllegalArgumentException
- if the repository is not found.Copyright © 2018 Nuxeo. All rights reserved.