Search in sources :

Example 11 with ApplicationKeyMapping

use of org.wso2.carbon.apimgt.keymgt.model.entity.ApplicationKeyMapping 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);
}
Also used : APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) Scope(org.wso2.carbon.apimgt.keymgt.model.entity.Scope) ApiPolicy(org.wso2.carbon.apimgt.keymgt.model.entity.ApiPolicy) API(org.wso2.carbon.apimgt.keymgt.model.entity.API)

Example 12 with ApplicationKeyMapping

use of org.wso2.carbon.apimgt.keymgt.model.entity.ApplicationKeyMapping in project carbon-apimgt by wso2.

the class KeyManagerDataServiceImpl method getApplicationKeyMappingFromApplicationRegistrationEvent.

private ApplicationKeyMapping getApplicationKeyMappingFromApplicationRegistrationEvent(ApplicationRegistrationEvent event) {
    ApplicationKeyMapping mapping = new ApplicationKeyMapping();
    mapping.setApplicationId(event.getApplicationId());
    mapping.setApplicationUUID(event.getApplicationUUID());
    mapping.setConsumerKey(event.getConsumerKey());
    mapping.setKeyType(event.getKeyType());
    mapping.setKeyManager(event.getKeyManager());
    if (log.isDebugEnabled()) {
        log.debug("Event: " + event.toString());
        log.debug("Converted : " + mapping.toString());
    }
    return mapping;
}
Also used : ApplicationKeyMapping(org.wso2.carbon.apimgt.keymgt.model.entity.ApplicationKeyMapping)

Aggregations

ApplicationKeyMapping (org.wso2.carbon.apimgt.api.model.subscription.ApplicationKeyMapping)5 ApplicationKeyMapping (org.wso2.carbon.apimgt.keymgt.model.entity.ApplicationKeyMapping)5 ArrayList (java.util.ArrayList)4 DataLoadingException (org.wso2.carbon.apimgt.keymgt.model.exception.DataLoadingException)4 Gson (com.google.gson.Gson)2 IOException (java.io.IOException)2 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 API (org.wso2.carbon.apimgt.keymgt.model.entity.API)2 ApiPolicy (org.wso2.carbon.apimgt.keymgt.model.entity.ApiPolicy)2 ApplicationKeyMappingList (org.wso2.carbon.apimgt.keymgt.model.entity.ApplicationKeyMappingList)2 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)1 SubscriptionValidationDAO (org.wso2.carbon.apimgt.impl.dao.SubscriptionValidationDAO)1 ApplicationKeyMappingDTO (org.wso2.carbon.apimgt.internal.service.dto.ApplicationKeyMappingDTO)1 ApplicationKeyMappingListDTO (org.wso2.carbon.apimgt.internal.service.dto.ApplicationKeyMappingListDTO)1 SubscriptionDataStore (org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore)1 Application (org.wso2.carbon.apimgt.keymgt.model.entity.Application)1 ApplicationKeyMappingCacheKey (org.wso2.carbon.apimgt.keymgt.model.entity.ApplicationKeyMappingCacheKey)1