use of com.epam.ta.reportportal.entity.oauth.OAuthRegistration in project service-authorization by reportportal.
the class CreateAuthIntegrationHandlerImpl method createOrUpdateOauthSettings.
@Override
public OAuthRegistrationResource createOrUpdateOauthSettings(String oauthProviderId, OAuthRegistrationResource clientRegistrationResource) {
OAuthRegistration oAuthRegistration = OAuthProviderFactory.fillOAuthRegistration(oauthProviderId, clientRegistrationResource);
OAuthRegistration updatedOauthRegistration = clientRegistrationRepository.findOAuthRegistrationById(oauthProviderId).map(existingRegistration -> {
clientRegistrationRepository.deleteById(existingRegistration.getId());
oAuthRegistration.setId(existingRegistration.getId());
return oAuthRegistration;
}).orElse(oAuthRegistration);
return OAuthRegistrationConverters.TO_RESOURCE.apply(clientRegistrationRepository.save(updatedOauthRegistration));
}
use of com.epam.ta.reportportal.entity.oauth.OAuthRegistration in project service-authorization by reportportal.
the class DeleteAuthIntegrationHandlerImpl method deleteOauthSettingsById.
@Override
public OperationCompletionRS deleteOauthSettingsById(String oauthProviderId) {
OAuthRegistration oAuthRegistration = clientRegistrationRepository.findOAuthRegistrationById(oauthProviderId).orElseThrow(() -> new ReportPortalException(ErrorType.AUTH_INTEGRATION_NOT_FOUND, Suppliers.formattedSupplier("Oauth settings with id = {} have not been found.", oauthProviderId).get()));
clientRegistrationRepository.deleteById(oAuthRegistration.getId());
return new OperationCompletionRS(Suppliers.formattedSupplier("Oauth settings with id = '{}' have been successfully removed.", oauthProviderId).get());
}
Aggregations