Improve the functionality

pull/142/head
Dharmakeerthi Lasantha 1 year ago
parent 189a572d31
commit c227969a61

@ -50,7 +50,7 @@ public interface APIManagementProviderService {
String keyType, String username, boolean isAllowedAllDomains, String keyType, String username, boolean isAllowedAllDomains,
String validityTime) throws APIManagerException; String validityTime) throws APIManagerException;
ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags,
String keyType, String username, String keyType, String username,
boolean isAllowedAllDomains, boolean isAllowedAllDomains,
String validityTime, String password) throws APIManagerException; String validityTime, String password) throws APIManagerException;

@ -103,7 +103,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
} }
@Override @Override
public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String tags[], public synchronized ApiApplicationKey generateAndRetrieveApplicationKeys(String applicationName, String[] tags,
String keyType, String username, String keyType, String username,
boolean isAllowedAllDomains, boolean isAllowedAllDomains,
String validityTime, String password) String validityTime, String password)
@ -116,15 +116,10 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
ApiApplicationInfo applicationInfo = applicationInfo(apiApplicationServices, username, password); ApiApplicationInfo applicationInfo = applicationInfo(apiApplicationServices, username, password);
try { try {
io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications =
consumerRESTAPIServices.getAllApplications(applicationInfo, applicationName);
io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application;
List<APIInfo> uniqueApiList = new ArrayList<>(); List<APIInfo> uniqueApiList = new ArrayList<>();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true);
Map<String, String> headerParams = new HashMap<>(); Map<String, String> headerParams = new HashMap<>();
if (!"carbon.super".equals(tenantDomain)) { if (!"carbon.super".equals(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true))) {
headerParams.put("X-WSO2-Tenant", "carbon.super"); headerParams.put("X-WSO2-Tenant", "carbon.super");
} }
@ -140,6 +135,9 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
uniqueApiList.addAll(taggedAPISet); uniqueApiList.addAll(taggedAPISet);
} }
io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application[] applications =
consumerRESTAPIServices.getAllApplications(applicationInfo, applicationName);
io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application application;
if (applications.length == 0) { if (applications.length == 0) {
application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application(); application = new io.entgra.device.mgt.core.apimgt.extension.rest.api.bean.APIMConsumer.Application();
application.setName(applicationName); application.setName(applicationName);
@ -151,13 +149,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
Arrays.stream(applications).findFirst(); Arrays.stream(applications).findFirst();
application = applicationOpt.get(); application = applicationOpt.get();
Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(applicationInfo, application.getApplicationId()); Subscription[] subscriptions = consumerRESTAPIServices.getAllSubscriptions(applicationInfo, application.getApplicationId());
for (Subscription subscription : subscriptions) { Arrays.stream(subscriptions).map(Subscription::getApiInfo).forEachOrdered(uniqueApiList::remove);
if (uniqueApiList.contains(subscription.getApiInfo())) {
uniqueApiList.remove(subscription.getApiInfo());
} else {
uniqueApiList.add(subscription.getApiInfo());
}
}
addSubscriptions(application, uniqueApiList, applicationInfo); addSubscriptions(application, uniqueApiList, applicationInfo);
} else { } else {
String msg = "Found more than one application for application name: " + applicationName; String msg = "Found more than one application for application name: " + applicationName;

Loading…
Cancel
Save