Package org.opencms.main
Class CmsContextInfo
java.lang.Object
org.opencms.main.CmsContextInfo
- All Implemented Interfaces:
Serializable
Contains user information for automated creation of a
CmsRequestContext
during system runtime.- Since:
- 6.0.0
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates a new instance, initializing the variables with some reasonable default values.CmsContextInfo
(String userName) Creates a new instance, initializing the user name as provided and all other vaiables with the same default values as inCmsContextInfo()
.CmsContextInfo
(CmsRequestContext requestContext) Creates a new instance with all context variables initialized from the given request context.CmsContextInfo
(CmsUser user, CmsProject project, String requestedUri, CmsSiteMatcher requestMatcher, String siteRoot, boolean isSecureRequest, Locale locale, String encoding, String remoteAddr, long requestTime, String ouFqn, boolean isForceAbsoluteLinks) Creates a new instance with all context variables initialized. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Checks if this context info configuration is frozen.clone()
Creates a clone of this context info object.void
freeze()
Finalizes (freezes) the configuration of this context information.Gets the detail content resource.Returns the encoding.Returns the locale.Returns the locale name.getOuFqn()
Returns the fully qualified name of the organizational unit.Returns the project, ornull
if the project has not been configured.Returns the project name.Returns the remote ip address.Returns the requested uri.Returns the matcher for the current request, that is the host part of the URI from the original http request.long
Returns the request time used for validation of resource publication and expiration dates.Returns the siteroot.getUser()
Returns the user, ornull
if the user has not been configured.Returns the username.boolean
Returns true if links to the current site should be generated with a server prefix.boolean
Returns true if this a secure request.void
setDetailResource
(CmsResource detailResource) Sets the detail content resource.void
setEncoding
(String encoding) Sets the encoding.void
setForceAbsoluteLinks
(boolean isForceAbsoluteLinks) Enables/disables usage of the server prefix for links to the current site.void
setIsSecureRequest
(boolean isSecureRequest) Sets the 'isSecureRequest' attribute.void
Sets the locale.void
setLocaleName
(String localeName) Sets the locale name.void
Sets the fully qualified name of the organizational unit.void
setProjectName
(String projectName) Sets the project name.void
setRemoteAddr
(String remoteAddr) Sets the remote ip address.void
setRequestedUri
(String requestedUri) Sets the requested uri.void
setRequestMatcher
(CmsSiteMatcher requestMatcher) Sets the matcher for the current request, that is the host part of the URI from the original http request.void
setRequestTime
(long requestTime) Sets the request time used for validation of resource publication and expiration dates.void
setSiteRoot
(String siteRoot) Sets the siteroot.void
setUserName
(String userName) Sets the username.
-
Field Details
-
ATTRIBUTE_REQUEST_TIME
Name of the http session attribute the request time is stored in.- See Also:
-
CURRENT_TIME
Indicates the request time should always be the current time.- See Also:
-
LOCALHOST
Localhost ip used in fallback cases.- See Also:
-
-
Constructor Details
-
CmsContextInfo
public CmsContextInfo()Creates a new instance, initializing the variables with some reasonable default values.The default values are:
- User name
- (configured default guest user)
- Project name
- Online
- Requested URI
- /
- Site root
- /
- Locale name
- (configured default locale name)
- Encoding
- (configured default system encoding)
- Remote address
- 127.0.0.1
- Organizational unit
- /
-
CmsContextInfo
Creates a new instance with all context variables initialized from the given request context.- Parameters:
requestContext
- the request context to initialize this context info with
-
CmsContextInfo
public CmsContextInfo(CmsUser user, CmsProject project, String requestedUri, CmsSiteMatcher requestMatcher, String siteRoot, boolean isSecureRequest, Locale locale, String encoding, String remoteAddr, long requestTime, String ouFqn, boolean isForceAbsoluteLinks) Creates a new instance with all context variables initialized.- Parameters:
user
- the user to create the context withproject
- the project to create the context withrequestedUri
- the request URI to create the context withrequestMatcher
- the matcher for the current request, that is the host part of the URI from the original http requestsiteRoot
- the site root to create the context withisSecureRequest
- if this a secure requestlocale
- the locale to create the context withencoding
- the encoding to create the context withremoteAddr
- the remote ip address to create the context withrequestTime
- the time of the request (used for resource publication / expiration date)ouFqn
- the fully qualified name of the organizational unit to create the context withisForceAbsoluteLinks
- a flag indicating whether links to the current site should be generated with a server prefix
-
CmsContextInfo
Creates a new instance, initializing the user name as provided and all other vaiables with the same default values as inCmsContextInfo()
.- Parameters:
userName
- the user name to create the context with- See Also:
-
-
Method Details
-
clone
Creates a clone of this context info object. -
freeze
Finalizes (freezes) the configuration of this context information.After this entry has been frozen, any attempt to change the configuration of this context info with one of the "set..." methods will lead to a
RuntimeException
. -
getDetailResource
Gets the detail content resource.- Returns:
- the detail content resource
-
getEncoding
Returns the encoding.- Returns:
- the encoding
- See Also:
-
getLocale
Returns the locale.- Returns:
- the locale
- See Also:
-
getLocaleName
Returns the locale name.- Returns:
- the locale name
- See Also:
-
getOuFqn
Returns the fully qualified name of the organizational unit.- Returns:
- the fully qualified name of the organizational unit
-
getProject
Returns the project, ornull
if the project has not been configured.If the project has not been configured, at last the project name will be available.
- Returns:
- the project
- See Also:
-
getProjectName
Returns the project name.- Returns:
- the project name
- See Also:
-
getRemoteAddr
Returns the remote ip address.- Returns:
- the remote ip address
- See Also:
-
getRequestedUri
Returns the requested uri.- Returns:
- the requested uri
- See Also:
-
getRequestMatcher
Returns the matcher for the current request, that is the host part of the URI from the original http request.- Returns:
- the matcher for the current request, that is the host part of the URI from the original http request
-
getRequestTime
Returns the request time used for validation of resource publication and expiration dates.- Returns:
- the request time used for validation of resource publication and expiration dates
- See Also:
-
getSiteRoot
Returns the siteroot.- Returns:
- the siteroot
- See Also:
-
getUser
Returns the user, ornull
if the user has not been configured.If the user has not been configured, at last the user name will be available.
- Returns:
- the user
- See Also:
-
getUserName
Returns the username.- Returns:
- the username
- See Also:
-
isForceAbsoluteLinks
Returns true if links to the current site should be generated with a server prefix.- Returns:
- true if links to current site should be absolute
-
isSecureRequest
Returns true if this a secure request.- Returns:
- true if this is a secure request
-
setDetailResource
Sets the detail content resource.- Parameters:
detailResource
- the detail content resource to set
-
setEncoding
Sets the encoding.- Parameters:
encoding
- the encoding to set- See Also:
-
setForceAbsoluteLinks
Enables/disables usage of the server prefix for links to the current site.- Parameters:
isForceAbsoluteLinks
- true if links to the current site should be generated with a server prefix
-
setIsSecureRequest
Sets the 'isSecureRequest' attribute.- Parameters:
isSecureRequest
- true if this a secure request
-
setLocale
Sets the locale.Setting the locale name will override the currently selected locale and vice-versa. The locale name and the locale will always match.
- Parameters:
locale
- the locale to set- See Also:
-
setLocaleName
Sets the locale name.Setting the locale name will override the currently selected locale and vice-versa. The locale name and the locale will always match.
- Parameters:
localeName
- the locale name to set- See Also:
-
setOuFqn
Sets the fully qualified name of the organizational unit.- Parameters:
ouFqn
- the fully qualified name of the organizational unit to set
-
setProjectName
Sets the project name.- Parameters:
projectName
- the project name to set- See Also:
-
setRemoteAddr
Sets the remote ip address.- Parameters:
remoteAddr
- the remote ip address- See Also:
-
setRequestedUri
Sets the requested uri.- Parameters:
requestedUri
- the requested uri to set- See Also:
-
setRequestMatcher
Sets the matcher for the current request, that is the host part of the URI from the original http request.- Parameters:
requestMatcher
- the matcher for the current request
-
setRequestTime
Sets the request time used for validation of resource publication and expiration dates.- Parameters:
requestTime
- the request time to set- See Also:
-
setSiteRoot
Sets the siteroot.- Parameters:
siteRoot
- the siteroot to set- See Also:
-
setUserName
Sets the username.- Parameters:
userName
- the username to set- See Also:
-
checkFrozen
Checks if this context info configuration is frozen.- Throws:
CmsRuntimeException
- in case the configuration is already frozen
-