/** * Calculate notification delta. * * @param appToken application token * @param context context * @param syncRequest the sync request * @return the gets the notification response */ private GetNotificationResponse calculateNotificationDelta(String appToken, NotificationClientSync syncRequest, SyncContext context) { GetNotificationRequest request = new GetNotificationRequest( syncRequest.getTopicListHash(), context.getEndpointProfile(), syncRequest.getSubscriptionCommands(), syncRequest.getAcceptedUnicastNotifications(), syncRequest.getTopicStates()); return notificationDeltaService.getNotificationDelta(request); }
private void parseNotificationClientSync(ClientSync sync, ByteBuffer buf, int options, int payloadLength) { int payloadLimitPosition = buf.position() + payloadLength; NotificationClientSync nfSync = new NotificationClientSync(); nfSync.setTopicListHash(buf.getInt()); while (buf.position() < payloadLimitPosition) { byte fieldId = buf.get(); // reading unused reserved field buf.get(); switch (fieldId) { case NF_TOPIC_STATES_FIELD_ID: nfSync.setTopicStates(parseTopicStates(buf)); break; case NF_UNICAST_LIST_FIELD_ID: nfSync.setAcceptedUnicastNotifications(parseUnicastIds(buf)); break; case NF_SUBSCRIPTION_ADD_FIELD_ID: parseSubscriptionCommands(nfSync, buf, true); break; case NF_SUBSCRIPTION_REMOVE_FIELD_ID: parseSubscriptionCommands(nfSync, buf, false); break; default: break; } } sync.setNotificationSync(nfSync); }
private void parseSubscriptionCommands(NotificationClientSync nfSync, ByteBuffer buf, boolean add) { int count = getIntFromUnsignedShort(buf); if (nfSync.getSubscriptionCommands() == null) { nfSync.setSubscriptionCommands(new ArrayList<>()); } SubscriptionCommandType subscriptionType = add ? SubscriptionCommandType.ADD : SubscriptionCommandType.REMOVE; List<SubscriptionCommand> commands = new ArrayList<>(); for (int i = 0; i < count; i++) { long topicId = buf.getLong(); commands.add(new SubscriptionCommand(topicId, subscriptionType)); } nfSync.getSubscriptionCommands().addAll(commands); }
/** * Calculate different between requests. * * @param oldRequest old request * @param newRequest new request * @return difference */ private NotificationClientSync diff(NotificationClientSync oldRequest, NotificationClientSync newRequest) { if (oldRequest == null) { return newRequest; } else { if ((newRequest.getAcceptedUnicastNotifications() != null && newRequest.getAcceptedUnicastNotifications().size() > 0) || (newRequest.getSubscriptionCommands() != null && newRequest.getSubscriptionCommands().size() > 0) || (newRequest.getTopicListHash() != oldRequest.getTopicListHash())) { return newRequest; } else { return null; } } }
/** * Updates a request. */ public void updateRequest(ServerSync response) { UUID channelUuid = getChannelUuid(); LOG.debug("[{}] Cleanup profile request", channelUuid); request.setProfileSync(null); if (request.getUserSync() != null) { LOG.debug("[{}] Cleanup user request", channelUuid); request.setUserSync(new UserClientSync()); } if (request.getEventSync() != null) { LOG.debug("[{}] Cleanup event request", channelUuid); request.setEventSync(new EventClientSync()); } if (request.getLogSync() != null) { LOG.debug("[{}] Cleanup log request", channelUuid); request.getLogSync().setLogEntries(null); } if (request.getNotificationSync() != null) { LOG.debug("[{}] Cleanup/update notification request", channelUuid); request.getNotificationSync().setSubscriptionCommands(null); request.getNotificationSync().setAcceptedUnicastNotifications(null); } }
? !notificationSync.equals(that.notificationSync) : that.notificationSync != null) { return false;
@Override public int hashCode() { int result = requestId; result = 31 * result + (clientSyncMetaData != null ? clientSyncMetaData.hashCode() : 0); result = 31 * result + (bootstrapSync != null ? bootstrapSync.hashCode() : 0); result = 31 * result + (profileSync != null ? profileSync.hashCode() : 0); result = 31 * result + (forceConfigurationSync ? 1 : 0); result = 31 * result + (configurationSync != null ? configurationSync.hashCode() : 0); result = 31 * result + (forceNotificationSync ? 1 : 0); result = 31 * result + (notificationSync != null ? notificationSync.hashCode() : 0); result = 31 * result + (userSync != null ? userSync.hashCode() : 0); result = 31 * result + (eventSync != null ? eventSync.hashCode() : 0); result = 31 * result + (logSync != null ? logSync.hashCode() : 0); result = 31 * result + (useConfigurationRawSchema ? 1 : 0); return result; }
return null; NotificationClientSync sync = new NotificationClientSync(); sync.setTopicListHash(source.getTopicListHash()); if (source.getAcceptedUnicastNotifications() != null) { sync.setAcceptedUnicastNotifications(new ArrayList<>( source.getAcceptedUnicastNotifications())); sync.setSubscriptionCommands(commands); states.add(new TopicState(state.getTopicId(), state.getSeqNumber())); sync.setTopicStates(states);