|
21 | 21 | package com.microfocus.application.automation.tools.octane.configuration; |
22 | 22 |
|
23 | 23 | import com.hp.octane.integrations.OctaneSDK; |
24 | | -import com.hp.octane.integrations.dto.connectivity.OctaneResponse; |
| 24 | +import com.hp.octane.integrations.exceptions.OctaneConnectivityException; |
25 | 25 | import com.microfocus.application.automation.tools.octane.CIJenkinsServicesImpl; |
26 | 26 | import com.microfocus.application.automation.tools.octane.Messages; |
27 | 27 | import hudson.ProxyConfiguration; |
@@ -100,20 +100,14 @@ public static FormValidation checkConfigurationAndWrapWithFormValidation(String |
100 | 100 | } |
101 | 101 |
|
102 | 102 | public static void checkConfiguration(List<String> errorMessages, String location, String sharedSpace, String username, Secret password) { |
103 | | - OctaneResponse checkResponse; |
| 103 | + |
104 | 104 | try { |
105 | | - checkResponse = OctaneSDK.testOctaneConfiguration(location, sharedSpace, username, password.getPlainText(), CIJenkinsServicesImpl.class); |
106 | | - |
107 | | - if (checkResponse.getStatus() == 401) { |
108 | | - errorMessages.add(Messages.AuthenticationFailure()); |
109 | | - } else if (checkResponse.getStatus() == 403) { |
110 | | - errorMessages.add(Messages.AuthorizationFailure()); |
111 | | - } else if (checkResponse.getStatus() == 404) { |
112 | | - errorMessages.add(Messages.ConnectionSharedSpaceInvalid()); |
113 | | - } else if (checkResponse.getStatus() != 200) { |
114 | | - errorMessages.add(Messages.UnexpectedFailure() + ": " + checkResponse.getStatus()); |
115 | | - } |
116 | | - } catch (IOException ioe) { |
| 105 | + OctaneSDK.testAndValidateOctaneConfiguration(location, sharedSpace, username, password.getPlainText(), CIJenkinsServicesImpl.class); |
| 106 | + |
| 107 | + } catch (OctaneConnectivityException octaneException) { |
| 108 | + errorMessages.add(octaneException.getErrorMessageVal()); |
| 109 | + |
| 110 | + }catch (IOException ioe) { |
117 | 111 | logger.warn("Connection check failed due to communication problem", ioe); |
118 | 112 | errorMessages.add(Messages.ConnectionFailure()); |
119 | 113 | } |
|
0 commit comments