summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2021-09-06 14:28:23 +0100
committerAndr� Schmid <andre.schmid@est.tech>2021-09-09 12:12:29 +0000
commitc03a82e3af8ae60c1200a252aac8dadb1c8da0b8 (patch)
tree26ae3386e358b4865942d550f12357f01b732914 /catalog-be/src/main/java
parent0ba5888b69b3ac6b60967ba9b64db96e87dc5c4e (diff)
[SDC-BE] Remove hardcoded MR apiKey
Issue-ID: SDC-3714 Change-Id: Ie154a225bc1c47d6d3b504f915a697047e1b0440 Signed-off-by: MichaelMorris <michael.morris@est.tech>
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandler.java12
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealth.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java17
3 files changed, 26 insertions, 11 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandler.java
index 425b464c4f..41d10737d3 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaHandler.java
@@ -62,10 +62,6 @@ public class CambriaHandler implements ICambriaHandler {
private static final Logger log = Logger.getLogger(CambriaHandler.class.getName());
private static final String PARTITION_KEY = "asdc" + "aa";
private static final String SEND_NOTIFICATION = "send notification";
- private static final String CONSUMER_ID = ConfigurationManager.getConfigurationManager().getDistributionEngineConfiguration()
- .getDistributionStatusTopic().getConsumerId();
- private static final boolean USE_HTTPS_WITH_DMAAP = ConfigurationManager.getConfigurationManager().getDistributionEngineConfiguration()
- .isUseHttpsWithDmaap();
private final Gson gson = new Gson();
/**
@@ -284,7 +280,9 @@ public class CambriaHandler implements ICambriaHandler {
String managerSecretKey) {
AbstractAuthenticatedManagerBuilder<CambriaTopicManager> clientBuilder = createTopicManagerBuilder(hostSet)
.authenticatedBy(managerApiKey, managerSecretKey);
- if (USE_HTTPS_WITH_DMAAP) {
+ final boolean useHttpsWithDmaap = ConfigurationManager.getConfigurationManager().getDistributionEngineConfiguration()
+ .isUseHttpsWithDmaap();
+ if (useHttpsWithDmaap) {
clientBuilder = clientBuilder.usingHttps();
}
return clientBuilder;
@@ -506,7 +504,9 @@ public class CambriaHandler implements ICambriaHandler {
Either<ApiCredential, CambriaErrorResponse> result;
try {
CambriaIdentityManager createIdentityManager = buildCambriaClient(new IdentityManagerBuilder().usingHosts(hostSet));
- String description = String.format("ASDC Key for %s", CONSUMER_ID);
+ final String consumerId = ConfigurationManager.getConfigurationManager().getDistributionEngineConfiguration()
+ .getDistributionStatusTopic().getConsumerId();
+ String description = String.format("ASDC Key for %s", consumerId);
ApiCredential credential = createIdentityManager.createApiKey("", description);
createIdentityManager.setApiCredentials(credential.getApiKey(), credential.getApiSecret());
result = Either.left(credential);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealth.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealth.java
index b1bf59f3aa..0851f22c0a 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealth.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealth.java
@@ -31,7 +31,6 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.ConfigurationManager;
@@ -66,9 +65,8 @@ public class DistributionEngineClusterHealth {
private HealthCheckInfo healthCheckInfo = HealthCheckInfoResult.UNKNOWN.getHealthCheckInfo();
private Map<String, AtomicBoolean> envNamePerStatus = null;
private ScheduledFuture<?> scheduledFuture = null;
-
- @PostConstruct
- protected void init() {
+
+ protected void init(final String publicApiKey) {
logger.trace("Enter init method of DistributionEngineClusterHealth");
Long reconnectIntervalConfig = ConfigurationManager.getConfigurationManager().getConfiguration()
.getUebHealthCheckReconnectIntervalInSeconds();
@@ -82,7 +80,7 @@ public class DistributionEngineClusterHealth {
DistributionEngineConfiguration distributionEngineConfiguration = ConfigurationManager.getConfigurationManager()
.getDistributionEngineConfiguration();
this.uebServers = distributionEngineConfiguration.getUebServers();
- this.publicApiKey = distributionEngineConfiguration.getUebPublicKey();
+ this.publicApiKey = publicApiKey;
this.healthCheckScheduledTask = new HealthCheckScheduledTask(this.uebServers);
logger.trace("Exit init method of DistributionEngineClusterHealth");
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java
index 26992b9c3d..afb311f452 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/EnvironmentsEngine.java
@@ -168,6 +168,7 @@ public class EnvironmentsEngine implements INotificationHandler {
String envId = opEnvEntry.getEnvironmentId();
DistributionEngineConfiguration distributionEngineConfiguration = ConfigurationManager.getConfigurationManager()
.getDistributionEngineConfiguration();
+ distributionEngineClusterHealth.init(opEnvEntry.getUebApikey());
DistributionEnginePollingTask distributionEnginePollingTask = new DistributionEnginePollingTask(distributionEngineConfiguration,
distributionCompleteReporter, componentUtils, distributionEngineClusterHealth, opEnvEntry);
String envName = configurationManager.getDistributionEngineConfiguration().getEnvironments().get(0);
@@ -430,9 +431,25 @@ public class EnvironmentsEngine implements INotificationHandler {
private Map<String, OperationalEnvironmentEntry> populateEnvironments() {
Map<String, OperationalEnvironmentEntry> envs = getEnvironmentsFromDb();
OperationalEnvironmentEntry confEntry = readEnvFromConfig();
+ readKeyFromDbOrCreate(envs, confEntry);
envs.put(confEntry.getEnvironmentId(), confEntry);
return envs;
}
+
+ private void readKeyFromDbOrCreate(Map<String, OperationalEnvironmentEntry> envs, OperationalEnvironmentEntry confEntry) {
+ if (envs.get(confEntry.getEnvironmentId()) == null){
+ log.debug("Creating UEB API key");
+ Wrapper<Boolean> errorWrapper = new Wrapper<>();
+ createUebKeys(errorWrapper, confEntry);
+ confEntry.setStatus(EnvironmentStatusEnum.COMPLETED);
+ log.debug("Saving UEB API key to DB");
+ operationalEnvironmentDao.save(confEntry);
+ } else {
+ log.debug("Reading UEB API key from DB");
+ confEntry.setUebApikey(envs.get(confEntry.getEnvironmentId()).getUebApikey());
+ confEntry.setUebSecretKey(envs.get(confEntry.getEnvironmentId()).getUebSecretKey());
+ }
+ }
private OperationalEnvironmentEntry readEnvFromConfig() {
OperationalEnvironmentEntry entry = new OperationalEnvironmentEntry();