Commit 0cc5541d authored by neelesh thakur's avatar neelesh thakur
Browse files

replace core-lib-azure EventGridTopicPartitionInfoAzure instead of TopicHelper

parent 7d7c19d6
Pipeline #30679 passed with stages
in 25 minutes and 41 seconds
......@@ -61,9 +61,6 @@ public class SubscriptionRepository implements ISubscriptionRepository {
@Autowired
private CryptographyUtil cryptographyUtil;
/*@Autowired
private TopicsHelper topicsHelper;*/
@Autowired
private PartitionHelper partitionHelper;
......@@ -315,8 +312,6 @@ public class SubscriptionRepository implements ISubscriptionRepository {
hmacSecret.setValue(secretValue);
secret = hmacSecret;
}
/*return new Subscription(doc.getId(), doc.getName(),doc.getDescription(), topicsHelper.extractDisplayName(doc.getTopic()), doc.getPushEndpoint(),
doc.getCreatedBy(), doc.getCreatedOnEpoch(), doc.getNotificationId(), secret);*/
return new Subscription(doc.getId(), doc.getName(),doc.getDescription(), topicsRepository.getTopicAliasFromFullyQualifiedTopicName(doc.getTopic()), doc.getPushEndpoint(),
doc.getCreatedBy(), doc.getCreatedOnEpoch(), doc.getNotificationId(), secret);
}
......
......@@ -14,10 +14,12 @@
package org.opengroup.osdu.register.provider.azure.util;
import org.apache.http.HttpStatus;
import org.opengroup.osdu.azure.partition.EventGridTopicPartitionInfoAzure;
import org.opengroup.osdu.azure.partition.PartitionInfoAzure;
import org.opengroup.osdu.azure.partition.PartitionServiceClient;
import org.opengroup.osdu.azure.partition.PartitionServiceEventGridClient;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.partition.PartitionException;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -29,43 +31,38 @@ import java.util.List;
@Component
public class PartitionHelper {
@Autowired
private PartitionServiceClient partitionService;
@Autowired
private PartitionServiceEventGridClient partitionServiceEventGridClient;
@Autowired
private DpsHeaders headers;
@Autowired
private PartitionServiceClient partitionService;
@Autowired
private PartitionServiceEventGridClient partitionServiceEventGridClient;
@Autowired
private DpsHeaders headers;
public String retrieveResourceGroup() {
PartitionInfoAzure partition = partitionService.getPartition(headers.getPartitionId());
return partition.getEventGridResourceGroup();
}
public List<String> retrieveTopicNames() {
PartitionInfoAzure partition = partitionService.getPartition(headers.getPartitionId());
String topicName = partition.getEventGridRecordsTopicEndpoint().split("\\.")[0].replace("https://", "");
return Arrays.asList(topicName);
}
public String getFullyQualifiedTopicName(String topicNameAlias) {
EventGridTopicPartitionInfoAzure eventGridTopicPartitionInfoAzure = null;
try {
eventGridTopicPartitionInfoAzure = partitionServiceEventGridClient.getEventGridTopicInPartition(headers.getPartitionId(), topicNameAlias);
} catch (PartitionException e) {
public String retrieveResourceGroup() {
PartitionInfoAzure partition = partitionService.getPartition(headers.getPartitionId());
return partition.getEventGridResourceGroup();
}
public String getFullyQualifiedTopicName(String topicNameAlias) {
EventGridTopicPartitionInfoAzure eventGridTopicPartitionInfoAzure = null;
try {
eventGridTopicPartitionInfoAzure = partitionServiceEventGridClient.getEventGridTopicInPartition(headers.getPartitionId(), topicNameAlias);
} catch (PartitionException e) {
throw new AppException(
HttpStatus.SC_NOT_FOUND, "Not found", String.format("Invalid topic for subscription: %s, please use GET topics API for available topics", topicNameAlias), e);
}
return eventGridTopicPartitionInfoAzure.getTopicName().split("\\.")[0].replace("https://", "");
}
return eventGridTopicPartitionInfoAzure.getTopicName().split("\\.")[0].replace("https://", "");
}
public String retrieveKeyIdentifier() {
PartitionInfoAzure partition = partitionService.getPartition(headers.getPartitionId());
return partition.getCryptographyEncryptionKeyIdentifier();
}
public String retrieveKeyIdentifier() {
PartitionInfoAzure partition = partitionService.getPartition(headers.getPartitionId());
return partition.getCryptographyEncryptionKeyIdentifier();
}
public String retrieveScope(String topic) {
PartitionInfoAzure partition = partitionService.getPartition(headers.getPartitionId());
return String.format("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.EventGrid/topics/%s",
partition.getAzureSubscriptionId(), partition.getEventGridResourceGroup(), topic);
}
public String retrieveScope(String topic) {
PartitionInfoAzure partition = partitionService.getPartition(headers.getPartitionId());
return String.format("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.EventGrid/topics/%s",
partition.getAzureSubscriptionId(), partition.getEventGridResourceGroup(), topic);
}
}
Markdown is supported
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