|
|
|
@ -42,14 +42,10 @@ public class APIPublisherUtil {
|
|
|
|
|
public static final String API_VERSION_PARAM = "{version}";
|
|
|
|
|
public static final String API_PUBLISH_ENVIRONMENT = "Production and Sandbox";
|
|
|
|
|
private static final String API_CONFIG_DEFAULT_VERSION = "1.0.0";
|
|
|
|
|
private static final String PARAM_MANAGED_API_NAME = "managed-api-name";
|
|
|
|
|
private static final String PARAM_MANAGED_API_VERSION = "managed-api-version";
|
|
|
|
|
private static final String PARAM_MANAGED_API_CONTEXT = "managed-api-context";
|
|
|
|
|
private static final String PARAM_MANAGED_API_ENDPOINT = "managed-api-endpoint";
|
|
|
|
|
private static final String PARAM_MANAGED_API_OWNER = "managed-api-owner";
|
|
|
|
|
private static final String PARAM_MANAGED_API_TRANSPORTS = "managed-api-transports";
|
|
|
|
|
private static final String PARAM_MANAGED_API_IS_SECURED = "managed-api-isSecured";
|
|
|
|
|
private static final String PARAM_MANAGED_API_APPLICATION = "managed-api-application";
|
|
|
|
|
private static final String PARAM_SHARED_WITH_ALL_TENANTS = "isSharedWithAllTenants";
|
|
|
|
|
private static final String PARAM_PROVIDER_TENANT_DOMAIN = "providerTenantDomain";
|
|
|
|
|
|
|
|
|
@ -125,16 +121,22 @@ public class APIPublisherUtil {
|
|
|
|
|
if (scope != null) {
|
|
|
|
|
if (apiScopes.get(scope.getKey()) == null) {
|
|
|
|
|
apiScopes.put(scope.getKey(), scope);
|
|
|
|
|
} else {
|
|
|
|
|
// this has to be done because of the use of pass by reference
|
|
|
|
|
// where same object reference of scope should be available for both
|
|
|
|
|
// api scope and uri template scope
|
|
|
|
|
template.setScope(apiScopes.get(scope.getKey()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Set<Scope> scopes = new HashSet<>(apiScopes.values());
|
|
|
|
|
api.setScopes(scopes);
|
|
|
|
|
|
|
|
|
|
// this has to be done because of the use of pass by reference
|
|
|
|
|
// where same object reference of scope should be available for both
|
|
|
|
|
// api scope and uri template scope
|
|
|
|
|
for (Scope scope : scopes) {
|
|
|
|
|
for (URITemplate template : uriTemplates) {
|
|
|
|
|
if (scope.getKey().equals(template.getScope().getKey())) {
|
|
|
|
|
template.setScope(scope);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
api.setUriTemplates(uriTemplates);
|
|
|
|
|
}
|
|
|
|
|
return api;
|
|
|
|
@ -202,12 +204,13 @@ public class APIPublisherUtil {
|
|
|
|
|
* Build the API Configuration to be passed to APIM, from a given list of URL templates
|
|
|
|
|
*
|
|
|
|
|
* @param servletContext
|
|
|
|
|
* @param apiDef
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static APIConfig buildApiConfig(ServletContext servletContext, APIResourceConfiguration apidef) {
|
|
|
|
|
public static APIConfig buildApiConfig(ServletContext servletContext, APIResourceConfiguration apiDef) {
|
|
|
|
|
APIConfig apiConfig = new APIConfig();
|
|
|
|
|
|
|
|
|
|
String name = apidef.getName();
|
|
|
|
|
String name = apiDef.getName();
|
|
|
|
|
if (name == null || name.isEmpty()) {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("API Name not set in @API Annotation");
|
|
|
|
@ -216,7 +219,7 @@ public class APIPublisherUtil {
|
|
|
|
|
}
|
|
|
|
|
apiConfig.setName(name);
|
|
|
|
|
|
|
|
|
|
String version = apidef.getVersion();
|
|
|
|
|
String version = apiDef.getVersion();
|
|
|
|
|
if (version == null || version.isEmpty()) {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("'API Version not set in @API Annotation'");
|
|
|
|
@ -226,7 +229,7 @@ public class APIPublisherUtil {
|
|
|
|
|
apiConfig.setVersion(version);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String context = apidef.getContext();
|
|
|
|
|
String context = apiDef.getContext();
|
|
|
|
|
if (context == null || context.isEmpty()) {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("'API Context not set in @API Annotation'");
|
|
|
|
@ -235,7 +238,7 @@ public class APIPublisherUtil {
|
|
|
|
|
}
|
|
|
|
|
apiConfig.setContext(context);
|
|
|
|
|
|
|
|
|
|
String[] tags = apidef.getTags();
|
|
|
|
|
String[] tags = apiDef.getTags();
|
|
|
|
|
if (tags == null || tags.length == 0) {
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
log.debug("'API tag not set in @API Annotation'");
|
|
|
|
@ -300,8 +303,8 @@ public class APIPublisherUtil {
|
|
|
|
|
&& Boolean.parseBoolean(sharingValueParam));
|
|
|
|
|
apiConfig.setSharedWithAllTenants(isSharedWithAllTenants);
|
|
|
|
|
|
|
|
|
|
Set<URITemplate> uriTemplates = new LinkedHashSet<URITemplate>();
|
|
|
|
|
for (APIResource apiResource : apidef.getResources()) {
|
|
|
|
|
Set<URITemplate> uriTemplates = new LinkedHashSet<>();
|
|
|
|
|
for (APIResource apiResource : apiDef.getResources()) {
|
|
|
|
|
URITemplate template = new URITemplate();
|
|
|
|
|
template.setAuthType(apiResource.getAuthType());
|
|
|
|
|
template.setHTTPVerb(apiResource.getHttpVerb());
|
|
|
|
|