@@ -76,7 +76,8 @@ List<Map<String, String>> getStatuses(Map<String, ArchivePVOptions> archivePVS,
7676 }
7777
7878 private List <Map <String , String >> getStatusesFromPvListQuery (String archiverURL , List <String > pvs ) {
79- URI pvStatusURI = UriComponentsBuilder .fromUri (URI .create (archiverURL + PV_STATUS_RESOURCE ))
79+ String uriString = archiverURL + PV_STATUS_RESOURCE ;
80+ URI pvStatusURI = UriComponentsBuilder .fromUri (URI .create (uriString ))
8081 .queryParam ("pv" , String .join ("," , pvs ))
8182 .build ()
8283 .toUri ();
@@ -86,10 +87,7 @@ private List<Map<String, String>> getStatusesFromPvListQuery(String archiverURL,
8687 .retrieve ()
8788 .bodyToMono (String .class )
8889 .timeout (Duration .of (TIMEOUT_SECONDS , ChronoUnit .SECONDS ))
89- .onErrorResume (e -> {
90- logger .log (Level .WARNING , String .format ("There was an error getting status from pv list query response with URI: %s. Error: %s" , pvStatusURI , e .getMessage ()));
91- return Mono .empty ();
92- })
90+ .onErrorResume (e -> showError (uriString , e ))
9391 .block ();
9492
9593 try {
@@ -113,10 +111,7 @@ private List<Map<String, String>> getStatusesFromPvListBody(String archiverURL,
113111 .retrieve ()
114112 .bodyToMono (String .class )
115113 .timeout (Duration .of (TIMEOUT_SECONDS , ChronoUnit .SECONDS ))
116- .onErrorResume (e -> {
117- logger .log (Level .WARNING , String .format ("There was an error getting status from pv list body response with URI: %s. Error: %s" , uriString , e .getMessage ()));
118- return Mono .empty ();
119- })
114+ .onErrorResume (e -> showError (uriString , e ))
120115 .block ();
121116
122117 // Structure of response is
@@ -145,10 +140,7 @@ private void submitAction(String values, String endpoint, String aaURL) {
145140 .retrieve ()
146141 .bodyToMono (String .class )
147142 .timeout (Duration .of (TIMEOUT_SECONDS , ChronoUnit .SECONDS ))
148- .onErrorResume (e -> {
149- logger .log (Level .WARNING , String .format ("There was an error submitting action response with URI: %s. Error: %s" , uriString , e .getMessage ()));
150- return Mono .empty ();
151- })
143+ .onErrorResume (e -> showError (uriString , e ))
152144 .block ();
153145 logger .log (Level .FINE , () -> response );
154146
@@ -213,15 +205,12 @@ List<String> getAAPolicies(String aaURL) {
213205 try {
214206 String uriString = aaURL + POLICY_RESOURCE ;
215207 String response = client .get ()
216- .uri (URI .create (aaURL + POLICY_RESOURCE ))
208+ .uri (URI .create (uriString ))
217209 .retrieve ()
218210 .bodyToMono (String .class )
219211 .timeout (Duration .of (10 , ChronoUnit .SECONDS ))
220- .onErrorResume (e -> {
221- logger .log (Level .WARNING , String .format ("There was an error getting version response with URI: %s. Error: %s" , uriString , e .getMessage ()));
222- return Mono .empty ();
223- })
224- .block ();;
212+ .onErrorResume (e -> showError (uriString , e ))
213+ .block ();
225214 Map <String , String > policyMap = objectMapper .readValue (response , Map .class );
226215 return new ArrayList <>(policyMap .keySet ());
227216 } catch (Exception e ) {
@@ -235,15 +224,12 @@ String getVersion(String archiverURL) {
235224 try {
236225 String uriString = archiverURL + ARCHIVER_VERSIONS_RESOURCE ;
237226 String response = client .get ()
238- .uri (URI .create (archiverURL + ARCHIVER_VERSIONS_RESOURCE ))
227+ .uri (URI .create (uriString ))
239228 .retrieve ()
240229 .bodyToMono (String .class )
241230 .timeout (Duration .of (TIMEOUT_SECONDS , ChronoUnit .SECONDS ))
242- .onErrorResume (e -> {
243- logger .log (Level .WARNING , String .format ("There was an error getting version response with URI: %s. Error: %s" , uriString , e .getMessage ()));
244- return Mono .empty ();
245- })
246- .block ();;
231+ .onErrorResume (e -> showError (uriString , e ))
232+ .block ();
247233 Map <String , String > versionMap = objectMapper .readValue (response , Map .class );
248234 String [] mgmtVersion = versionMap .get ("mgmt_version" ).split ("Archiver Appliance Version " );
249235 if (mgmtVersion .length > 1 ) {
@@ -256,4 +242,9 @@ String getVersion(String archiverURL) {
256242 }
257243 return "" ;
258244 }
245+
246+ private Mono <String > showError (String uriString , Throwable error ) {
247+ logger .log (Level .WARNING , String .format ("There was an error getting a response with URI: %s. Error: %s" , uriString , error .getMessage ()));
248+ return Mono .empty ();
249+ }
259250}
0 commit comments