private static UserServerSync deepCopy(UserServerSync source) { if (source == null) { return null; } UserServerSync copy = new UserServerSync(); if (source.getEndpointAttachResponses() != null) { copy.setEndpointAttachResponses(new ArrayList<>(source.getEndpointAttachResponses())); } if (source.getEndpointDetachResponses() != null) { copy.setEndpointDetachResponses(new ArrayList<>(source.getEndpointDetachResponses())); } if (source.getUserAttachNotification() != null) { copy.setUserAttachNotification(new UserAttachNotification( source.getUserAttachNotification().getUserExternalId(), source .getUserAttachNotification().getEndpointAccessToken())); } if (source.getUserAttachResponse() != null) { UserAttachResponse uarSource = source.getUserAttachResponse(); copy.setUserAttachResponse(new UserAttachResponse( uarSource.getResult(), uarSource.getErrorCode(), uarSource.getErrorReason())); } if (source.getUserDetachNotification() != null) { copy.setUserDetachNotification(new UserDetachNotification( source.getUserDetachNotification().getEndpointAccessToken())); } return copy; }
private UserServerSync processUserSyncRequest(String endpointId, int requestHash, UserClientSync request, EndpointProfileDto profile) { UserServerSync response = new UserServerSync(); if (request.getEndpointAttachRequests() != null) { response.setEndpointAttachResponses(processEndpointAttachRequests( endpointId, requestHash, request, profile)); } if (request.getEndpointDetachRequests() != null) { response.setEndpointDetachResponses(processEndpointDetachRequests( endpointId, requestHash, request, profile)); } return response; }
private void updateResponseWithUserAttachResults(ServerSync response, UserVerificationResponseMessage message) { if (response.getUserSync() == null) { response.setUserSync(new UserServerSync()); } response.getUserSync().setUserAttachResponse(EntityConvertUtils.convert(message)); }
if (source.getUserAttachNotification() != null) { sync.setUserAttachNotification( new UserAttachNotification(source.getUserAttachNotification().getUserExternalId(), source .getUserAttachNotification().getEndpointAccessToken())); if (source.getUserDetachNotification() != null) { sync.setUserDetachNotification(new UserDetachNotification( source.getUserDetachNotification().getEndpointAccessToken())); if (source.getUserAttachResponse() != null) { sync.setUserAttachResponse(convert(source.getUserAttachResponse())); if (source.getEndpointAttachResponses() != null) { List<EndpointAttachResponse> responses = new ArrayList<>( source.getEndpointAttachResponses().size()); for (org.kaaproject.kaa.server.sync.EndpointAttachResponse response : source.getEndpointAttachResponses()) { responses.add(new EndpointAttachResponse( response.getRequestId(), response.getEndpointKeyHash(), convert(response if (source.getEndpointDetachResponses() != null) { List<EndpointDetachResponse> responses = new ArrayList<>( source.getEndpointDetachResponses().size()); for (org.kaaproject.kaa.server.sync.EndpointDetachResponse response : source.getEndpointDetachResponses()) { responses.add(new EndpointDetachResponse( response.getRequestId(), convert(response.getResult())));
userSyncResponse = new UserServerSync(); pendingResponse.setUserSync(userSyncResponse); if (message instanceof EndpointUserAttachMessage) { userSyncResponse .setUserAttachNotification( new UserAttachNotification(message.getUserId(), message.getOriginator())); LOG.debug("[{}][{}] Adding user attach notification", endpointKey, actorKey); } else if (message instanceof EndpointUserDetachMessage) { userSyncResponse.setUserDetachNotification( new UserDetachNotification(message.getOriginator())); LOG.debug("[{}][{}] Adding user detach notification", endpointKey, actorKey);
List<EndpointAttachResponse> attachResponses = responseHolder.getResponse() .getUserSync() .getEndpointAttachResponses(); if (attachResponses != null && !attachResponses.isEmpty()) { state.resetEventSeqNumber(); List<EndpointDetachResponse> endpointDetachResponses = responseHolder.getResponse() .getUserSync() .getEndpointDetachResponses(); for (EndpointDetachResponse detachResponse : endpointDetachResponses) { if (detachRequest.getRequestId() == detachResponse.getRequestId()) {
if (userResponse.getEndpointAttachResponses() != null && !userResponse.getEndpointAttachResponses().isEmpty()) { return true; if (userResponse.getEndpointDetachResponses() != null && !userResponse.getEndpointDetachResponses().isEmpty()) { return true; if (userResponse.getUserAttachResponse() != null) { return true; if (userResponse.getUserAttachNotification() != null) { return true; if (userResponse.getUserDetachNotification() != null) { return true;
private void encode(GrowingByteBuffer buf, UserServerSync userSync) { buildExtensionHeader(buf, USER_EXTENSION_ID, NOTHING, NOTHING, 0); final int extPosition = buf.position(); if (userSync.getUserAttachResponse() != null) { UserAttachResponse uaResponse = userSync.getUserAttachResponse(); buf.put(USER_ATTACH_RESPONSE_FIELD_ID); buf.put(NOTHING); if (userSync.getUserAttachNotification() != null) { UserAttachNotification nf = userSync.getUserAttachNotification(); buf.put(USER_ATTACH_NOTIFICATION_FIELD_ID); buf.put((byte) nf.getUserExternalId().length()); if (userSync.getUserDetachNotification() != null) { UserDetachNotification nf = userSync.getUserDetachNotification(); buf.put(USER_DETACH_NOTIFICATION_FIELD_ID); buf.put(NOTHING); if (userSync.getEndpointAttachResponses() != null) { buf.put(ENDPOINT_ATTACH_RESPONSE_FIELD_ID); buf.put(NOTHING); buf.putShort((short) userSync.getEndpointAttachResponses().size()); for (EndpointAttachResponse response : userSync.getEndpointAttachResponses()) { buf.put(response.getResult() == SyncStatus.SUCCESS ? SUCCESS : FAILURE); if (response.getEndpointKeyHash() != null) { if (userSync.getEndpointDetachResponses() != null) { buf.put(ENDPOINT_DETACH_RESPONSE_FIELD_ID); buf.put(NOTHING); buf.putShort((short) userSync.getEndpointDetachResponses().size());