wso2 / product-microgateway

Choreo Connect is a cloud-native, open-source, and developer-centric API gateway.
https://wso2.com/choreo/choreo-connect/
Apache License 2.0
287 stars 246 forks source link

Retrieve subscription policies from SubscriptionDataStore for organizations the feature is enabled #3520

Closed renuka-fernando closed 1 month ago

renuka-fernando commented 1 month ago

Purpose

SubscriptionPolicy subPolicy = datastore.getSubscriptionPolicyByOrgIdAndName(apiConfig.getOrganizationId(),
                sub.getPolicyId());

We are getting the org ID from API. API always has an org. So let's say org Foo's API is invoked and his org is not in feature flag.

    @Override
    public SubscriptionPolicy getSubscriptionPolicyByOrgIdAndName(String orgId, String policyName) {
        String organizationId = StringUtils.isEmpty(orgId) ? APIConstants.SUPER_TENANT_DOMAIN_NAME : orgId;
        String key = PolicyType.SUBSCRIPTION +
                SubscriptionDataStoreUtil.DELEM_PERIOD + organizationId +
                SubscriptionDataStoreUtil.DELEM_PERIOD + policyName;
        return subscriptionPolicyMap.get(key);
    }

But every org still does not have a sub-policy. Hence getting null pointer exception.

Issues

Fixes # Related Issue: https://github.com/wso2-enterprise/choreo/issues/26811

Automation tests

Tested environments

Not Tested


Maintainers: Check before merge

CLAassistant commented 1 month ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

choreo-cicd commented 1 month ago

[] : dev-deployment-v2 : 20240517.9

choreo-cicd commented 1 month ago

[] Controlplane cluster : dev-deployment-v2 : 20240517.9

choreo-cicd commented 1 month ago

[] Dataplane(EastUS) cluster : dev-deployment-v2 : 20240517.9

choreo-cicd commented 1 month ago

[] Dataplane(NorthEU) cluster : dev-deployment-v2 : 20240517.9

choreo-cicd commented 1 month ago

[succeeded] Dataplane(NorthEU) cluster : stage-deployment-v2 : 20240517.4

choreo-cicd commented 1 month ago

[succeeded] Dataplane(CDP2-WU2) cluster : stage-deployment-v2 : 20240517.4

choreo-cicd commented 1 month ago

[failed] Dataplane(EastUS) cluster : stage-deployment-v2 : 20240517.4

choreo-cicd commented 1 month ago

[succeeded] Controlplane cluster : stage-deployment-v2 : 20240517.4

choreo-cicd commented 1 month ago

[succeeded] Dataplane(EastUS) cluster : stage-deployment-v2 : 20240517.4

choreo-cicd commented 1 month ago

[succeeded] Controlplane cluster : stage-deployment-v2 : 20240517.4

choreo-cicd commented 1 month ago

[succeeded] Dataplane(NorthEU) cluster : stage-deployment-v2 : 20240517.4

choreo-cicd commented 1 month ago

[succeeded] Dataplane(CDP2-WU2) cluster : stage-deployment-v2 : 20240517.4

choreo-cicd commented 1 month ago

[] Dataplane(CDP2-WU2) cluster : stage-deployment-v2 : 20240520.2

choreo-cicd commented 1 month ago

[] Controlplane cluster : stage-deployment-v2 : 20240520.2

choreo-cicd commented 1 month ago

[] Dataplane(EastUS) cluster : stage-deployment-v2 : 20240520.2

choreo-cicd commented 1 month ago

[] Dataplane(NorthEU) cluster : stage-deployment-v2 : 20240520.2

choreo-cicd commented 1 month ago

[succeeded] Dataplane(NorthEU) cluster : prod-deployment-v2 : 20240521.2

choreo-cicd commented 1 month ago

[failed] Dataplane(CDP2-WU2) cluster : prod-deployment-v2 : 20240521.2

choreo-cicd commented 1 month ago

[succeeded] Controlplane cluster : prod-deployment-v2 : 20240521.2

choreo-cicd commented 1 month ago

[canceled] Dataplane(EastUS) cluster : prod-deployment-v2 : 20240521.2

choreo-cicd commented 1 month ago

[] Controlplane cluster : prod-deployment-v2 : 20240521.3

choreo-cicd commented 1 month ago

[] Dataplane(CDP2-WU2) cluster : prod-deployment-v2 : 20240521.3

choreo-cicd commented 1 month ago

[] Dataplane(EastUS) cluster : prod-deployment-v2 : 20240521.3

choreo-cicd commented 1 month ago

[] Dataplane(NorthEU) cluster : prod-deployment-v2 : 20240521.3