private String getSdkToken(ClientSync request) { return request.getClientSyncMetaData().getSdkToken(); }
private void addAppTokenToClientSyncMetaData(ClientSyncMetaData clientSyncMetaData) { clientSyncMetaData.setApplicationToken(getAppToken(clientSyncMetaData.getSdkToken())); }
@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); }); }
private EndpointProfileDto registerEndpoint(String endpointId, int requestHash, ClientSyncMetaData metaData, ProfileClientSync request) { LOG.debug("[{}][{}] register endpoint. request: {}", endpointId, requestHash, request); byte[] endpointKey = toByteArray(request.getEndpointPublicKey()); byte[] profileBody = toByteArray(request.getProfileBody()); RegisterProfileRequest registerProfileRequest = new RegisterProfileRequest( metaData.getApplicationToken(), endpointKey, metaData.getSdkToken(), profileBody, request.getEndpointAccessToken()); EndpointProfileDto endpointProfile = profileService.registerProfile(registerProfileRequest); LOG.debug("profile registered. id: {}, endpointKeyHash: {}", endpointProfile.getId(), endpointProfile.getEndpointKeyHash()); return endpointProfile; }
private EndpointProfileDto updateEndpoint(String endpointId, int requestHash, ClientSyncMetaData metaData, ProfileClientSync request) { LOG.debug("[{}][{}] update endpoint. request: {}", endpointId, requestHash, request); EndpointObjectHash endpointKeyHash = EndpointObjectHash.fromBytes( toByteArray(metaData.getEndpointPublicKeyHash())); UpdateProfileRequest updateRequest = new UpdateProfileRequest( metaData.getApplicationToken(), endpointKeyHash, request.getEndpointAccessToken(), request.getProfileBody().array(), metaData.getSdkToken()); EndpointProfileDto endpointProfile = profileService.updateProfile(updateRequest); LOG.debug("profile updated. id: {}, endpointKeyHash: {}", endpointProfile.getId(), endpointProfile.getEndpointKeyHash()); return endpointProfile; }