com.ideo.sweetdev.presentation.service.error
Class ErrorService2

java.lang.Object
  extended bycom.ideo.sweetdev.core.service.AbstractService
      extended bycom.ideo.sweetdev.presentation.service.error.ErrorService2
All Implemented Interfaces:
IErrorService2, IService

public class ErrorService2
extends AbstractService
implements IErrorService2

the class ErrorService2 allows to store a list of messages and errors. These messages and errors can be displayed later by means of the CustomErrorTag tag.

This class displays every error by default. To disable this option, use setTrace(false);

 

Field Summary
protected static java.lang.String CLASS_NAME
          class name.
protected static java.lang.String DEFAULT_EMPTY_ERRORMSG
          message to display if no other one is supplied.
protected static java.lang.String USER_NULL_ERRORMSG
          USER_NULL_ERRORMSG.
 
Constructor Summary
ErrorService2(java.lang.String _name)
          Constructs an error service 2.
 
Method Summary
 void configure(java.util.Map _parameters)
          Configure the service.
 java.util.Collection consumeMessages(java.lang.String _sessionID)
          This methode gets the messages for a given user and specified session, and delete them.
protected static java.lang.String getErrorMessage(java.util.Locale _locale, java.lang.String _key)
          This method returns an error message following the locale.
protected static java.lang.String getErrorMessage(java.util.Locale _locale, java.lang.String _key, java.lang.Object[] _parametersTab)
          This method returns an error message following the locale.
static java.util.Map getMessages()
          This method returns the messages map.
 java.util.Collection getMessages(java.lang.String _session)
          This methode gets the messages for a given user and specified session, without deleting them.
static boolean getTrace()
          This method retrieves the trace attribute.
 void init()
          Initialize the service.
static boolean isEmpty(java.lang.String _sessionID)
          This method checks if current user have errors in session.
 void refresh()
          Refresh the service data cache
static void saveError(java.lang.String _sessionID, java.lang.Throwable _throwable, java.lang.String _className, java.util.Locale _locale)
          This method saves an error of user in session.
static void saveErrors(java.lang.String _sessionID, java.util.Collection _errors, java.lang.String _className)
          This method saves an error of user in session.
static void saveMessage(java.lang.String _key, java.lang.Object[] _parameters, java.lang.String _type, java.lang.Integer _indent, java.lang.String _sessionID, java.util.Locale _locale)
          This method saves a message of user in session.
static void saveMessage(java.lang.Throwable _throwable, java.lang.String _className, java.lang.String _sessionID, java.lang.Integer _indent, java.util.Locale _locale)
          This method saves a message of user in session.
static void setMessages(java.util.Map _messages)
          This method sets the messages map.
static void setTrace(boolean _trace)
          This method sets the trace attribute.
 
Methods inherited from class com.ideo.sweetdev.core.service.AbstractService
getServiceName, setServiceName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ideo.sweetdev.core.service.IService
getServiceName
 

Field Detail

DEFAULT_EMPTY_ERRORMSG

protected static final java.lang.String DEFAULT_EMPTY_ERRORMSG
message to display if no other one is supplied.

See Also:
Constant Field Values

USER_NULL_ERRORMSG

protected static final java.lang.String USER_NULL_ERRORMSG
USER_NULL_ERRORMSG.

See Also:
Constant Field Values

CLASS_NAME

protected static final java.lang.String CLASS_NAME
class name.

Constructor Detail

ErrorService2

public ErrorService2(java.lang.String _name)
Constructs an error service 2.

Parameters:
_name - the service name.
Method Detail

init

public void init()
          throws TechnicalException
Description copied from interface: IService
Initialize the service. This method is called by the ServiceManager just after the configure() method.

Specified by:
init in interface IService
Overrides:
init in class AbstractService
Throws:
TechnicalException
See Also:
IService.init()

configure

public void configure(java.util.Map _parameters)
               throws TechnicalException
Description copied from interface: IService
Configure the service. This method is called by the ServiceManager at the first instantiation of this class.

Specified by:
configure in interface IService
Overrides:
configure in class AbstractService
Throws:
TechnicalException
See Also:
IService.configure(java.util.Map)

