Skip to content

Commit 082cc9d

Browse files
committed
Fix #301
1 parent 4071e3f commit 082cc9d

1 file changed

Lines changed: 14 additions & 19 deletions

File tree

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

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ public String getEndpoint() {
8484
}
8585
}
8686

87-
;
88-
8987
public APIManagerAPIAdapter() {
9088
cmd = CoreParameters.getInstance();
9189
}
@@ -175,10 +173,9 @@ URI getAPIRequestUri(APIFilter filter) throws URISyntaxException, AppException {
175173
if (filter.getId() != null) {
176174
requestedId = "/" + filter.getId();
177175
}
178-
URI uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + "/" + filter.getApiType() + requestedId)
176+
return new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + "/" + filter.getApiType() + requestedId)
179177
.addParameters(filter.getFilters())
180178
.build();
181-
return uri;
182179
}
183180

184181
API getUniqueAPI(List<API> foundAPIs, APIFilter filter) throws AppException {
@@ -454,7 +451,7 @@ public void addClientApplications(API api) throws AppException {
454451
private void addClientApplications(API api, APIFilter filter) throws AppException {
455452
if (!filter.isIncludeClientApplications()) return;
456453
List<ClientApplication> existingClientApps = new ArrayList<>();
457-
List<ClientApplication> apps = null;
454+
List<ClientApplication> apps;
458455
// With version >7.7 we can retrieve the subscribed apps directly
459456
if (APIManagerAdapter.hasAPIManagerVersion("7.7")) {
460457
apps = APIManagerAdapter.getInstance().appAdapter.getAppsSubscribedWithAPI(api.getId());
@@ -565,7 +562,6 @@ private void addBackendResourcePath(API api, APISpecification apiDefinition, boo
565562
}
566563
// In any case, we save the backend resource path, as it is necessary for the full backendBasepath in the exported API config.
567564
api.setBackendResourcePath(resourcePath);
568-
return;
569565
} catch (Exception e) {
570566
throw new AppException("Cannot parse Backend-API for API: '" + api.toStringHuman() + "' in order to change API-Specification", ErrorCode.CANT_READ_API_DEFINITION_FILE, e);
571567
} finally {
@@ -594,8 +590,7 @@ public API createAPIProxy(API api) throws AppException {
594590
LOG.error("Error creating API-Proxy (FE-API) using URI: " + uri + ". Received Status-Code: " + statusCode + ", Response: '" + response + "'");
595591
throw new AppException("Error creating API-Proxy (FE-API). Received Status-Code: " + statusCode, ErrorCode.CANT_CREATE_API_PROXY);
596592
}
597-
API apiProxy = mapper.readValue(response, API.class);
598-
return apiProxy;
593+
return mapper.readValue(response, API.class);
599594
} catch (Exception e) {
600595
throw new AppException("Can't create API-Proxy.", ErrorCode.CANT_CREATE_API_PROXY, e);
601596
} finally {
@@ -639,8 +634,7 @@ public API updateAPIProxy(API api) throws AppException {
639634
LOG.debug("Request sent:" + EntityUtils.toString(entity));
640635
throw new AppException("Error updating API-Proxy. Response-Code: " + statusCode + "", ErrorCode.API_MANAGER_COMMUNICATION);
641636
}
642-
API apiProxy = mapper.readValue(response, API.class);
643-
return apiProxy;
637+
return mapper.readValue(response, API.class);
644638
} catch (Exception e) {
645639
throw new AppException("Cannot update API-Proxy.", ErrorCode.CANT_UPDATE_API_PROXY, e);
646640
} finally {
@@ -867,7 +861,6 @@ public API importBackendAPI(API api) throws AppException {
867861

868862
private JsonNode importFromWSDL(API api) throws IOException {
869863
URI uri;
870-
HttpEntity entity = new StringEntity("", ContentType.APPLICATION_FORM_URLENCODED);
871864
String username;
872865
String pass;
873866
String wsdlUrl;
@@ -884,16 +877,18 @@ private JsonNode importFromWSDL(API api) throws IOException {
884877
pass = parser.getPassword();
885878

886879
try {
887-
URIBuilder uriBuilder = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + "/apirepo/importFromUrl/")
888-
.setParameter("organizationId", api.getOrganization().getId())
889-
.setParameter("type", "wsdl")
890-
.setParameter("url", wsdlUrl)
891-
.setParameter("name", api.getName());
880+
uri = new URIBuilder(cmd.getAPIManagerURL()).setPath(cmd.getApiBasepath() + "/apirepo/importFromUrl/").build();
881+
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
882+
883+
nameValuePairs.add(new BasicNameValuePair("organizationId", api.getOrganization().getId()));
884+
nameValuePairs.add(new BasicNameValuePair("type", "wsdl"));
885+
nameValuePairs.add(new BasicNameValuePair("url", wsdlUrl));
886+
nameValuePairs.add(new BasicNameValuePair("name", api.getName()));
892887
if (username != null) {
893-
uriBuilder.setParameter("username", username);
894-
uriBuilder.setParameter("password", pass);
888+
nameValuePairs.add(new BasicNameValuePair("username", username));
889+
nameValuePairs.add(new BasicNameValuePair("password", pass));
895890
}
896-
uri = uriBuilder.build();
891+
HttpEntity entity = new UrlEncodedFormEntity(nameValuePairs);
897892
RestAPICall importWSDL = new POSTRequest(entity, uri);
898893
httpResponse = importWSDL.execute();
899894
int statusCode = httpResponse.getStatusLine().getStatusCode();

0 commit comments

Comments
 (0)