use of org.springframework.social.connect.NoSuchConnectionException in project theskeleton by codenergic.
the class SocialConnectionService method removeConnection.
@Override
public void removeConnection(ConnectionKey connectionKey) {
SocialConnectionEntity connection = connectionRepository.findByUserIdAndProviderAndProviderUserId(userId, connectionKey.getProviderId(), connectionKey.getProviderUserId()).orElseThrow(() -> new NoSuchConnectionException(connectionKey));
connectionRepository.delete(connection);
}
use of org.springframework.social.connect.NoSuchConnectionException in project theskeleton by codenergic.
the class SocialConnectionService method updateConnection.
@Override
@Transactional
public void updateConnection(Connection<?> connection) {
ConnectionData data = connection.createData();
SocialConnectionEntity userConnection = connectionRepository.findByUserIdAndProviderAndProviderUserId(userId, data.getProviderId(), data.getProviderUserId()).orElseThrow(() -> new NoSuchConnectionException(connection.getKey())).setDisplayName(data.getDisplayName()).setProfileUrl(data.getProfileUrl()).setImageUrl(data.getImageUrl()).setAccessToken(encrypt(data.getAccessToken())).setSecret(encrypt(data.getSecret())).setRefreshToken(encrypt(data.getRefreshToken())).setExpireTime(data.getExpireTime());
connectionRepository.save(userConnection);
}
Aggregations