refresh

public void refresh()
Description copied from interface: IService
Refresh the service data cache

Specified by:
refresh in interface IService
Overrides:
refresh in class AbstractService
See Also:
IService.refresh()

isEmpty

public static boolean isEmpty(java.lang.String _sessionID)
This method checks if current user have errors in session.

Parameters:
_sessionID - the current session id.
Returns:
true if current user have errors in session.

getErrorMessage

protected static java.lang.String getErrorMessage(java.util.Locale _locale,
                                                  java.lang.String _key)
This method returns an error message following the locale.

Parameters:
_locale - the current locales.
_key - the message key.
Returns:
the error message following the locale.

getErrorMessage

protected static java.lang.String getErrorMessage(java.util.Locale _locale,
                                                  java.lang.String _key,
                                                  java.lang.Object[] _parametersTab)
This method returns an error message following the locale.

Parameters:
_locale - the current locales.
_key - the message key.
_parametersTab - the array of parameters.
Returns:
the error message following the locale.

saveError

public static void saveError(java.lang.String _sessionID,
                             java.lang.Throwable _throwable,
                             java.lang.String _className,
                             java.util.Locale _locale)
This method saves an error of user in session.

Parameters:
_sessionID - the current session.
_throwable - the exception where the error comes from.
_className - name of the class that raised the error.
_locale - the current locales.

saveErrors

public static void saveErrors(java.lang.String _sessionID,
                              java.util.Collection _errors,
                              java.lang.String _className)
This method saves an error of user in session.

Parameters:
_sessionID - the current session id.
_errors - the collection of ActionMessage to save.
_className - name of the class that raised the list of errors.

saveMessage

public static void saveMessage(java.lang.Throwable _throwable,
                               java.lang.String _className,
                               java.lang.String _sessionID,
                               java.lang.Integer _indent,
                               java.util.Locale _locale)
This method saves a message of user in session.

Parameters:
_throwable - the exception where the error comes from.
_className - name of the class that raised the error.
_sessionID - the current session id.
_indent - indentation level.

saveMessage

public static void saveMessage(java.lang.String _key,
                               java.lang.Object[] _parameters,
                               java.lang.String _type,
                               java.lang.Integer _indent,
                               java.lang.String _sessionID,
                               java.util.Locale _locale)
This method saves a message of user in session.

Parameters:
_key - key of the message to display.
_parameters - message parameters (peut etre null).
_type - message type : ActionMessage.ERROR, ActionMessage.MESSAGE, ActionMessage.WARNING.
_indent - indentation level : ActionMessage.LEVEL_0, ActionMessage.LEVEL_1, ActionMessage.LEVEL_2.
_sessionID - the current session.

consumeMessages

public java.util.Collection consumeMessages(java.lang.String _sessionID)
Description copied from interface: IErrorService2
This methode gets the messages for a given user and specified session, and delete them.

Specified by:
consumeMessages in interface IErrorService2
Parameters:
_sessionID - the current session ID.
Returns:
the messages to return.
See Also:
com.ideo.sweetdev.presentation.service.error.IErrorService2#consumeMessages(javax.servlet.http.HttpSession)

getMessages

public java.util.Collection getMessages(java.lang.String _session)
Description copied from interface: IErrorService2
This methode gets the messages for a given user and specified session, without deleting them.

Specified by:
getMessages in interface IErrorService2
Parameters:
_session - the current session ID.
Returns:
the messages to return.
See Also:
com.ideo.sweetdev.presentation.service.error.IErrorService2#getMessages(javax.servlet.http.HttpSession)

getMessages

public static java.util.Map getMessages()
This method returns the messages map.

Returns:
the messages map.

setMessages

public static void setMessages(java.util.Map _messages)
This method sets the messages map.

Returns:
the messages map.

setTrace

public static void setTrace(boolean _trace)
This method sets the trace attribute.

Parameters:
_trace - the trace attribute.

getTrace

public static boolean getTrace()
This method retrieves the trace attribute.

Returns:
trace the trace attribute.