Skip to content

Commit e39735b

Browse files
author
Chris Wiechmann
committed
Retry request on API-Access endpoint also on Return-Code 404
Fixes #157
1 parent 7f366f2 commit e39735b

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99
- Avoid NPE if given OAuth-Provider Profile is invalid (See issue [#143](https://github.com/Axway-API-Management-Plus/apim-cli/issues/143))
1010
- Actual API-Lookup when using additional criteria V-Host and QueryRoutingVersion (See issue [#151](https://github.com/Axway-API-Management-Plus/apim-cli/issues/151))
1111

12+
### Changed
13+
- Retry request at API access endpoint also for return code 404 (See issue [#157](https://github.com/Axway-API-Management-Plus/apim-cli/issues/157))
14+
1215
### Added
1316
- Exported API-Manager settings now include Null-Values for not set properties (See issue [#150](https://github.com/Axway-API-Management-Plus/apim-cli/issues/150))
1417
- Now Login to API-Manager is considered as successul if Status-Code is between 200-299 or 301 (See issue [#148](https://github.com/Axway-API-Management-Plus/apim-cli/issues/148))

modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAPIAccessAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public APIAccess createAPIAccess(APIAccess apiAccess, AbstractEntity parentEntit
194194
int statusCode = httpResponse.getStatusLine().getStatusCode();
195195
String response = EntityUtils.toString(httpResponse.getEntity());
196196
if(statusCode < 200 || statusCode > 299){
197-
if(statusCode==403 && response.contains("Unknown API")) {
197+
if((statusCode==403 || statusCode==404) && response.contains("Unknown API")) {
198198
LOG.warn("Got unexpected error: 'Unknown API' while creating API-Access ... Try again in 1 second.");
199199
Thread.sleep(1000);
200200
httpResponse = request.execute();

modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAPIAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ public boolean upgradeAccessToNewerAPI(API apiToUpgradeAccess, API referenceAPI,
925925
int statusCode = httpResponse.getStatusLine().getStatusCode();
926926
if(statusCode != 204){
927927
String response = EntityUtils.toString(httpResponse.getEntity());
928-
if(statusCode==403 && response.contains("Unknown API")) {
928+
if((statusCode==403 || statusCode==404) && response.contains("Unknown API")) {
929929
LOG.warn("Got unexpected error: 'Unknown API' while granting access to newer API ... Try again in 1 second.");
930930
Thread.sleep(1000);
931931
httpResponse = request.execute();
@@ -975,7 +975,7 @@ public void grantClientOrganization(List<Organization> grantAccessToOrgs, API ap
975975
int statusCode = httpResponse.getStatusLine().getStatusCode();
976976
if(statusCode != 204){
977977
String response = EntityUtils.toString(httpResponse.getEntity());
978-
if(statusCode==403 && response.contains("Unknown API")) {
978+
if((statusCode==403 || statusCode==404) && response.contains("Unknown API")) {
979979
LOG.warn("Got unexpected error: 'Unknown API' while creating API-Access ... Try again in 1 second.");
980980
Thread.sleep(1000);
981981
httpResponse = apiCall.execute();

0 commit comments

Comments
 (0)