/** * Get endpoints ids by access token. * * @param accessToken is endpoint key hash * @return endpoint key hash */ public ByteBuffer findEpIdByAccessToken(String accessToken) { LOG.debug("Try to find endpoint key hash by access token {}", accessToken); ByteBuffer endpointKeyHash = null; CassandraEpByAccessToken result = findById(accessToken); if (result != null) { endpointKeyHash = result.getEndpointKeyHash(); } return endpointKeyHash; } }
private CassandraEndpointProfile saveProfile(CassandraEndpointProfile profile) { profile.setId(convertKeyHashToString(profile.getEndpointKeyHash())); LOG.debug("Saving endpoint profile with id {}", profile.getId()); profile = super.save(profile); ByteBuffer epKeyHash = profile.getEndpointKeyHash(); List<Statement> statementList = new ArrayList<>(); statementList.add(cassandraEpByAppIdDao.getSaveQuery( new CassandraEpByAppId(profile.getApplicationId(), epKeyHash))); String accessToken = profile.getAccessToken(); if (accessToken != null) { statementList.add( cassandraEpByAccessTokenDao.getSaveQuery( new CassandraEpByAccessToken(accessToken, epKeyHash))); } statementList.add(getSaveQuery(profile)); Statement saveBySdkTokenId = cassandraEpBySdkTokenDao.getSaveQuery( new CassandraEpBySdkToken(profile.getSdkToken(), epKeyHash)); statementList.add(saveBySdkTokenId); Set<String> groupIdSet = getEndpointProfilesGroupIdSet(profile); for (String groupId : groupIdSet) { statementList.add( cassandraEpByEndpointGroupIdDao.getSaveQuery( new CassandraEpByEndpointGroupId(groupId, epKeyHash))); } executeBatch(statementList.toArray(new Statement[statementList.size()])); LOG.debug("[{}] Endpoint profile saved", profile.getId()); return profile; }
new CassandraEpByAccessToken(accessToken, epKeyHash)));