protected EndpointProfileDto generateEndpointProfileDtoWithSchemaVersion(String appId, int schemaVersion, String srvProfileBody) { EndpointProfileDto profileDto = new EndpointProfileDto(); profileDto.setApplicationId(appId); profileDto.setServerProfileVersion(schemaVersion); profileDto.setEndpointKeyHash("TEST_KEY_HASH".getBytes()); profileDto.setEpsConfigurationHash(EPS_CONFIG_HASH); try { profileDto.setClientProfileBody(readSchemaFileAsString(TEST_PROFILE_BODY_PATH)); } catch (IOException e) { LOG.error("Can't set client-side EP body {}", e); } profileDto.setSdkToken(UUID.randomUUID().toString()); profileDto.setServerProfileBody(srvProfileBody); return endpointService.saveEndpointProfile(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 generateEndpointProfileDto(String appId, List<String> topicIds) { if (isBlank(appId)) { appId = generateApplicationDto().getId(); } EndpointProfileDto profileDto = new EndpointProfileDto(); profileDto.setApplicationId(appId); profileDto.setSubscriptions(topicIds); profileDto.setEndpointKeyHash("TEST_KEY_HASH".getBytes()); profileDto.setServerProfileBody("{\"serverTitle\": \"SERVER_TEST\"}"); profileDto.setEpsConfigurationHash(EPS_CONFIG_HASH); try { profileDto.setClientProfileBody(readSchemaFileAsString(TEST_PROFILE_BODY_PATH)); } catch (IOException e) { LOG.error("Can't set client-side EP body {}", e); } profileDto.setSdkToken(UUID.randomUUID().toString()); return endpointService.saveEndpointProfile(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(); }
dto.setEndpointKey(request.getEndpointKey()); dto.setEndpointKeyHash(keyHash.getData()); dto.setClientProfileBody(profileJson); dto.setProfileHash(EndpointObjectHash.fromSha1(request.getProfile()).getData());
dto.setEndpointUserId(endpointUserId); dto.setAccessToken(accessToken); dto.setClientProfileBody( profile != null ? MongoDaoUtil.decodeReservedCharacteres(profile).toString()
dto.setEndpointUserId(endpointUserId); dto.setAccessToken(accessToken); dto.setClientProfileBody(profile); dto.setProfileHash(getBytes(profileHash)); dto.setClientProfileVersion(profileVersion);