use of org.wso2.carbon.apimgt.keymgt.model.impl.SubscriptionDataLoaderImpl in project carbon-apimgt by wso2.
the class SubscriptionDataStoreImpl method initializeLoadingTasks.
public void initializeLoadingTasks() {
Runnable apiTask = new PopulateTask<>(apiMap, () -> {
try {
log.debug("Calling loadAllApis. ");
List<API> apiList = new SubscriptionDataLoaderImpl().loadAllApis(tenantDomain);
apiByUUIDMap.clear();
for (API api : apiList) {
apiByUUIDMap.put(api.getUuid(), api);
String key = api.getApiName().concat(":").concat(api.getApiVersion());
apiNameVersionMap.put(key, api);
}
apisInitialized = true;
return apiList;
} catch (APIManagementException e) {
log.error("Exception while loading APIs " + e);
}
return null;
});
executorService.schedule(apiTask, 0, TimeUnit.SECONDS);
Runnable subscriptionLoadingTask = new PopulateTask<>(subscriptionMap, () -> {
try {
log.debug("Calling loadAllSubscriptions.");
return new SubscriptionDataLoaderImpl().loadAllSubscriptions(tenantDomain);
} catch (APIManagementException e) {
log.error("Exception while loading Subscriptions " + e);
}
return null;
});
executorService.schedule(subscriptionLoadingTask, 0, TimeUnit.SECONDS);
Runnable applicationLoadingTask = new PopulateTask<>(applicationMap, () -> {
try {
log.debug("Calling loadAllApplications.");
return new SubscriptionDataLoaderImpl().loadAllApplications(tenantDomain);
} catch (APIManagementException e) {
log.error("Exception while loading Applications " + e);
}
return null;
});
executorService.schedule(applicationLoadingTask, 0, TimeUnit.SECONDS);
Runnable keyMappingsTask = new PopulateTask<>(applicationKeyMappingMap, () -> {
try {
log.debug("Calling loadAllKeyMappings.");
return new SubscriptionDataLoaderImpl().loadAllKeyMappings(tenantDomain);
} catch (APIManagementException e) {
log.error("Exception while loading ApplicationKeyMapping " + e);
}
return null;
});
executorService.schedule(keyMappingsTask, 0, TimeUnit.SECONDS);
Runnable apiPolicyLoadingTask = new PopulateTask<>(apiPolicyMap, () -> {
try {
log.debug("Calling loadAllSubscriptionPolicies.");
List<ApiPolicy> apiPolicyList = new SubscriptionDataLoaderImpl().loadAllAPIPolicies(tenantDomain);
apiPoliciesInitialized = true;
return apiPolicyList;
} catch (APIManagementException e) {
log.error("Exception while loading api Policies " + e);
}
return null;
});
executorService.schedule(apiPolicyLoadingTask, 0, TimeUnit.SECONDS);
Runnable subPolicyLoadingTask = new PopulateTask<>(subscriptionPolicyMap, () -> {
try {
log.debug("Calling loadAllSubscriptionPolicies.");
return new SubscriptionDataLoaderImpl().loadAllSubscriptionPolicies(tenantDomain);
} catch (APIManagementException e) {
log.error("Exception while loading Subscription Policies " + e);
}
return null;
});
executorService.schedule(subPolicyLoadingTask, 0, TimeUnit.SECONDS);
Runnable appPolicyLoadingTask = new PopulateTask<>(appPolicyMap, () -> {
try {
log.debug("Calling loadAllAppPolicies.");
return new SubscriptionDataLoaderImpl().loadAllAppPolicies(tenantDomain);
} catch (APIManagementException e) {
log.error("Exception while loading Application Policies " + e);
}
return null;
});
executorService.schedule(appPolicyLoadingTask, 0, TimeUnit.SECONDS);
Runnable scopesLoadingTask = new PopulateTask<>(scopesMap, () -> {
try {
log.debug("Calling loadAllScopes.");
List<Scope> scopeList = new SubscriptionDataLoaderImpl().loadAllScopes(tenantDomain);
scopesInitialized = true;
return scopeList;
} catch (APIManagementException e) {
log.error("Exception while loading Scopes " + e);
}
return null;
});
executorService.schedule(scopesLoadingTask, 0, TimeUnit.SECONDS);
}
use of org.wso2.carbon.apimgt.keymgt.model.impl.SubscriptionDataLoaderImpl in project carbon-apimgt by wso2.
the class SubscriptionDataStoreImpl method addOrUpdateApiPolicy.
@Override
public void addOrUpdateApiPolicy(ApiPolicy apiPolicy) {
try {
ApiPolicy policy = new SubscriptionDataLoaderImpl().getAPIPolicy(apiPolicy.getName(), tenantDomain);
apiPolicyMap.remove(apiPolicy.getCacheKey());
apiPolicyMap.put(apiPolicy.getCacheKey(), policy);
} catch (DataLoadingException e) {
log.error("Exception while loading api policy for " + apiPolicy.getName() + " for domain " + tenantDomain, e);
}
}
Aggregations