Skip to content
Snippets Groups Projects
Commit 0cc5541d authored by Neelesh Thakur's avatar Neelesh Thakur
Browse files

replace core-lib-azure EventGridTopicPartitionInfoAzure instead of TopicHelper

parent 7d7c19d6
No related branches found
No related tags found
1 merge request!75use friendly topic name
Pipeline #30679 passed with warnings
...@@ -61,9 +61,6 @@ public class SubscriptionRepository implements ISubscriptionRepository { ...@@ -61,9 +61,6 @@ public class SubscriptionRepository implements ISubscriptionRepository {
@Autowired @Autowired
private CryptographyUtil cryptographyUtil; private CryptographyUtil cryptographyUtil;
/*@Autowired
private TopicsHelper topicsHelper;*/
@Autowired @Autowired
private PartitionHelper partitionHelper; private PartitionHelper partitionHelper;
...@@ -315,8 +312,6 @@ public class SubscriptionRepository implements ISubscriptionRepository { ...@@ -315,8 +312,6 @@ public class SubscriptionRepository implements ISubscriptionRepository {
hmacSecret.setValue(secretValue); hmacSecret.setValue(secretValue);
secret = hmacSecret; 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(), return new Subscription(doc.getId(), doc.getName(),doc.getDescription(), topicsRepository.getTopicAliasFromFullyQualifiedTopicName(doc.getTopic()), doc.getPushEndpoint(),
doc.getCreatedBy(), doc.getCreatedOnEpoch(), doc.getNotificationId(), secret); doc.getCreatedBy(), doc.getCreatedOnEpoch(), doc.getNotificationId(), secret);
} }
......
...@@ -14,10 +14,12 @@ ...@@ -14,10 +14,12 @@
package org.opengroup.osdu.register.provider.azure.util; 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.EventGridTopicPartitionInfoAzure;
import org.opengroup.osdu.azure.partition.PartitionInfoAzure; import org.opengroup.osdu.azure.partition.PartitionInfoAzure;
import org.opengroup.osdu.azure.partition.PartitionServiceClient; import org.opengroup.osdu.azure.partition.PartitionServiceClient;
import org.opengroup.osdu.azure.partition.PartitionServiceEventGridClient; 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.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.partition.PartitionException; import org.opengroup.osdu.core.common.partition.PartitionException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -29,43 +31,38 @@ import java.util.List; ...@@ -29,43 +31,38 @@ import java.util.List;
@Component @Component
public class PartitionHelper { public class PartitionHelper {
@Autowired @Autowired
private PartitionServiceClient partitionService; private PartitionServiceClient partitionService;
@Autowired @Autowired
private PartitionServiceEventGridClient partitionServiceEventGridClient; private PartitionServiceEventGridClient partitionServiceEventGridClient;
@Autowired @Autowired
private DpsHeaders headers; private DpsHeaders headers;
public String retrieveResourceGroup() { public String retrieveResourceGroup() {
PartitionInfoAzure partition = partitionService.getPartition(headers.getPartitionId()); PartitionInfoAzure partition = partitionService.getPartition(headers.getPartitionId());
return partition.getEventGridResourceGroup(); 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 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() { public String retrieveKeyIdentifier() {
PartitionInfoAzure partition = partitionService.getPartition(headers.getPartitionId()); PartitionInfoAzure partition = partitionService.getPartition(headers.getPartitionId());
return partition.getCryptographyEncryptionKeyIdentifier(); return partition.getCryptographyEncryptionKeyIdentifier();
} }
public String retrieveScope(String topic) { public String retrieveScope(String topic) {
PartitionInfoAzure partition = partitionService.getPartition(headers.getPartitionId()); PartitionInfoAzure partition = partitionService.getPartition(headers.getPartitionId());
return String.format("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.EventGrid/topics/%s", return String.format("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.EventGrid/topics/%s",
partition.getAzureSubscriptionId(), partition.getEventGridResourceGroup(), topic); partition.getAzureSubscriptionId(), partition.getEventGridResourceGroup(), topic);
} }
} }
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