com.arsdigita.kernel
Class KernelHelper

java.lang.Object
  extended bycom.arsdigita.kernel.KernelHelper

public class KernelHelper
extends Object

Provides static methods for accessing kernel-specific data. $Id: //core-platform/dev/src/com/arsdigita/kernel/KernelHelper.java#17 $


Constructor Summary
KernelHelper()
           
 
Method Summary
static boolean emailIsPrimaryIdentifier()
          Deprecated. Use Kernel.getConfig().getPrimaryUserIdentifier()
static Party getCurrentEffectiveParty()
           
static Party getCurrentParty()
           
static User getCurrentUser()
          Deprecated. Call KernelContext.getParty() e.g., Kernel.getContext().getParty().
static User getCurrentUser(javax.servlet.http.HttpServletRequest request)
          Deprecated. See getCurrentUser()
static String getHostName()
          Deprecated. This method will no longer exist in an upcoming release.
static KernelRequestContext getKernelRequestContext(javax.servlet.http.HttpServletRequest req)
          Extracts the KernelRequestContext from the given request.
static javax.servlet.http.HttpServletRequest getRequest()
          Deprecated. Use DispatcherHelper.getRequest().
static String getServerName()
          Deprecated. This method now delegates to WebConfig. Use WebConfig.getServer() and the object it returns instead of this method.
static String getServerPort()
          Deprecated. This method now delegates to WebConfig. Use WebConfig.getServer() and the object it returns instead of this method.
static String getServerURL()
          Deprecated. Use "http://" + Web.getConfig().getServer() + "/" instead.
static String getSiteName()
          Deprecated. Use Web.getConfig().getSiteName() instead.
static String getSystemAdministratorEmailAddress()
          Get the system administrator's email address.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KernelHelper

public KernelHelper()
Method Detail

getKernelRequestContext

public static KernelRequestContext getKernelRequestContext(javax.servlet.http.HttpServletRequest req)
Extracts the KernelRequestContext from the given request.

Returns:
the KernelRequestContext.
Throws:
IllegalStateException - if the current request context does not subclass KernelRequestContext.

getRequest

public static javax.servlet.http.HttpServletRequest getRequest()
Deprecated. Use DispatcherHelper.getRequest().

Returns the current HTTP request.

Returns:
the current HTTP request.

getServerName

public static String getServerName()
Deprecated. This method now delegates to WebConfig. Use WebConfig.getServer() and the object it returns instead of this method.

Returns the name or IP address of the server, for example "www.redhat.com". This may be different from the host name the server runs on. It is intended for use in constructing URLs that refer back to the server but must be constructed outside of an HTTP request context where this information is known explicitly.

The value of serverName is controlled by enterprise.init:

 init com.arsdigita.kernel.Initializer {
     hostName   = "prd001.redhat.com";
     serverName = "www.redhat.com";
     serverPort = "80";
 }
 

If serverName is not defined in enterprise.init, this method will return hostName. If hostName is not defined it will return null.


getServerPort

public static String getServerPort()
Deprecated. This method now delegates to WebConfig. Use WebConfig.getServer() and the object it returns instead of this method.

Returns the port number the server is running on, or null if not defined.


getServerURL

public static String getServerURL()
Deprecated. Use "http://" + Web.getConfig().getServer() + "/" instead.

Returns a canonical URL for accessing the server, constructed from the values of getServerName() and getServerPort(). If the server port is not defined or set to the standard HTTP port 80 it will not be included in the URL. If neither the server name nor port are defined, the return value is simply "http://localhost/".


getHostName

public static String getHostName()
Deprecated. This method will no longer exist in an upcoming release.

Retrieves the host name for this server (for example, "arsDigita.com"). The value is controlled by enterprise.init:
 init com.arsdigita.kernel.Initializer {
 hostName = "redhat.com";
 siteName = "Red Hat Web Site";
 }
 

Returns:
the host name.

getSiteName

public static String getSiteName()
Deprecated. Use Web.getConfig().getSiteName() instead.

Retrieves the site name for this server (for example, "Red Hat Web Site"). The value is controlled by enterprise.init:
 init com.arsdigita.kernel.Initializer {
 hostName = "redhat.com";
 siteName = "Red Hat Web Site";
 }
 

Returns:
the site name.

getSystemAdministratorEmailAddress

public static String getSystemAdministratorEmailAddress()
Get the system administrator's email address. It returns the email address specified in kernel initializer as systemAdministratorEmailAddress. This method is only to be used to obtain a reply-to address for notifications. The return value may or may not correspond to an actual user account on the system..

For example, when a user tries to change their password, they receive confirmation via email. This email must appear to originate from a valid email address on the system. Ideally it will also correspond to a real person who can be replied to for help.

Returns:
email address suitable for reply-to in system notifications

emailIsPrimaryIdentifier

public static boolean emailIsPrimaryIdentifier()
Deprecated. Use Kernel.getConfig().getPrimaryUserIdentifier()


getCurrentUser

public static User getCurrentUser(javax.servlet.http.HttpServletRequest request)
Deprecated. See getCurrentUser()

Fetches the currently logged in user, or null. This is a convenience wrapper around getCurrentUser(). In the general case, those are preferrable.

Parameters:
request - The HTTP request
Returns:
The currently logged-in user, or null if there is none.
Throws:
RuntimeException - if the logged-in user doesn't exist in the database

getCurrentUser

public static User getCurrentUser()
Deprecated. Call KernelContext.getParty() e.g., Kernel.getContext().getParty().

Returns the current user.


getCurrentParty

public static Party getCurrentParty()

getCurrentEffectiveParty

public static Party getCurrentEffectiveParty()


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC