|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.sr.common.json.JSONResponse
public class JSONResponse
This class represents a response from a remote service. The response of a service call may contain a result or an error.
In any cases call responses contains a message identifier which is the same as incoming message for message correlation
on the caller side. The response may contain a header message part which contains additional fields beside error or result.
The following Javascript class represents a response wrapper which contains an operation result within it.
{
JSONTransformer doesn't use class identifiers for simple & primitive java types. For the complex classes like beans,
transformer puts additional hints into the wrapper class to easy transformation process. A complex object representation
would be like this:
"id":"64f4f4b0-79ee-45f0-9b47-77836bc74ce8",
"header":{
"headerField1": "headerVal",
"headerField2": "headerVal",
},
"result":"resultObject"
}
{"classHintAttribute":"test.bean.SimpleBean","beanField":"testValue"}
The following Javascript class represents a response wrapper which contains an error within it.
{
"id":"C3F236B3-D450-0001-B8E3-4F8D528C5390",
"error":
{"errorName":"org.sr.server.AuhenticationException",
"errorCode":491,
"errorMsg":"Authentication is required for securityTestBean.authenticationRequiredMethod calls"
}
}
Field Summary | |
---|---|
static int |
CODE_AUTHENTICATION_REQUIRED
|
static int |
CODE_ERR_NOLOCATOR
|
static int |
CODE_ERR_NOMETHOD
|
static int |
CODE_ERR_PARSE
|
static int |
CODE_REMOTE_EXCEPTION
|
static int |
CODE_SUCCESS
|
static int |
CODE_TRANSPORT_SECURITY_REQUIRED
|
static int |
CODE_UNAUTHORIZED
|
static java.lang.String |
ERROR_ATTRIBUTE
|
static java.lang.String |
ERRORCODE_ATTRIBUTE
|
static java.lang.String |
ERRORMESSAGE_ATTRIBUTE
|
static java.lang.String |
ERRORNAME_ATTRIBUTE
|
static java.lang.String |
HEADER_ATTRIBUTE
|
static java.lang.String |
RESPONSEID_ATTRIBUTE
|
static java.lang.String |
RESULT_ATTRIBUTE
|
Constructor Summary | |
---|---|
JSONResponse(JSONObject response)
Create a JSONResponse wrapper java class to the given JSONObject (Javascript class) |
|
JSONResponse(java.lang.String response)
Create a JSONResponse wrapper java class to the given String object which obeys JSON Rules |
|
JSONResponse(java.lang.String id,
int errorCode,
java.lang.String errorName,
java.lang.String errorMessage)
Creates a response wrapper class which contains the given error |
|
JSONResponse(java.lang.String id,
java.lang.Object result)
Creates a response wrapper class for the given result for the given message id |
Method Summary | |
---|---|
int |
getErrorCode()
|
java.lang.String |
getErrorMessage()
|
java.lang.String |
getErrorName()
|
java.util.Map<java.lang.String,java.lang.Object> |
getHeader()
|
java.lang.String |
getResponseId()
|
java.lang.Object |
getResult()
|
boolean |
hasError()
|
boolean |
hasHeaders()
|
boolean |
hasResult()
|
void |
putToHeader(java.lang.String fieldName,
java.lang.Object value)
|
void |
removeFromHeader(java.lang.String fieldName)
|
void |
setHeader(java.util.Map<java.lang.String,java.lang.Object> header)
|
JSONObject |
toJSON()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String RESPONSEID_ATTRIBUTE
public static final java.lang.String HEADER_ATTRIBUTE
public static final java.lang.String RESULT_ATTRIBUTE
public static final java.lang.String ERROR_ATTRIBUTE
public static final java.lang.String ERRORCODE_ATTRIBUTE
public static final java.lang.String ERRORNAME_ATTRIBUTE
public static final java.lang.String ERRORMESSAGE_ATTRIBUTE
public static final int CODE_SUCCESS
public static final int CODE_REMOTE_EXCEPTION
public static final int CODE_TRANSPORT_SECURITY_REQUIRED
public static final int CODE_AUTHENTICATION_REQUIRED
public static final int CODE_UNAUTHORIZED
public static final int CODE_ERR_PARSE
public static final int CODE_ERR_NOMETHOD
public static final int CODE_ERR_NOLOCATOR
Constructor Detail |
---|
public JSONResponse(java.lang.String response) throws JSONException, TransformationException, TransformationNotSupportedException
response
-
JSONException
TransformationException
TransformationNotSupportedException
public JSONResponse(JSONObject response) throws JSONException, TransformationException, TransformationNotSupportedException
response
-
JSONException
TransformationException
TransformationNotSupportedException
public JSONResponse(java.lang.String id, java.lang.Object result) throws JSONException
id
- result
-
JSONException
public JSONResponse(java.lang.String id, int errorCode, java.lang.String errorName, java.lang.String errorMessage) throws JSONException
id
- errorCode
- errorName
- errorMessage
-
JSONException
Method Detail |
---|
public boolean hasResult()
public boolean hasHeaders()
public boolean hasError()
public java.lang.String getResponseId()
public java.lang.String getErrorName()
public int getErrorCode()
public java.lang.String getErrorMessage()
public java.lang.Object getResult()
public void setHeader(java.util.Map<java.lang.String,java.lang.Object> header) throws JSONException, TransformationException, TransformationNotSupportedException
JSONException
TransformationException
TransformationNotSupportedException
public java.util.Map<java.lang.String,java.lang.Object> getHeader()
public void putToHeader(java.lang.String fieldName, java.lang.Object value) throws JSONException, TransformationException, TransformationNotSupportedException
JSONException
TransformationException
TransformationNotSupportedException
public void removeFromHeader(java.lang.String fieldName) throws JSONException, TransformationException, TransformationNotSupportedException
JSONException
TransformationException
TransformationNotSupportedException
public JSONObject toJSON()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |