|
|
@ -65,6 +65,7 @@ import org.wso2.carbon.user.api.UserStoreException;
|
|
|
|
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
|
|
|
|
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* This class represents an implementation of APIManagementProviderService.
|
|
|
|
* This class represents an implementation of APIManagementProviderService.
|
|
|
@ -143,31 +144,29 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
|
|
|
APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices();
|
|
|
|
APIApplicationManagerExtensionDataHolder.getInstance().getConsumerRESTAPIServices();
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
List<APIInfo> uniqueApiList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> headerParams = new HashMap<>();
|
|
|
|
Map<String, String> headerParams = new HashMap<>();
|
|
|
|
if (!"carbon.super".equals(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true))) {
|
|
|
|
if (!"carbon.super".equals(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true))) {
|
|
|
|
headerParams.put("X-WSO2-Tenant", "carbon.super");
|
|
|
|
headerParams.put("X-WSO2-Tenant", "carbon.super");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map <String, APIInfo> uniqueApiSet = new HashMap<>();
|
|
|
|
for (String tag : tags) {
|
|
|
|
for (String tag : tags) {
|
|
|
|
Map<String, String> queryParams = new HashMap<>();
|
|
|
|
Map<String, String> queryParams = new HashMap<>();
|
|
|
|
queryParams.put("tag", tag);
|
|
|
|
queryParams.put("tag", tag);
|
|
|
|
|
|
|
|
|
|
|
|
APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(tokenInfo, queryParams, headerParams);
|
|
|
|
APIInfo[] apiInfos = consumerRESTAPIServices.getAllApis(tokenInfo, queryParams, headerParams);
|
|
|
|
|
|
|
|
Arrays.stream(apiInfos).forEach(apiInfo -> uniqueApiSet.putIfAbsent(apiInfo.getName(), apiInfo));
|
|
|
|
uniqueApiList.addAll(List.of(apiInfos));
|
|
|
|
|
|
|
|
Set<APIInfo> taggedAPISet = new HashSet<>(uniqueApiList);
|
|
|
|
|
|
|
|
uniqueApiList.clear();
|
|
|
|
|
|
|
|
uniqueApiList.addAll(taggedAPISet);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<APIInfo> uniqueApiList = new ArrayList<>(uniqueApiSet.values());
|
|
|
|
|
|
|
|
|
|
|
|
io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications =
|
|
|
|
io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications =
|
|
|
|
consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName);
|
|
|
|
consumerRESTAPIServices.getAllApplications(tokenInfo, applicationName);
|
|
|
|
io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application;
|
|
|
|
io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application;
|
|
|
|
MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService();
|
|
|
|
MetadataManagementService metadataManagementService = APIApplicationManagerExtensionDataHolder.getInstance().getMetadataManagementService();
|
|
|
|
if (applications.length == 0) {
|
|
|
|
if (applications.length == 0) {
|
|
|
|
return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType, validityTime);
|
|
|
|
return handleNewAPIApplication(applicationName, uniqueApiList, tokenInfo, keyType,
|
|
|
|
|
|
|
|
validityTime);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (applications.length == 1) {
|
|
|
|
if (applications.length == 1) {
|
|
|
|
Optional<io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application> applicationOpt =
|
|
|
|
Optional<io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application> applicationOpt =
|
|
|
|