Commit 363b162e authored by Alok Joshi's avatar Alok Joshi
Browse files

use Azure factory for subscription client

parent a7426f15
Pipeline #61505 failed with stages
in 18 minutes and 45 seconds
package org.opengroup.osdu.notification.provider.azure.di;
import lombok.Data;
import org.opengroup.osdu.core.common.notification.SubscriptionAPIConfig;
import org.opengroup.osdu.notification.provider.interfaces.IAppProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@Component
@ConfigurationProperties
public class SubscriptionAPIConfigBean extends AbstractFactoryBean<SubscriptionAPIConfig> {
@Autowired
private IAppProperties config;
private String apiKey;
@Override
public Class<?> getObjectType() {
return SubscriptionAPIConfig.class;
}
@Override
protected SubscriptionAPIConfig createInstance() throws Exception {
return SubscriptionAPIConfig
.builder()
.rootUrl(config.getRegisterAPI())
.apiKey(apiKey)
.build();
}
}
package org.opengroup.osdu.notification.provider.azure.di;
import org.opengroup.osdu.core.common.http.IHttpClient;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.notification.ISubscriptionFactory;
import org.opengroup.osdu.core.common.notification.ISubscriptionService;
import org.opengroup.osdu.core.common.notification.SubscriptionAPIConfig;
import org.opengroup.osdu.core.common.notification.SubscriptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import java.util.Objects;
@Component
@Primary
@ConditionalOnProperty(value = "azure.entitlements.factory.enabled", havingValue = "true", matchIfMissing = true)
public class SubscriptionFactoryAzure implements ISubscriptionFactory {
private final SubscriptionAPIConfig config;
private final IHttpClient client;
@Autowired
public SubscriptionFactoryAzure(final SubscriptionAPIConfig subscriptionConfig, final IHttpClient httpClient) {
Objects.requireNonNull(subscriptionConfig, "SubscriptionAPIConfig cannot be null");
this.config = subscriptionConfig;
this.client = httpClient;
}
@Override
public ISubscriptionService create(final DpsHeaders dpsHeaders) {
Objects.requireNonNull(dpsHeaders, "headers cannot be null");
return new SubscriptionService(this.config, this.client, dpsHeaders);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment