org.opencms.main
Class CmsContextInfo

java.lang.Object
  extended by org.opencms.main.CmsContextInfo

public class CmsContextInfo
extends java.lang.Object

Contains user information for automated creation of a CmsRequestContext during system runtime.

Since:
6.0.0
Version:
$Revision: 1.20 $

Field Summary
static java.lang.String ATTRIBUTE_REQUEST_TIME
          Name of the http session attribute the request time is stored in.
static long CURRENT_TIME
          Indicates the request time should always be the current time.
static java.lang.String LOCALHOST
          Localhost ip used in fallback cases.
 
Constructor Summary
CmsContextInfo()
          Creates a new instance, initializing the variables with some reasonable default values.
CmsContextInfo(CmsRequestContext requestContext)
          Creates a new instance with all context variables initialized from the given request context.
CmsContextInfo(CmsUser user, CmsProject project, java.lang.String requestedUri, java.lang.String siteRoot, java.util.Locale locale, java.lang.String encoding, java.lang.String remoteAddr, long requestTime, java.lang.String ouFqn)
          Creates a new instance with all context variables initialized.
CmsContextInfo(java.lang.String userName)
          Creates a new instance, initializing the user name as provided and all other vaiables with the same default values as in CmsContextInfo().
 
Method Summary
protected  void checkFrozen()
          Checks if this context info configuration is frozen.
 java.lang.Object clone()
          Creates a clone of this context info object.
 void freeze()
          Finalizes (freezes) the configuration of this context information.
 java.lang.String getEncoding()
          Returns the encoding.
 java.util.Locale getLocale()
          Returns the locale.
 java.lang.String getLocaleName()
          Returns the locale name.
 java.lang.String getOuFqn()
          Returns the fully qualified name of the organizational unit.
 CmsProject getProject()
          Returns the project, or null if the project has not been configured.
 java.lang.String getProjectName()
          Returns the project name.
 java.lang.String getRemoteAddr()
          Returns the remote ip address.
 java.lang.String getRequestedUri()
          Returns the requested uri.
 long getRequestTime()
          Returns the request time used for validation of resource publication and expiration dates.
 java.lang.String getSiteRoot()
          Returns the siteroot.
 CmsUser getUser()
          Returns the user, or null if the user has not been configured.
 java.lang.String getUserName()
          Returns the username.
 void setEncoding(java.lang.String encoding)
          Sets the encoding.
 void setLocale(java.util.Locale locale)
          Sets the locale.
 void setLocaleName(java.lang.String localeName)
          Sets the locale name.
 void setOuFqn(java.lang.String ouFqn)
          Sets the fully qualified name of the organizational unit.
 void setProjectName(java.lang.String projectName)
          Sets the project name.
 void setRemoteAddr(java.lang.String remoteAddr)
          Sets the remote ip address.
 void setRequestedUri(java.lang.String requestedUri)
          Sets the requested uri.
 void setRequestTime(long requestTime)
          Sets the request time used for validation of resource publication and expiration dates.
 void setSiteRoot(java.lang.String siteRoot)
          Sets the siteroot.
 void setUserName(java.lang.String userName)
          Sets the username.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTRIBUTE_REQUEST_TIME

public static final java.lang.String ATTRIBUTE_REQUEST_TIME
Name of the http session attribute the request time is stored in.

See Also:
Constant Field Values

CURRENT_TIME

public static final long CURRENT_TIME
Indicates the request time should always be the current time.

See Also:
Constant Field Values

LOCALHOST

public static final java.lang.String LOCALHOST
Localhost ip used in fallback cases.

See Also:
Constant Field Values
Constructor Detail

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

public CmsContextInfo(CmsRequestContext requestContext)
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,
                      java.lang.String requestedUri,
                      java.lang.String siteRoot,
                      java.util.Locale locale,
                      java.lang.String encoding,
                      java.lang.String remoteAddr,
                      long requestTime,
                      java.lang.String ouFqn)
Creates a new instance with all context variables initialized.

Parameters:
user - the user to create the context with
project - the project to create the context with
requestedUri - the request URI to create the context with
siteRoot - the site root to create the context with
locale - the locale to create the context with
encoding - the encoding to create the context with
remoteAddr - the remote ip address to create the context with
requestTime - the time of the request (used for resource publication / expiration date)
ouFqn - the fully qualified name of the organizational unit to create the context with

CmsContextInfo

public CmsContextInfo(java.lang.String userName)
Creates a new instance, initializing the user name as provided and all other vaiables with the same default values as in CmsContextInfo().

Parameters:
userName - the user name to create the context with
See Also:
CmsContextInfo()
Method Detail

clone

public java.lang.Object clone()
Creates a clone of this context info object.

Overrides:
clone in class java.lang.Object
See Also:
Object.clone()

freeze

public void 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.


getEncoding

public java.lang.String getEncoding()
Returns the encoding.

Returns:
the encoding
See Also:
CmsRequestContext.getEncoding()

getLocale

public java.util.Locale getLocale()
Returns the locale.

Returns:
the locale
See Also:
CmsRequestContext.getLocale()

getLocaleName

public java.lang.String getLocaleName()
Returns the locale name.

Returns:
the locale name
See Also:
CmsRequestContext.getLocale()

getOuFqn

public java.lang.String getOuFqn()
Returns the fully qualified name of the organizational unit.

Returns:
the fully qualified name of the organizational unit

getProject

public CmsProject getProject()
Returns the project, or null 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(), CmsRequestContext.currentProject()

getProjectName

public java.lang.String getProjectName()
Returns the project name.

Returns:
the project name
See Also:
getProject(), CmsRequestContext.currentProject()

getRemoteAddr

public java.lang.String getRemoteAddr()
Returns the remote ip address.

Returns:
the remote ip address
See Also:
CmsRequestContext.getRemoteAddress()

getRequestedUri

public java.lang.String getRequestedUri()
Returns the requested uri.

Returns:
the requested uri
See Also:
CmsRequestContext.getUri()

getRequestTime

public long 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:
CmsRequestContext.getRequestTime()

getSiteRoot

public java.lang.String getSiteRoot()
Returns the siteroot.

Returns:
the siteroot
See Also:
CmsRequestContext.getSiteRoot()

getUser

public CmsUser getUser()
Returns the user, or null 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(), CmsRequestContext.currentUser()

getUserName

public java.lang.String getUserName()
Returns the username.

Returns:
the username
See Also:
getUser(), CmsRequestContext.currentUser()

setEncoding

public void setEncoding(java.lang.String encoding)
Sets the encoding.

Parameters:
encoding - the encoding to set
See Also:
CmsRequestContext.setEncoding(String)

setLocale

public void setLocale(java.util.Locale locale)
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(String), CmsRequestContext.getLocale()

setLocaleName

public void setLocaleName(java.lang.String localeName)
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:
setLocale(Locale), CmsRequestContext.getLocale()

setOuFqn

public void setOuFqn(java.lang.String ouFqn)
Sets the fully qualified name of the organizational unit.

Parameters:
ouFqn - the fully qualified name of the organizational unit to set

setProjectName

public void setProjectName(java.lang.String projectName)
Sets the project name.

Parameters:
projectName - the project name to set
See Also:
CmsRequestContext.currentProject()

setRemoteAddr

public void setRemoteAddr(java.lang.String remoteAddr)
Sets the remote ip address.

Parameters:
remoteAddr - the remote ip address
See Also:
CmsRequestContext.getRemoteAddress()

setRequestedUri

public void setRequestedUri(java.lang.String requestedUri)
Sets the requested uri.

Parameters:
requestedUri - the requested uri to set
See Also:
CmsRequestContext.setUri(String)

setRequestTime

public void setRequestTime(long requestTime)
Sets the request time used for validation of resource publication and expiration dates.

Parameters:
requestTime - the request time to set
See Also:
CmsRequestContext.getRequestTime()

setSiteRoot

public void setSiteRoot(java.lang.String siteRoot)
Sets the siteroot.

Parameters:
siteRoot - the siteroot to set
See Also:
CmsRequestContext.setSiteRoot(String)

setUserName

public void setUserName(java.lang.String userName)
Sets the username.

Parameters:
userName - the username to set
See Also:
CmsRequestContext.currentUser()

checkFrozen

protected void checkFrozen()
                    throws CmsRuntimeException
Checks if this context info configuration is frozen.

Throws:
CmsRuntimeException - in case the configuration is already frozen