use of com.vodafone360.people.service.io.ResponseQueue.DecodedResponse in project 360-Engine-for-Android by 360.
the class SyncMeEngine method processUpdateStatusResponse.
/**
* This method processes the response to status update by setMe() method
* @param resp Response - the expected response datatype is ContactChanges
*/
private void processUpdateStatusResponse(final DecodedResponse resp) {
LogUtils.logD("SyncMeDbUtils processUpdateStatusResponse()");
ServiceStatus status = BaseEngine.getResponseStatus(BaseDataType.CONTACT_CHANGES_DATA_TYPE, resp.mDataTypes);
if (status == ServiceStatus.SUCCESS) {
ContactChanges result = (ContactChanges) resp.mDataTypes.get(0);
LogUtils.logI("SyncMeProfile.processUpdateStatusResponse() - Me profile userId = " + result.mUserProfile.userID);
SyncMeDbUtils.savePresenceStatusResponse(mDbHelper, result);
}
completeUiRequest(status);
}
use of com.vodafone360.people.service.io.ResponseQueue.DecodedResponse in project 360-Engine-for-Android by 360.
the class RequestQueue method clearActiveRequests.
/**
* Return the current (i.e. most recently generated) request id.
*
* @return the current request id.
*/
/*
* public synchronized int getCurrentId(){ return mCurrentRequestId; }
*/
/**
* Clear active requests (i.e add dummy response to response queue).
*
* @param rpgOnly
*/
protected void clearActiveRequests(boolean rpgOnly) {
synchronized (QueueManager.getInstance().lock) {
ResponseQueue rQ = ResponseQueue.getInstance();
for (int i = 0; i < mRequests.size(); i++) {
Request request = mRequests.get(i);
if (request.isActive() && (!rQ.responseExists(request.getRequestId()))) {
if (!rpgOnly || (rpgOnly && ((request.getAuthenticationType() == Request.USE_RPG) || (request.getAuthenticationType() == Request.USE_BOTH)))) {
LogUtils.logE("RequestQueue.clearActiveRequests() Deleting request " + request.getRequestId());
mRequests.remove(i);
// necessarily times out before)
if (request.getExpiryDate() > 0) {
mTimeOutWatcher.removeRequest(request);
}
i--;
rQ.addToResponseQueue(new DecodedResponse(request.getRequestId(), null, request.mEngineId, DecodedResponse.ResponseType.TIMED_OUT_RESPONSE.ordinal()));
}
}
}
}
}
use of com.vodafone360.people.service.io.ResponseQueue.DecodedResponse in project 360-Engine-for-Android by 360.
the class ResponseQueue method addToResponseQueue.
/**
* Adds a response item to the queue.
*
* @param reqId The request ID to add the response for.
* @param data The response data to add to the queue.
* @param source The corresponding engine that fired off the request for the
* response.
*/
public void addToResponseQueue(final DecodedResponse response) {
synchronized (QueueManager.getInstance().lock) {
ServiceStatus status = BaseEngine.getResponseStatus(BaseDataType.UNKNOWN_DATA_TYPE, response.mDataTypes);
if (status == ServiceStatus.ERROR_INVALID_SESSION) {
EngineManager em = EngineManager.getInstance();
if (em != null) {
LogUtils.logE("Logging out the current user because of invalide session");
em.getLoginEngine().logoutAndRemoveUser();
return;
}
}
synchronized (mResponses) {
mResponses.add(response);
}
Request request = RequestQueue.getInstance().removeRequest(response.mReqId);
if (request != null) {
// we suppose the response being handled by the same engine
// that issued the request with the given id
response.mSource = request.mEngineId;
}
mEngMgr = EngineManager.getInstance();
if (mEngMgr != null) {
mEngMgr.onCommsInMessage(response.mSource);
}
}
}
use of com.vodafone360.people.service.io.ResponseQueue.DecodedResponse in project 360-Engine-for-Android by 360.
the class UploadServerContactsTest method reportBackToEngine.
@Override
public void reportBackToEngine(int reqId, EngineId engine) {
Log.d(LOG_TAG, "reportBackToEngine");
ResponseQueue respQueue = ResponseQueue.getInstance();
List<BaseDataType> data = new ArrayList<BaseDataType>();
try {
assertEquals(mEng.engineId(), engine);
synchronized (mEng.mWaitForReqIdLock) {
if (mEng.mActiveReqId == null || mEng.mActiveReqId.intValue() != reqId) {
try {
mEng.mWaitForReqIdLock.wait(MAX_WAIT_FOR_REQ_ID);
} catch (InterruptedException e) {
}
assertEquals(Integer.valueOf(reqId), mEng.mActiveReqId);
}
}
switch(mState) {
case ADD_CONTACT_LIST:
reportBackAddContactSuccess(reqId, data);
break;
case MODIFY_CONTACT_LIST:
reportModifyContactSuccess(reqId, data);
break;
case DELETE_CONTACT_LIST:
reportDeleteContactSuccess(reqId, data);
break;
case DELETE_CONTACT_DETAIL_LIST:
reportDeleteContactDetailSuccess(reqId, data);
break;
case ADD_NEW_GROUP_LIST:
reportBackAddGroupSuccess(reqId, data);
break;
case DELETE_GROUP_LIST:
reportDeleteGroupListSuccess(reqId, data);
break;
default:
fail("Unexpected request from processor");
}
} catch (Throwable err) {
ServerError serverError = new ServerError(ServerError.ErrorType.INTERNALERROR);
serverError.errorDescription = err + "\n";
for (int i = 0; i < err.getStackTrace().length; i++) {
StackTraceElement v = err.getStackTrace()[i];
serverError.errorDescription += "\t" + v + "\n";
}
Log.e(LOG_TAG, "Exception:\n" + serverError.errorDescription);
data.clear();
data.add(serverError);
}
respQueue.addToResponseQueue(new DecodedResponse(reqId, data, engine, DecodedResponse.ResponseType.SERVER_ERROR.ordinal()));
mEng.onCommsInMessage();
Log.d(LOG_TAG, "reportBackToEngine - message added to response queue");
}
use of com.vodafone360.people.service.io.ResponseQueue.DecodedResponse 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()));
}
Aggregations