Skip to content
Snippets Groups Projects
Commit 0c1d78e2 authored by Nikhil Singh[MicroSoft]'s avatar Nikhil Singh[MicroSoft] Committed by Komal Makkar
Browse files

Usage of Non Request Scope bean for Service Bus Flow

parent 4845fc47
No related branches found
No related tags found
2 merge requests!100Commit 2 contents:,!95Usage of Non Request Scope bean for Service Bus Flow
......@@ -19,7 +19,10 @@ package org.opengroup.osdu.notification.di;
import org.opengroup.osdu.core.common.cache.ICache;
import org.opengroup.osdu.core.common.cache.MultiTenantCache;
import org.opengroup.osdu.core.common.cache.VmCache;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
......@@ -27,7 +30,9 @@ import org.springframework.stereotype.Component;
@Component
public class SubscriptionCacheFactory implements ICache<String, String> {
@Autowired
private TenantInfo tenant;
private DpsHeaders headers;
@Autowired
private ITenantFactory tenantFactory;
private MultiTenantCache<String> caches;
......@@ -56,6 +61,10 @@ public class SubscriptionCacheFactory implements ICache<String, String> {
}
private ICache<String, String> partitionCache() {
return this.caches.get(String.format("%s:subscription", this.tenant.getDataPartitionId()));
TenantInfo tenantInfo = this.tenantFactory.getTenantInfo(this.headers.getPartitionIdWithFallbackToAccountId());
if (tenantInfo == null) {
throw AppException.createUnauthorized(String.format("could not retrieve tenant info for data partition id: %s", this.headers.getPartitionIdWithFallbackToAccountId()));
}
return this.caches.get(String.format("%s:subscription", tenantInfo.getDataPartitionId()));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment