@Override public EndpointProfileDto syncServerProfile(String appToken, String endpointKey, EndpointObjectHash key) { EndpointProfileDto profile = refreshServerEndpointProfile(key); profile.setGroupState(new ArrayList<>()); profile = syncProfileState(appToken, endpointKey, profile, false); return profile; }
@Override public EndpointProfileDto updateProfile(ClientSyncMetaData metaData, EndpointObjectHash keyHash, boolean useConfigurationRawSchema) { LOG.debug("Updating Profile for {}", keyHash); EndpointProfileDto dto = endpointService.findEndpointProfileByKeyHash(keyHash.getData()); AppSeqNumber appSeqNumber = cacheService.getAppSeqNumber(metaData.getApplicationToken()); SdkProfileDto sdkProfile = cacheService.getSdkProfileBySdkToken(metaData.getSdkToken()); Function<EndpointProfileDto, EndpointProfileDto> updateFunction = profile -> { populateVersionStates(appSeqNumber.getTenantId(), profile, sdkProfile); profile.setGroupState(new ArrayList<>()); profile.setUseConfigurationRawSchema(useConfigurationRawSchema); profile.setSequenceNumber(0); return profile; }; return updateProfile(updateFunction.apply(dto), (storedProfile, newProfile) -> { return updateFunction.apply(storedProfile); }); }
int curAppSeqNumber = appSeqNumber.getSeqNumber(); HistoryDelta historyDelta = fetchHistory(endpointId, appToken, profile, curAppSeqNumber); profile.setGroupState(historyDelta.getEndpointGroupStates()); profile.setSequenceNumber(curAppSeqNumber); if (historyDelta.isConfigurationChanged() || updateConfiguration) { storedProfile.setEpsConfigurationHash(newProfile.getEpsConfigurationHash()); storedProfile.setGroupState(new ArrayList<>()); return updateFunction.apply(storedProfile).getV1(); });
protected EndpointProfileDto generateEndpointProfileForTestUpdate(String id, byte[] keyHash, List<EndpointGroupStateDto> groupState) { EndpointProfileDto profileDto = new EndpointProfileDto(); profileDto.setId(id); profileDto.setApplicationId(generateStringId()); profileDto.setEndpointKeyHash(keyHash); profileDto.setAccessToken(generateStringId()); profileDto.setGroupState(groupState); profileDto.setSdkToken(UUID.randomUUID().toString()); return profileDto; }
protected EndpointProfileDto generateEndpointProfileWithGroupIdDto(String endpointGroupId) { EndpointProfileDto profileDto = new EndpointProfileDto(); profileDto.setEndpointKeyHash(generateString("TEST_KEY_HASH").getBytes()); String appId = generateApplicationDto().getId(); profileDto.setApplicationId(appId); List<EndpointGroupStateDto> groupState = new ArrayList<>(); groupState.add(new EndpointGroupStateDto(endpointGroupId, null, null)); profileDto.setGroupState(groupState); try { profileDto.setClientProfileBody(readSchemaFileAsString(TEST_PROFILE_BODY_PATH)); } catch (IOException e) { LOG.error("Can't set client-side EP body {}", e); } profileDto.setServerProfileBody("{\"serverTitle\": \"SERVER_TEST\"}"); profileDto.setSdkToken(UUID.randomUUID().toString()); return endpointService.saveEndpointProfile(profileDto); }
protected EndpointProfileDto generateEndpointProfileForTestUpdate(String id, byte[] keyHash, List<EndpointGroupStateDto> cfGroupState) { EndpointProfileDto profileDto = new EndpointProfileDto(); profileDto.setId(id); profileDto.setEndpointKeyHash(keyHash); profileDto.setApplicationId(generateStringId()); profileDto.setAccessToken(generateStringId()); profileDto.setGroupState(cfGroupState); profileDto.setSdkToken(UUID.randomUUID().toString()); profileDto.setEpsConfigurationHash(EPS_CONFIG_HASH); return profileDto; }
@Override public EndpointProfileDto updateProfile(UpdateProfileRequest request) { LOG.debug("Updating Profile for {}", request.getEndpointKeyHash()); EndpointProfileDto dto = endpointService.findEndpointProfileByKeyHash( request.getEndpointKeyHash().getData()); AppSeqNumber appSeqNumber = cacheService.getAppSeqNumber(request.getApplicationToken()); SdkProfileDto sdkProfile = cacheService.getSdkProfileBySdkToken(request.getSdkToken()); String profileJson = decodeProfile( request.getProfile(), appSeqNumber.getAppToken(), sdkProfile.getProfileSchemaVersion()); Function<EndpointProfileDto, EndpointProfileDto> updateFunction = profile -> { if (request.getAccessToken() != null) { profile.setAccessToken(request.getAccessToken()); } profile.setClientProfileBody(profileJson); profile.setProfileHash(EndpointObjectHash.fromSha1(request.getProfile()).getData()); populateVersionStates(appSeqNumber.getTenantId(), profile, sdkProfile); profile.setGroupState(new ArrayList<>()); profile.setSequenceNumber(0); return profile; }; return updateProfile(updateFunction.apply(dto), (storedProfile, newProfile) -> { return updateFunction.apply(storedProfile); }); }
protected EndpointProfileDto generateEndpointProfileWithEndpointGroupId(String appId) { byte[] keyHash = generateBytes(); if (appId == null) { appId = generateStringId(); } EndpointProfileDto profileDto = new EndpointProfileDto(); profileDto.setApplicationId(appId); profileDto.setEndpointKeyHash(keyHash); profileDto.setAccessToken(generateStringId()); profileDto.setClientProfileBody("test profile"); profileDto.setServerProfileBody("test server-side profile"); profileDto.setEpsConfigurationHash(EPS_CONFIG_HASH); List<EndpointGroupStateDto> groupState = new ArrayList<>(); groupState.add(new EndpointGroupStateDto(TEST_ENDPOINT_GROUP_ID, null, null)); profileDto.setGroupState(groupState); profileDto.setSdkToken(UUID.randomUUID().toString()); return endpointProfileDao.save(new CassandraEndpointProfile(profileDto)).toDto(); }
EndpointProfileDto dto = new EndpointProfileDto(); dto.setId(id); dto.setGroupState(DaoUtil.convertDtoList(groupState)); dto.setSequenceNumber(sequenceNumber); dto.setConfigurationHash(configurationHash);
EndpointProfileDto dto = new EndpointProfileDto(); dto.setId(id); dto.setGroupState(DaoUtil.convertDtoList(groupStates)); dto.setSequenceNumber(sequenceNumber); dto.setConfigurationHash(getBytes(configurationHash));