org.mmbase.bridge.util
Class CloudUtil

java.lang.Object
  extended by org.mmbase.bridge.util.CloudUtil

public class CloudUtil
extends Object

An utility to work with clouds on the session or as a ThreadLocal

Since:
MMBase-1.9
Version:
$Id: CloudUtil.java 34900 2009-05-01 16:29:42Z michiel $

Field Summary
static String DEFAULT_AUTHENTICATION
           
static String DEFAULT_CLOUD_NAME
           
static String DEFAULT_SESSIONNAME
           
 
Method Summary
static void addCloudToThread(Cloud cloud)
          Add cloud to the current thread
static void addCloudToThread(HttpServletRequest request)
          Add cloud from the http session to the current thread
static Cloud createCloud(HttpServletRequest req)
          Create a new cloud in the session based on the info of the request (username/password) The cloud is stored in the session under the DEFAULT_SESSIONNAME
static Cloud createCloud(HttpServletRequest req, String sessionname)
          Create a new cloud in the session based on the info of the request (username/password)
static Cloud createCloud(HttpServletRequest req, String authenticate, Map<String,?> loginInfo)
          Create a new cloud in the session based on the info of the request (username/password)
static Cloud createCloud(HttpServletRequest req, String sessionname, String authenticate, Map<String,?> loginInfo)
          Create a new cloud in the session based on the info of the request (username/password)
static Cloud getCloudFromSession(HttpServletRequest request)
          Get cloud from session.
static Cloud getCloudFromSession(HttpServletRequest request, String sessionname)
          Get cloud from session.
static Cloud getCloudFromThread()
          Get cloud from current thread
static Map<String,String> getUserCredentials(String username, String password)
          Get Map with login credentials to pass to MMbase bridge
static boolean hasCloud(HttpServletRequest request)
          Checks if a cloud is on the session with given the default sessionname.
static boolean hasCloud(HttpServletRequest request, String sessionname)
          Checks if a cloud is on the session with given sessionname.
static boolean isEmptyOrWhitespace(String str)
          is Empty Or Whitespace.String
static void removeCloudFromThread()
          Remove cloud from current thread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SESSIONNAME

public static final String DEFAULT_SESSIONNAME
See Also:
Constant Field Values

DEFAULT_CLOUD_NAME

public static final String DEFAULT_CLOUD_NAME
See Also:
Constant Field Values

DEFAULT_AUTHENTICATION

public static final String DEFAULT_AUTHENTICATION
See Also:
Constant Field Values
Method Detail

createCloud

public static Cloud createCloud(HttpServletRequest req)
Create a new cloud in the session based on the info of the request (username/password) The cloud is stored in the session under the DEFAULT_SESSIONNAME

Parameters:
req - HttpServletRequest
Returns:
The new cloud

createCloud

public static Cloud createCloud(HttpServletRequest req,
                                String sessionname)
Create a new cloud in the session based on the info of the request (username/password)

Parameters:
req - HttpServletRequest
sessionname - session attribute name to store the cloud in.
Returns:
The new cloud

createCloud

public static Cloud createCloud(HttpServletRequest req,
                                String authenticate,
                                Map<String,?> loginInfo)
Create a new cloud in the session based on the info of the request (username/password)

Parameters:
req - HttpServletRequest
authenticate - Authentication method (eg. "name/password")
loginInfo - Map with login information
Returns:
The new cloud

createCloud

public static Cloud createCloud(HttpServletRequest req,
                                String sessionname,
                                String authenticate,
                                Map<String,?> loginInfo)
Create a new cloud in the session based on the info of the request (username/password)

Parameters:
req - HttpServletRequest
sessionname - session attribute name to store the cloud in.
authenticate - Authentication method (eg. "name/password")
loginInfo - Map with login information
Returns:
The new cloud

getUserCredentials

public static Map<String,String> getUserCredentials(String username,
                                                    String password)
Get Map with login credentials to pass to MMbase bridge

Parameters:
username - username for login
password - password for login
Returns:
Map with Login information

getCloudFromSession

public static Cloud getCloudFromSession(HttpServletRequest request)
Get cloud from session. The DEFAULT_SESSIONNAME is used as attribute name

Parameters:
request - HttpServletRequest
Returns:
Stored cloud

getCloudFromSession

public static Cloud getCloudFromSession(HttpServletRequest request,
                                        String sessionname)
Get cloud from session. The DEFAULT_SESSIONNAME is used as attribute name

Parameters:
request - HttpServletRequest
sessionname - session attribute name to retrieve the cloud from
Returns:
Stored cloud

hasCloud

public static boolean hasCloud(HttpServletRequest request)
Checks if a cloud is on the session with given the default sessionname.

Parameters:
request - HttpServletRequest to search for the cloud.
Returns:
true if a cloud is found, false otherwise.

hasCloud

public static boolean hasCloud(HttpServletRequest request,
                               String sessionname)
Checks if a cloud is on the session with given sessionname.

Parameters:
request - HttpServletRequest to search for the cloud.
sessionname - The name of the cloud on the session.
Returns:
true if a cloud is found, false otherwise.

addCloudToThread

public static void addCloudToThread(HttpServletRequest request)
Add cloud from the http session to the current thread

Parameters:
request - HttpServletRequest with the session

addCloudToThread

public static void addCloudToThread(Cloud cloud)
Add cloud to the current thread

Parameters:
cloud - cloud to add to thread

removeCloudFromThread

public static void removeCloudFromThread()
Remove cloud from current thread


getCloudFromThread

public static Cloud getCloudFromThread()
Get cloud from current thread

Returns:
Cloud from thread

isEmptyOrWhitespace

public static boolean isEmptyOrWhitespace(String str)
is Empty Or Whitespace.String

Parameters:
str - String to check emptiness
Returns:
boolean is it empty


MMBase 2.0-SNAPSHOT - null