use of com.vodafone360.people.engine.EngineManager.EngineId in project 360-Engine-for-Android by 360.
the class PeopleServiceTest method reportBackToFramework.
@Override
public void reportBackToFramework(int reqId, EngineId engine) {
/*
* We are not interested in testing specific engines in those tests then for all kind of
* requests we will return error because it is handled by all engines, just to finish flow.
*/
ResponseQueue respQueue = ResponseQueue.getInstance();
List<BaseDataType> data = new ArrayList<BaseDataType>();
ServerError se1 = new ServerError(ServerError.ErrorType.INTERNALERROR);
se1.errorDescription = "Test error produced by test framework, ignore it";
data.add(se1);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
}
use of com.vodafone360.people.engine.EngineManager.EngineId in project 360-Engine-for-Android by 360.
the class EngineManager method onCommsInMessage.
/**
* Respond to incoming message received from Comms layer. If this message
* has a valid engine id it is routed to that engine, otherwise The
* {@link EngineManager} will try to get the next response.
*
* @param source EngineId associated with incoming message.
*/
public void onCommsInMessage(EngineId source) {
BaseEngine engine = null;
if (source != null) {
engine = mEngineList.get(source.ordinal());
}
if (engine != null) {
engine.onCommsInMessage();
} else {
LogUtils.logE("EngineManager.onCommsInMessage - " + "Cannot dispatch message, unknown source " + source);
final ResponseQueue queue = ResponseQueue.getInstance();
queue.getNextResponse(source);
}
}
use of com.vodafone360.people.engine.EngineManager.EngineId in project 360-Engine-for-Android by 360.
the class HttpConnectionThread method addErrorToResponseQueue.
/**
* Adds errors to the response queue whenever there is an HTTP error on the
* backend.
*
* @param reqIds The request IDs the error happened for.
*/
public void addErrorToResponseQueue(List<Integer> reqIds) {
EngineId source = null;
QueueManager requestQueue = QueueManager.getInstance();
ResponseQueue responseQueue = ResponseQueue.getInstance();
for (Integer reqId : reqIds) {
// attempt to get type from request
Request req = requestQueue.getRequest(reqId);
if (req != null)
source = req.mEngineId;
responseQueue.addToResponseQueue(new DecodedResponse(reqId, null, source, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
}
}
use of com.vodafone360.people.engine.EngineManager.EngineId in project 360-Engine-for-Android by 360.
the class HessianDecoder method decodeHessianByteArray.
/**
*
* Parse Hessian encoded byte array placing parsed contents into List.
*
* @param requestId The request ID that the response was received for.
* @param data byte array containing Hessian encoded data
* @param type Event type Shows whether we have a push or common message type.
* @param isZipped True if the response is gzipped, otherwise false.
* @param engineId The engine ID the response should be reported back to.
*
* @return The response containing the decoded objects.
*
* @throws IOException Thrown if there is something wrong with reading the (gzipped) hessian encoded input stream.
*
*/
public DecodedResponse decodeHessianByteArray(int requestId, byte[] data, Request.Type type, boolean isZipped, EngineId engineId) throws IOException {
InputStream is = null;
InputStream bis = null;
if (isZipped == true) {
LogUtils.logV("HessianDecoder.decodeHessianByteArray() Handle zipped data");
bis = new ByteArrayInputStream(data);
is = new GZIPInputStream(bis, data.length);
} else {
LogUtils.logV("HessianDecoder.decodeHessianByteArray() Handle non-zipped data");
is = new ByteArrayInputStream(data);
}
DecodedResponse response = null;
mMicroHessianInput.init(is);
LogUtils.logV("HessianDecoder.decodeHessianByteArray() Begin Hessian decode");
try {
response = decodeResponse(is, requestId, type, isZipped, engineId);
} catch (IOException e) {
LogUtils.logE("HessianDecoder.decodeHessianByteArray() " + "IOException during decodeResponse", e);
}
CloseUtils.close(bis);
CloseUtils.close(is);
return response;
}
use of com.vodafone360.people.engine.EngineManager.EngineId in project 360-Engine-for-Android by 360.
the class LoginEngineTest method reportBackToEngine.
@Override
public void reportBackToEngine(int reqId, EngineId engine) {
Log.d("TAG", "LoginEngineTest.reportBackToEngine");
ResponseQueue respQueue = ResponseQueue.getInstance();
List<BaseDataType> data = new ArrayList<BaseDataType>();
switch(mState) {
case IDLE:
break;
case LOGIN_REQUEST:
case SMS_RESPONSE_SIGNIN:
Log.d("TAG", "IdentityEngineTest.reportBackToEngine FETCH ids");
StatusMsg msg = new StatusMsg();
data.add(msg);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.LOGIN_RESPONSE.ordinal()));
mEng.onCommsInMessage();
mState = LoginTestState.LOGIN_REQUEST_VALID;
break;
case LOGIN_REQUEST_VALID:
Log.d("TAG", "IdentityEngineTest.reportBackToEngine FETCH ids");
AuthSessionHolder sesh = new AuthSessionHolder();
data.add(sesh);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.LOGIN_RESPONSE.ordinal()));
mEng.onCommsInMessage();
mState = LoginTestState.SMS_RESPONSE_SIGNIN;
break;
case REGISTRATION:
Log.d("TAG", "IdentityEngineTest.reportBackToEngine Registration");
data.add(mTestModule.createDummyContactData());
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SIGNUP_RESPONSE.ordinal()));
mEng.onCommsInMessage();
break;
case REGISTRATION_ERROR:
data.add(new ServerError(ServerError.ErrorType.UNKNOWN));
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
mEng.onCommsInMessage();
break;
case GET_T_AND_C:
case FETCH_PRIVACY:
case USER_NAME_STATE:
SimpleText txt = new SimpleText();
txt.addText("Simple text");
data.add(txt);
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.GET_T_AND_C_RESPONSE.ordinal()));
mEng.onCommsInMessage();
break;
case SERVER_ERROR:
data.add(new ServerError(ServerError.ErrorType.UNKNOWN));
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
mEng.onCommsInMessage();
break;
default:
}
}
Aggregations