Search in sources :

Example 1 with NoSuchConnectionException

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);
}
Also used : NoSuchConnectionException(org.springframework.social.connect.NoSuchConnectionException)

Example 2 with NoSuchConnectionException

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);
}
Also used : NoSuchConnectionException(org.springframework.social.connect.NoSuchConnectionException) ConnectionData(org.springframework.social.connect.ConnectionData) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

NoSuchConnectionException (org.springframework.social.connect.NoSuchConnectionException)2 ConnectionData (org.springframework.social.connect.ConnectionData)1 Transactional (org.springframework.transaction.annotation.Transactional)1