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;
}