org.broadleafcommerce.core.web.api
Class BroadleafWebServicesException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by org.broadleafcommerce.core.web.api.BroadleafWebServicesException
All Implemented Interfaces:
Serializable

public class BroadleafWebServicesException
extends RuntimeException

The purpose of this is to allow REST endpoints to build an exception with

Author:
Kelly Tisdell
See Also:
Serialized Form

Field Summary
static String CART_ITEM_NOT_FOUND
           
static String CART_NOT_FOUND
           
static String CART_PRICING_ERROR
           
static String CATEGORY_NOT_FOUND
           
static String CUSTOMER_NOT_FOUND
           
static String FULFILLMENT_GROUP_NOT_FOUND
           
static String FULFILLMENT_OPTION_NOT_FOUND
           
protected  int httpStatusCode
           
static String INVALID_CATEGORY_ID
           
protected  Locale locale
           
protected  Map<String,Object[]> messages
           
static String PRODUCT_NOT_FOUND
           
static String PROMO_CODE_INVALID
           
static String PROMO_CODE_MAX_USAGES
           
static String SEARCH_ERROR
           
static String SEARCH_QUERY_EMPTY
           
static String SEARCH_QUERY_MALFORMED
           
static String SKU_NOT_FOUND
           
protected  Map<String,String> translatedMessages
           
static String UNKNOWN_ERROR
           
static String UPDATE_CART_ERROR
           
 
Constructor Summary
BroadleafWebServicesException(int httpStatusCode, Locale locale, Map<String,Object[]> messages, Throwable cause)
           
 
Method Summary
 BroadleafWebServicesException addMessage(String key)
          Convenience method for adding a message with no parameters
 BroadleafWebServicesException addMessage(String key, Object param)
          Convenience method for adding a message with a single parameter
 BroadleafWebServicesException addMessage(String key, Object[] params)
          Convenience mentod for adding a message with multiple parameters
 BroadleafWebServicesException addTranslatedMessage(String key, String message)
          Adds a translated message.
static BroadleafWebServicesException build(int httpStatusCode)
           
static BroadleafWebServicesException build(int httpStatusCode, Locale locale)
           
static BroadleafWebServicesException build(int httpStatusCode, Locale locale, Map<String,Object[]> messages)
           
static BroadleafWebServicesException build(int httpStatusCode, Locale locale, Map<String,Object[]> messages, Throwable cause)
           
static BroadleafWebServicesException build(int httpStatusCode, Locale locale, Throwable t)
           
static BroadleafWebServicesException build(int httpStatusCode, Throwable t)
           
 int getHttpStatusCode()
          Returns the intended HTTP status code (e.g.
 Locale getLocale()
          Returns the java.util.Locale that messages should be formatted in.
 Map<String,Object[]> getMessages()
          Gets a map of message keys and object arrays.
 Map<String,String> getTranslatedMessages()
          Gets a map of messages that have already been translated.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN_ERROR

public static final String UNKNOWN_ERROR
See Also:
Constant Field Values

PRODUCT_NOT_FOUND

public static final String PRODUCT_NOT_FOUND
See Also:
Constant Field Values

CATEGORY_NOT_FOUND

public static final String CATEGORY_NOT_FOUND
See Also:
Constant Field Values

SKU_NOT_FOUND

public static final String SKU_NOT_FOUND
See Also:
Constant Field Values

SEARCH_ERROR

public static final String SEARCH_ERROR
See Also:
Constant Field Values

SEARCH_QUERY_EMPTY

public static final String SEARCH_QUERY_EMPTY
See Also:
Constant Field Values

SEARCH_QUERY_MALFORMED

public static final String SEARCH_QUERY_MALFORMED
See Also:
Constant Field Values

INVALID_CATEGORY_ID

public static final String INVALID_CATEGORY_ID
See Also:
Constant Field Values

CART_NOT_FOUND

public static final String CART_NOT_FOUND
See Also:
Constant Field Values

CART_ITEM_NOT_FOUND

public static final String CART_ITEM_NOT_FOUND
See Also:
Constant Field Values

CART_PRICING_ERROR

public static final String CART_PRICING_ERROR
See Also:
Constant Field Values

UPDATE_CART_ERROR

public static final String UPDATE_CART_ERROR
See Also:
Constant Field Values

PROMO_CODE_MAX_USAGES

public static final String PROMO_CODE_MAX_USAGES
See Also:
Constant Field Values

PROMO_CODE_INVALID

public static final String PROMO_CODE_INVALID
See Also:
Constant Field Values

FULFILLMENT_GROUP_NOT_FOUND

public static final String FULFILLMENT_GROUP_NOT_FOUND
See Also:
Constant Field Values

FULFILLMENT_OPTION_NOT_FOUND

public static final String FULFILLMENT_OPTION_NOT_FOUND
See Also:
Constant Field Values

CUSTOMER_NOT_FOUND

public static final String CUSTOMER_NOT_FOUND
See Also:
Constant Field Values

httpStatusCode

protected int httpStatusCode

messages

protected Map<String,Object[]> messages

translatedMessages

protected Map<String,String> translatedMessages

locale

protected Locale locale
Constructor Detail

BroadleafWebServicesException

public BroadleafWebServicesException(int httpStatusCode,
                                     Locale locale,
                                     Map<String,Object[]> messages,
                                     Throwable cause)
Method Detail

build

public static BroadleafWebServicesException build(int httpStatusCode)

build

public static BroadleafWebServicesException build(int httpStatusCode,
                                                  Throwable t)

build

public static BroadleafWebServicesException build(int httpStatusCode,
                                                  Locale locale)

build

public static BroadleafWebServicesException build(int httpStatusCode,
                                                  Locale locale,
                                                  Throwable t)

build

public static BroadleafWebServicesException build(int httpStatusCode,
                                                  Locale locale,
                                                  Map<String,Object[]> messages)

build

public static BroadleafWebServicesException build(int httpStatusCode,
                                                  Locale locale,
                                                  Map<String,Object[]> messages,
                                                  Throwable cause)

getHttpStatusCode

public int getHttpStatusCode()
Returns the intended HTTP status code (e.g. 400, 403, 404, 500, etc...). Default is 500.

Returns:

getMessages

public Map<String,Object[]> getMessages()
Gets a map of message keys and object arrays. These will generally be used to build a an internationalized message in the response. The map key is typically going to be a message bundle key, and the object array provides parameters for the message. For more information, see Spring's org.springframework.context.MessageSource.

Returns:

getTranslatedMessages

public Map<String,String> getTranslatedMessages()
Gets a map of messages that have already been translated. BLC provides a number of translation mechanisms for entities in the DB.

Returns:

addTranslatedMessage

public BroadleafWebServicesException addTranslatedMessage(String key,
                                                          String message)
Adds a translated message. The assumption is that the message added to this map does not need to be translated or internationalized any further. It is already translated according to the user's Locale.

Parameters:
key -
message -
Returns:

addMessage

public BroadleafWebServicesException addMessage(String key)
Convenience method for adding a message with no parameters

Parameters:
key -
Returns:

addMessage

public BroadleafWebServicesException addMessage(String key,
                                                Object param)
Convenience method for adding a message with a single parameter

Parameters:
key -
param -
Returns:

addMessage

public BroadleafWebServicesException addMessage(String key,
                                                Object[] params)
Convenience mentod for adding a message with multiple parameters

Parameters:
key -
params -
Returns:

getLocale

public Locale getLocale()
Returns the java.util.Locale that messages should be formatted in.

Returns:


Copyright © 2013. All Rights Reserved.