Search in sources :

Example 11 with EngineId

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()));
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) ServerError(com.vodafone360.people.datatypes.ServerError) ArrayList(java.util.ArrayList) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) ResponseQueue(com.vodafone360.people.service.io.ResponseQueue)

Example 12 with EngineId

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);
    }
}
Also used : ResponseQueue(com.vodafone360.people.service.io.ResponseQueue)

Example 13 with EngineId

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()));
    }
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) EngineId(com.vodafone360.people.engine.EngineManager.EngineId) Request(com.vodafone360.people.service.io.Request) ResponseQueue(com.vodafone360.people.service.io.ResponseQueue) QueueManager(com.vodafone360.people.service.io.QueueManager)

Example 14 with EngineId

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;
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) ByteArrayInputStream(java.io.ByteArrayInputStream) GZIPInputStream(java.util.zip.GZIPInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException)

Example 15 with EngineId

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:
    }
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) AuthSessionHolder(com.vodafone360.people.datatypes.AuthSessionHolder) StatusMsg(com.vodafone360.people.datatypes.StatusMsg) SimpleText(com.vodafone360.people.datatypes.SimpleText) ServerError(com.vodafone360.people.datatypes.ServerError) ArrayList(java.util.ArrayList) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) ResponseQueue(com.vodafone360.people.service.io.ResponseQueue)

Aggregations

DecodedResponse (com.vodafone360.people.service.io.ResponseQueue.DecodedResponse)11 BaseDataType (com.vodafone360.people.datatypes.BaseDataType)9 ServerError (com.vodafone360.people.datatypes.ServerError)9 ResponseQueue (com.vodafone360.people.service.io.ResponseQueue)9 ArrayList (java.util.ArrayList)9 Request (com.vodafone360.people.service.io.Request)5 EngineId (com.vodafone360.people.engine.EngineManager.EngineId)4 Identity (com.vodafone360.people.datatypes.Identity)3 StatusMsg (com.vodafone360.people.datatypes.StatusMsg)3 AuthSessionHolder (com.vodafone360.people.datatypes.AuthSessionHolder)2 ServiceUiRequest (com.vodafone360.people.service.ServiceUiRequest)2 QueueManager (com.vodafone360.people.service.io.QueueManager)2 IOException (java.io.IOException)2 ActivityContact (com.vodafone360.people.datatypes.ActivityContact)1 ActivityItem (com.vodafone360.people.datatypes.ActivityItem)1 ExternalResponseObject (com.vodafone360.people.datatypes.ExternalResponseObject)1 IdentityCapability (com.vodafone360.people.datatypes.IdentityCapability)1 PushChatConversationEvent (com.vodafone360.people.datatypes.PushChatConversationEvent)1 PushChatMessageEvent (com.vodafone360.people.datatypes.PushChatMessageEvent)1 PushClosedConversationEvent (com.vodafone360.people.datatypes.PushClosedConversationEvent)1