com.konakart.json
Class KKJSONEngBase

java.lang.Object
  extended by com.konakart.json.KKJSONEngBase
Direct Known Subclasses:
KKJSONEng

public class KKJSONEngBase
extends java.lang.Object

KonaKart JSON Client-side Engine Base for the Application Engine


Field Summary
protected static org.codehaus.jackson.map.ObjectMapper mapper
          JSON Data Mapping Object
 
Constructor Summary
KKJSONEngBase(EngineConfigIf engConf)
          Constructor with an EngineConfig object.
 
Method Summary
protected  void checkForException(KKJSON_ResponseIf response)
           
 EngineConfigIf getEngConf()
           
 java.net.URL getJsonURL()
           
static org.codehaus.jackson.map.ObjectMapper getMapper()
           
protected  java.lang.String getNextId()
          Return the next number in a sequence for matching requests and responses
 java.lang.String getStoreId()
           
 java.lang.String getStoreIdForRequest()
          Only return the storeId if we're in a multi-store environment
protected static KKException handleThrowable(java.lang.Throwable e, java.lang.String methodName)
          Handles the exception for all methods.
 void init()
           
 boolean isGenerateMatchIds()
           
 boolean isSuccessfullyInitialised()
           
 java.lang.String postRequest(java.lang.String request)
           
static java.lang.String prettyJson(java.lang.String uglyJsonString)
          To pretty-print a JSON String
 void setEngConf(EngineConfigIf engConf)
           
 void setGenerateMatchIds(boolean generateMatchIds)
           
 void setJsonURL(java.net.URL jsonURL)
           
 void setStoreId(java.lang.String storeId)
           
 void setSuccessfullyInitialised(boolean successfullyInitialised)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mapper

protected static org.codehaus.jackson.map.ObjectMapper mapper
JSON Data Mapping Object

Constructor Detail

KKJSONEngBase

public KKJSONEngBase(EngineConfigIf engConf)
              throws KKException
Constructor with an EngineConfig object.

Parameters:
engConf -
Throws:
KKException
Method Detail

init

public void init()
          throws KKException
Throws:
KKException

handleThrowable

protected static KKException handleThrowable(java.lang.Throwable e,
                                             java.lang.String methodName)
Handles the exception for all methods. If the exception is a RemoteException or a ServerException and has a cause exception, then we add the cause exception instead of the RemoteException, although we do save the message of the RemoteException or ServerException.

We do this so that the receiver can detect the cause exception and act on it. Otherwise it gets lost.

Parameters:
e -
methodName -
Returns:
Returns an exception

checkForException

protected void checkForException(KKJSON_ResponseIf response)
                          throws KKException
Throws:
KKException

getNextId

protected java.lang.String getNextId()
Return the next number in a sequence for matching requests and responses

Returns:
the next number as a String

postRequest

public java.lang.String postRequest(java.lang.String request)
                             throws java.lang.Exception
Parameters:
request -
Returns:
the response
Throws:
java.lang.Exception

prettyJson

public static java.lang.String prettyJson(java.lang.String uglyJsonString)
To pretty-print a JSON String

Parameters:
uglyJsonString - the raw JSON String
Returns:
the pretty version of the input

isSuccessfullyInitialised

public boolean isSuccessfullyInitialised()
Returns:
the successfullyInitialised

setSuccessfullyInitialised

public void setSuccessfullyInitialised(boolean successfullyInitialised)
Parameters:
successfullyInitialised - the successfullyInitialised to set

getStoreIdForRequest

public java.lang.String getStoreIdForRequest()
Only return the storeId if we're in a multi-store environment

Returns:
the storeId that will go on the request

getStoreId

public java.lang.String getStoreId()
Returns:
the storeId

setStoreId

public void setStoreId(java.lang.String storeId)
Parameters:
storeId - the storeId to set

getEngConf

public EngineConfigIf getEngConf()
Returns:
the engConf

setEngConf

public void setEngConf(EngineConfigIf engConf)
Parameters:
engConf - the engConf to set

getJsonURL

public java.net.URL getJsonURL()
Returns:
the jsonURL

setJsonURL

public void setJsonURL(java.net.URL jsonURL)
Parameters:
jsonURL - the jsonURL to set

isGenerateMatchIds

public boolean isGenerateMatchIds()
Returns:
the generateMatchIds

setGenerateMatchIds

public void setGenerateMatchIds(boolean generateMatchIds)
Parameters:
generateMatchIds - the generateMatchIds to set

getMapper

public static org.codehaus.jackson.map.ObjectMapper getMapper()
Returns:
the mapper


Copyright © 2011 DS Data Systems UK Ltd.