/** * Checks if is first request. * * @param profile the profile * @return true, if is first request */ public static boolean isFirstRequest(EndpointProfileDto profile) { return profile.getGroupState() == null || profile.getGroupState().size() == 0; }
/** * Gets the old group map. * * @param profile the profile * @return the old group map */ private Map<String, EndpointGroupStateDto> getOldGroupMap(EndpointProfileDto profile) { return profile.getGroupState().stream().collect( Collectors.toMap(EndpointGroupStateDto::getEndpointGroupId, Function.identity())); } }
@Override public TopicListCacheEntry getTopicListHash(String appToken, String endpointId, EndpointProfileDto profile) { LOG.debug("[{}][{}] Calculating new topic list", appToken, endpointId); List<TopicDto> topics = recalculateTopicList(profile.getGroupState()); Collections.sort(topics); long[] ids = new long[topics.size()]; StringJoiner joiner = new StringJoiner("|"); for (int i = 0; i < topics.size(); i++) { Long id = Long.valueOf(topics.get(i).getId()); ids[i] = id.longValue(); joiner.add(id.toString()); } int simpleHash = Arrays.hashCode(ids); EndpointObjectHash complexHash = EndpointObjectHash.fromBytes( Sha1HashUtils.hashToBytes(joiner.toString())); TopicListCacheEntry entry = new TopicListCacheEntry(simpleHash, complexHash, topics); cacheService.putTopicList(complexHash, entry); LOG.debug("[{}][{}] Calculated new topic list {}", appToken, endpointId, entry); return entry; }
private PageLinkDto getPageLinkDto() { List<EndpointProfileDto> endpointProfileList = new ArrayList<>(); for (int i = 0; i < GENERATED_PROFILES_COUNT; i++) { endpointProfileList.add(generateEndpointProfileWithEndpointGroupId(TEST_APPID)); } String id = endpointProfileList.get(0).getGroupState().get(0).getEndpointGroupId(); return new PageLinkDto(id, TEST_LIMIT, TEST_OFFSET); }
@Override public ConfigurationCacheEntry getConfiguration(String appToken, String endpointId, EndpointProfileDto profile) throws GetDeltaException { LOG.debug("[{}][{}] Calculating new configuration", appToken, endpointId); AppVersionKey appConfigVersionKey = new AppVersionKey(appToken, profile.getConfigurationVersion()); EndpointObjectHash userConfHash = EndpointObjectHash.fromBytes(profile .getUserConfigurationHash()); EndpointObjectHash epsConfHash = EndpointObjectHash.fromBytes(profile .getEpsConfigurationHash()); DeltaCacheKey deltaKey = new DeltaCacheKey(appConfigVersionKey, profile.getGroupState(), userConfHash, epsConfHash, null, profile.isUseConfigurationRawSchema(), true); LOG.debug("[{}][{}] Built resync delta key {}", appToken, endpointId, deltaKey); return getDelta(endpointId, profile.getEndpointUserId(), deltaKey, profile.isUseConfigurationRawSchema()); }
if (profile.getGroupState() != null && profile.getGroupState().size() > 0) { historyDelta.setEndpointGroupStates(profile.getGroupState()); } else { historyDelta.setEndpointGroupStates(new ArrayList<>());
if (endpointProfile.getGroupState() != null) { for (EndpointGroupStateDto endpointGroupState : endpointProfile.getGroupState()) { endpointGroupsSet.add(controlService.getEndpointGroup( endpointGroupState.getEndpointGroupId()));
this.endpointUserId = dto.getEndpointUserId(); this.accessToken = dto.getAccessToken(); this.groupState = MongoDaoUtil.convertDtoToModelList(dto.getGroupState()); this.sequenceNumber = dto.getSequenceNumber(); this.epsConfigurationHash = dto.getEpsConfigurationHash();
this.endpointUserId = dto.getEndpointUserId(); this.accessToken = dto.getAccessToken(); this.groupStates = convertDtoToModelList(dto.getGroupState()); this.sequenceNumber = dto.getSequenceNumber(); this.profile = dto.getClientProfileBody();