/** * make deep copy of <code>ServerSync</code> instance. * * @param source is source for copping * @return deep copy of <code>ServerSync</code> instance */ public static ServerSync deepCopy(ServerSync source) { if (source == null) { return null; } ServerSync copy = new ServerSync(); copy.setRequestId(source.getRequestId()); copy.setStatus(source.getStatus()); copy.setUserSync(deepCopy(source.getUserSync())); copy.setRedirectSync(deepCopy(source.getRedirectSync())); copy.setProfileSync(deepCopy(source.getProfileSync())); copy.setNotificationSync(deepCopy(source.getNotificationSync())); copy.setLogSync(deepCopy(source.getLogSync())); copy.setEventSync(deepCopy(source.getEventSync())); copy.setConfigurationSync(deepCopy(source.getConfigurationSync())); return copy; }
/** * Clean <code>ServerSync</code>, which mean that all fields are null. * * @param syncResponse is instance for cleaning */ public static void cleanup(ServerSync syncResponse) { if (syncResponse == null) { return; } syncResponse.setUserSync(null); syncResponse.setRedirectSync(null); syncResponse.setProfileSync(null); syncResponse.setNotificationSync(null); syncResponse.setLogSync(null); syncResponse.setEventSync(null); syncResponse.setConfigurationSync(null); }
/** * Factory method that create instance where the response status set to FAILURE. * * @param requestId the request id * @return the sync context */ public static SyncContext failure(Integer requestId) { ServerSync response = new ServerSync(); response.setRequestId(requestId); response.setStatus(SyncStatus.FAILURE); return new SyncContext(response); }
if (sync.getBootstrapSync() != null) { encode(buf, sync.getBootstrapSync()); extensionCount++; if (sync.getProfileSync() != null) { encode(buf, sync.getProfileSync()); extensionCount++; if (sync.getUserSync() != null) { encode(buf, sync.getUserSync()); extensionCount++; if (sync.getLogSync() != null) { encode(buf, sync.getLogSync()); extensionCount++; if (sync.getConfigurationSync() != null) { encode(buf, sync.getConfigurationSync()); extensionCount++; if (sync.getNotificationSync() != null) { encode(buf, sync.getNotificationSync()); extensionCount++; if (sync.getEventSync() != null) { encode(buf, sync.getEventSync()); extensionCount++; if (sync.getRedirectSync() != null) {
if (response.getProfileSync() != null && response.getProfileSync().getResponseStatus() != SyncResponseStatus.NO_DELTA) { return true; if (response.getConfigurationSync() != null && response.getConfigurationSync().getResponseStatus() != SyncResponseStatus.NO_DELTA) { return true; if (response.getNotificationSync() != null && response.getNotificationSync().getResponseStatus() != SyncResponseStatus.NO_DELTA) { return true; if (response.getEventSync() != null) { if (response.getEventSync().getEventSequenceNumberResponse() != null) { return true; if (response.getEventSync().getEvents() != null && !response.getEventSync().getEvents().isEmpty()) { return true; if (response.getEventSync().getEventListenersResponses() != null && !response.getEventSync().getEventListenersResponses().isEmpty()) { return true; if (response.getUserSync() != null) { UserServerSync userResponse = response.getUserSync(); if (userResponse.getEndpointAttachResponses() != null && !userResponse.getEndpointAttachResponses().isEmpty()) {
private ServerSync buildRedirectionResponse(RedirectionRule redirection, ClientSync request) { RedirectServerSync redirectSyncResponse = new RedirectServerSync( redirection.getAccessPointId()); ServerSync response = new ServerSync(); response.setRequestId(request.getRequestId()); response.setStatus(SyncStatus.REDIRECT); response.setRedirectSync(redirectSyncResponse); return response; }
@Override public void run() { MessageEncoderDecoder crypt = getOrInitCrypt(); Map<Integer, PlatformEncDec> platformEncDecMap = getOrInitMap(platformProtocols); try { ClientSync request = decodeRequest(message, crypt, platformEncDecMap); LOG.trace("Processing request {}", request); BootstrapClientSync bsRequest = request.getBootstrapSync(); Set<ProtocolConnectionData> transports = opsListService.filter(bsRequest.getKeys()); BootstrapServerSync bsResponse = new BootstrapServerSync( bsRequest.getRequestId(), transports); ServerSync response = new ServerSync(); response.setRequestId(request.getRequestId()); response.setStatus(SyncStatus.SUCCESS); response.setBootstrapSync(bsResponse); LOG.trace("Response {}", response); encodeAndForward(message, crypt, platformEncDecMap, response); LOG.trace("Response forwarded to specific transport {}", response); } catch (Exception ex) { processErrors(message.getChannelContext(), message.getErrorBuilder(), ex); } }
private void updateResponseWithUserAttachResults(ServerSync response, UserVerificationResponseMessage message) { if (response.getUserSync() == null) { response.setUserSync(new UserServerSync()); } response.getUserSync().setUserAttachResponse(EntityConvertUtils.convert(message)); }
private void processSeqNumber(EventClientSync request, SyncContext responseHolder) { if (request.isSeqNumberRequest()) { EventServerSync response = responseHolder.getResponse().getEventSync(); if (response == null) { response = new EventServerSync(); responseHolder.getResponse().setEventSync(response); } response.setEventSequenceNumberResponse(new EventSequenceNumberResponse( Math.max(state.getEventSeqNumber(), 0))); } }
LOG.debug("Updating sync response {}", response); boolean modified = false; NotificationServerSync notificationResponse = response.getNotificationSync(); if (notificationResponse == null) { notificationResponse = new NotificationServerSync(); response.setNotificationSync(notificationResponse);
private void encodeMetaData(GrowingByteBuffer buf, ServerSync sync) { buildExtensionHeader(buf, META_DATA_EXTENSION_ID, NOTHING, NOTHING, 8); buf.putInt(sync.getRequestId()); buf.putInt(sync.getStatus().ordinal()); }
private void sendReply(ActorContext context, SyncRequestMessage request, Exception ex, ServerSync syncResponse) { LOG.debug("[{}] response: {}", actorKey, syncResponse); ServerSync copy = ServerSync.deepCopy(syncResponse); ServerSync.cleanup(syncResponse); NettySessionResponseMessage response = new NettySessionResponseMessage( request.getSession(), copy, ex, request.getCommand().getMessageBuilder(), request.getCommand().getErrorBuilder()); tellActor(context, request.getOriginator(), response); scheduleActorTimeout(context); }
public SyncStatus getStatus() { return response.getStatus(); }
public void setConfigurationSyncResponse(ConfigurationServerSync response) { this.response.setConfigurationSync(response); }
private void notifyAffectedEndpoints(ActorContext context, ClientSync request, SyncContext responseHolder) { if (responseHolder.getResponse().getUserSync() != null) { List<EndpointAttachResponse> attachResponses = responseHolder.getResponse() .getUserSync() .getEndpointAttachResponses(); if (attachResponses != null && !attachResponses.isEmpty()) { for (EndpointDetachRequest detachRequest : detachRequests) { List<EndpointDetachResponse> endpointDetachResponses = responseHolder.getResponse() .getUserSync() .getEndpointDetachResponses(); for (EndpointDetachResponse detachResponse : endpointDetachResponses) {
SyncContext context = new SyncContext(new ServerSync()); context.setNotificationVersion(state.getProfile()); context.setRequestId(request.getRequestId());
/** * Converts {@link ServerSync} to Avro {@link SyncResponse}. * * @param source the server sync * @return the Avro sync response */ public static SyncResponse convert(ServerSync source) { SyncResponse sync = new SyncResponse(); sync.setRequestId(source.getRequestId()); sync.setStatus(convert(source.getStatus())); sync.setBootstrapSyncResponse(convert(source.getBootstrapSync())); sync.setRedirectSyncResponse(convert(source.getRedirectSync())); sync.setProfileSyncResponse(convert(source.getProfileSync())); sync.setConfigurationSyncResponse(convert(source.getConfigurationSync())); sync.setNotificationSyncResponse(convert(source.getNotificationSync())); sync.setEventSyncResponse(convert(source.getEventSync())); sync.setUserSyncResponse(convert(source.getUserSync())); sync.setLogSyncResponse(convert(source.getLogSync())); return sync; }
ServerSync pendingResponse = channel.getResponseHolder().getResponse(); UserServerSync userSyncResponse = pendingResponse.getUserSync(); pendingResponse.setUserSync(userSyncResponse);
private void addEventsAndReply(ActorContext context, ChannelMetaData channel, EndpointEventReceiveMessage message) { SyncRequestMessage pendingRequest = channel.getRequestMessage(); SyncContext pendingResponse = channel.getResponseHolder(); EventServerSync eventResponse = pendingResponse.getResponse().getEventSync(); if (eventResponse == null) { eventResponse = new EventServerSync(); pendingResponse.getResponse().setEventSync(eventResponse); } eventResponse.setEvents(message.getEvents()); sendReply(context, pendingRequest, pendingResponse.getResponse()); if (!channel.getType().isAsync()) { state.removeChannel(channel); } }