com.axway.apim.config.APIConfig Maven / Gradle / Ivy
The newest version!
package com.axway.apim.config;
import com.axway.apim.api.API;
import com.axway.apim.api.model.*;
import com.axway.apim.config.model.APISecurity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import java.util.*;
@JsonPropertyOrder({"name", "path", "state", "version", "organization", "apiSpecification", "summary", "descriptionType", "descriptionManual", "vhost", "remoteHost",
"backendBasepath", "image", "inboundProfiles", "outboundProfiles", "securityProfiles", "authenticationProfiles", "tags", "customProperties",
"corsProfiles", "caCerts"})
public class APIConfig {
public static final String DEFAULT = "_default";
private final API api;
private final String apiDefinition;
private final Map securityProfiles;
public APIConfig(API api, String apiDefinition, Map securityProfiles) {
this.api = api;
this.apiDefinition = apiDefinition;
this.securityProfiles = securityProfiles;
}
public Map getOutboundProfiles() {
if (api.getOutboundProfiles() == null) return Collections.emptyMap();
if (api.getOutboundProfiles().isEmpty()) return Collections.emptyMap();
if (api.getOutboundProfiles().size() == 1) {
OutboundProfile defaultProfile = api.getOutboundProfiles().get(DEFAULT);
if (defaultProfile.getRouteType().equals("proxy")
&& defaultProfile.getAuthenticationProfile().equals(DEFAULT)
&& defaultProfile.getRequestPolicy() == null
&& defaultProfile.getResponsePolicy() == null
) return Collections.emptyMap();
}
for (OutboundProfile profile : api.getOutboundProfiles().values()) {
profile.setApiId(null);
// If the AuthenticationProfile is _default there is no need to export it, hence null is returned
if (DEFAULT.equals(profile.getAuthenticationProfile())) {
profile.setAuthenticationProfile(null);
}
}
return api.getOutboundProfiles();
}
public List