use of com.vodafone360.people.service.io.Request in project 360-Engine-for-Android by 360.
the class TimeOutWatcher method removeRequest.
/**
* Removes a request from being watched for timeouts.
*
* @param request the request to remove
*/
public void removeRequest(Request request) {
// just ignore the request
if (!mIsRunning)
return;
synchronized (QueueManager.getInstance().lock) {
if ((request != null) && (request.getExpiryDate() >= 0) && mRequests != null) {
int index = -1;
for (int i = 0; i < mRequests.size(); i++) {
final Request currentRequest = mRequests.get(i);
if (currentRequest == request) {
index = i;
mRequests.remove(i);
break;
}
}
// notify, we can still sleep!
if (index == 0) {
LogUtils.logV("TimeOutWatcher.removeRequest(): wake up the thread");
QueueManager.getInstance().lock.notify();
}
}
}
}
use of com.vodafone360.people.service.io.Request 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.service.io.Request in project 360-Engine-for-Android by 360.
the class UploadServerContacts method sendNextAddGroupRelationsPage.
/**
* Sends next add contact/group relation request to the server. Many
* contacts can be added by a single request.
*/
private void sendNextAddGroupRelationsPage() {
ContactChangeInfo info = null;
mActiveGroupId = null;
mContactIdList.clear();
mContactChangeInfoList.clear();
List<ContactChangeInfo> groupInfoList = new ArrayList<ContactChangeInfo>();
long startTime = System.nanoTime();
if (!ContactChangeLogTable.fetchContactChangeLog(groupInfoList, ContactChangeType.ADD_GROUP_REL, 0, MAX_UP_PAGE_SIZE, mDb.getReadableDatabase())) {
LogUtils.logE("UploadServerContacts." + "sendNextAddGroupRelationsPage() Unable to fetch add " + "group relations from database");
complete(ServiceStatus.ERROR_DATABASE_CORRUPT);
return;
}
mDbSyncTime += (System.nanoTime() - startTime);
if (groupInfoList.size() == 0) {
moveToNextState();
return;
}
mContactChangeInfoList.clear();
List<ContactChangeInfo> deleteInfoList = new ArrayList<ContactChangeInfo>();
for (int i = 0; i < groupInfoList.size(); i++) {
info = groupInfoList.get(i);
if (info.mServerContactId == null) {
info.mServerContactId = mDb.fetchServerId(info.mLocalContactId);
}
if (info.mServerContactId != null && info.mGroupOrRelId != null) {
if (mActiveGroupId == null) {
mActiveGroupId = info.mGroupOrRelId;
}
if (info.mGroupOrRelId.equals(mActiveGroupId)) {
mContactIdList.add(info.mServerContactId);
mContactChangeInfoList.add(info);
}
continue;
}
LogUtils.logE("UploadServerContact.sendNextAddGroupRelationsPage() " + "Invalid add group change: SID = " + info.mServerContactId + ", gid=" + info.mGroupOrRelId);
deleteInfoList.add(info);
}
mDb.deleteContactChanges(deleteInfoList);
if (mActiveGroupId == null) {
moveToNextState();
return;
}
mGroupList.clear();
GroupItem group = new GroupItem();
group.mId = mActiveGroupId;
mGroupList.add(group);
if (NetworkAgent.getAgentState() != NetworkAgent.AgentState.CONNECTED) {
complete(NetworkAgent.getServiceStatusfromDisconnectReason());
return;
}
mNoOfItemsSent = mGroupList.size();
setReqId(GroupPrivacy.addContactGroupRelations(getEngine(), mContactIdList, mGroupList));
}
use of com.vodafone360.people.service.io.Request in project 360-Engine-for-Android by 360.
the class UploadServerContacts method sendNextDelGroupRelationsPage.
/**
* Sends next delete contact/group relation request to the server.
*/
private void sendNextDelGroupRelationsPage() {
ContactChangeInfo info = null;
mActiveGroupId = null;
mContactChangeInfoList.clear();
List<ContactChangeInfo> groupInfoList = new ArrayList<ContactChangeInfo>();
long startTime = System.nanoTime();
if (!ContactChangeLogTable.fetchContactChangeLog(groupInfoList, ContactChangeType.DELETE_GROUP_REL, 0, MAX_UP_PAGE_SIZE, mDb.getReadableDatabase())) {
LogUtils.logE("UploadServerContacts." + "sendNextDelGroupRelationsPage() Unable to fetch delete " + "group relations from database");
complete(ServiceStatus.ERROR_DATABASE_CORRUPT);
return;
}
mDbSyncTime += (System.nanoTime() - startTime);
if (groupInfoList.size() == 0) {
moveToNextState();
return;
}
mContactChangeInfoList.clear();
List<ContactChangeInfo> deleteInfoList = new ArrayList<ContactChangeInfo>();
for (int i = 0; i < groupInfoList.size(); i++) {
info = groupInfoList.get(i);
if (info.mServerContactId == null) {
info.mServerContactId = mDb.fetchServerId(info.mLocalContactId);
}
if (info.mServerContactId != null && info.mGroupOrRelId != null) {
if (mActiveGroupId == null) {
mActiveGroupId = info.mGroupOrRelId;
}
if (mActiveGroupId.equals(info.mGroupOrRelId)) {
mContactIdList.add(info.mServerContactId);
mContactChangeInfoList.add(info);
}
continue;
}
LogUtils.logE("UploadServerContact.sendNextDelGroupRelationsPage() " + "Invalid delete group change: SID = " + info.mServerContactId + ", gid=" + info.mGroupOrRelId);
deleteInfoList.add(info);
}
mDb.deleteContactChanges(deleteInfoList);
if (mActiveGroupId == null) {
moveToNextState();
return;
}
if (NetworkAgent.getAgentState() != NetworkAgent.AgentState.CONNECTED) {
complete(NetworkAgent.getServiceStatusfromDisconnectReason());
return;
}
mNoOfItemsSent = mContactIdList.size();
setReqId(GroupPrivacy.deleteContactGroupRelationsExt(getEngine(), mActiveGroupId, mContactIdList));
}
use of com.vodafone360.people.service.io.Request in project 360-Engine-for-Android by 360.
the class IdentityEngine method handleGetAvailableIdentitiesResponse.
/**
* Handle Server response to request for available Identities. The response
* should be a list of Identity items. The request is completed with
* ServiceStatus.SUCCESS or ERROR_UNEXPECTED_RESPONSE if the data-type
* retrieved are not Identity items.
*
* @param data List of BaseDataTypes generated from Server response.
*/
private void handleGetAvailableIdentitiesResponse(List<BaseDataType> data) {
LogUtils.logD("IdentityEngine: handleServerGetAvailableIdentitiesResponse");
ServiceStatus errorStatus = getResponseStatus(BaseDataType.AVAILABLE_IDENTITY_DATA_TYPE, data);
if (errorStatus == ServiceStatus.SUCCESS) {
synchronized (mAvailableIdentityList) {
mAvailableIdentityList.clear();
for (BaseDataType item : data) {
Identity identity = (Identity) item;
if (!identity.isIdentityFieldBlankorNull()) {
mAvailableIdentityList.add(identity);
}
}
}
}
pushIdentitiesToUi(ServiceUiRequest.GET_AVAILABLE_IDENTITIES);
LogUtils.logD("IdentityEngine: handleGetAvailableIdentitiesResponse complete request.");
}
Aggregations