diff options
author | Martin Stockhammer <martin_s@apache.org> | 2016-10-02 15:20:56 +0200 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2016-10-02 15:20:56 +0200 |
commit | 1fd9c951e19a30f7636f4a924cb9e2bf06af2861 (patch) | |
tree | 7e38c34a82a4a567efa7a66db0015a65a1fdf82b /archiva-modules/archiva-web/archiva-rest | |
parent | 229276f8d933089dcfec615189ac31259aa45697 (diff) | |
download | archiva-1fd9c951e19a30f7636f4a924cb9e2bf06af2861.tar.gz archiva-1fd9c951e19a30f7636f4a924cb9e2bf06af2861.zip |
Improving error handling for LDAP configuration
Error is only displayed, if LDAP is used as repository. The error
messages are more detailed and internationalized.
Diffstat (limited to 'archiva-modules/archiva-web/archiva-rest')
-rw-r--r-- | archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java index 5d3aa8e40..e319c3629 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java @@ -132,6 +132,20 @@ public class DefaultRedbackRuntimeConfigurationService rbacManagerChanged || ( redbackRuntimeConfiguration.getRbacManagerImpls().toString().hashCode() != redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration().getRbacManagerImpls().toString().hashCode() ); + boolean ldapConfigured = false; + for (String um : redbackRuntimeConfiguration.getUserManagerImpls()) { + if (um.contains("ldap")) { + ldapConfigured=true; + } + } + if (!ldapConfigured) { + for (String rbm : redbackRuntimeConfiguration.getRbacManagerImpls()) { + if (rbm.contains("ldap")) { + ldapConfigured = true; + } + } + } + redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration ); if ( userManagerChanged ) @@ -149,8 +163,15 @@ public class DefaultRedbackRuntimeConfigurationService roleManager.initialize(); } - ldapConnectionFactory.initialize(); - + if (ldapConfigured) { + try { + ldapConnectionFactory.initialize(); + } catch (Exception e) { + ArchivaRestServiceException newEx = new ArchivaRestServiceException(e.getMessage(), e); + newEx.setErrorKey("error.ldap.connectionFactory.init.failed"); + throw newEx; + } + } Collection<PasswordRule> passwordRules = applicationContext.getBeansOfType( PasswordRule.class ).values(); for ( PasswordRule passwordRule : passwordRules ) @@ -184,16 +205,27 @@ public class DefaultRedbackRuntimeConfigurationService usersCache.setMaxElementsOnDisk( redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsOnDisk() ); - ldapUserMapper.initialize(); + if (ldapConfigured) { + try { + ldapUserMapper.initialize(); + } catch (Exception e) { + ArchivaRestServiceException newEx = new ArchivaRestServiceException(e.getMessage(), e); + newEx.setErrorKey("error.ldap.userMapper.init.failed"); + throw newEx; + } + } //check repositories roles are here !!! return Boolean.TRUE; } - catch ( Exception e ) + catch (ArchivaRestServiceException e) { + log.error(e.getMessage(), e); + throw e; + } catch ( Exception e ) { log.error( e.getMessage(), e ); - throw new ArchivaRestServiceException( e.getMessage(), e ); + throw new ArchivaRestServiceException(e.getMessage(), e); } } |