diff options
author | 2019-03-26 09:49:13 -0400 | |
---|---|---|
committer | 2019-03-26 09:49:13 -0400 | |
commit | 72d22a4339db09824d46746dacbba1e141763dc0 (patch) | |
tree | 7fbfea4b81afca0bc0c95e5d4b810f236f4dea29 /ms/cds-sdc-listener/application/src | |
parent | ef6983b670796becfa66c69075c1829e8f9aef4b (diff) |
Migrate ccdsk/apps to ccsdk/cds
Change-Id: I020a2ccec4e691717f888e8bd2afec91a7c4e987
Issue-ID: CCSDK-1178
Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
Diffstat (limited to 'ms/cds-sdc-listener/application/src')
11 files changed, 0 insertions, 532 deletions
diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerApplication.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerApplication.java deleted file mode 100644 index 3bd34fb0..00000000 --- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerApplication.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2019 Bell Canada. All rights reserved. - * - * NOTICE: All the intellectual and technical concepts contained herein are - * proprietary to Bell Canada and are protected by trade secret or copyright law. - * Unauthorized copying of this file, via any medium is strictly prohibited. - */ - -package org.onap.ccsdk.apps.cdssdclistener; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.properties.EnableConfigurationProperties; - -@SpringBootApplication -@EnableConfigurationProperties(CdsSdcListenerConfiguration.class) -public class CdsSdcListenerApplication { - public static void main(String[] args) { - SpringApplication.run(CdsSdcListenerApplication.class, args); - } -} diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerClient.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerClient.java deleted file mode 100644 index af0bb40b..00000000 --- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerClient.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2019 Bell Canada. All rights reserved. - * - * NOTICE: All the intellectual and technical concepts contained herein are - * proprietary to Bell Canada and are protected by trade secret or copyright law. - * Unauthorized copying of this file, via any medium is strictly prohibited. - */ -package org.onap.ccsdk.apps.cdssdclistener; - -import java.util.Optional; -import org.onap.ccsdk.apps.cdssdclistener.exceptions.CdsSdcListenerException; -import org.onap.sdc.api.IDistributionClient; -import org.onap.sdc.api.results.IDistributionClientResult; -import org.onap.sdc.impl.DistributionClientFactory; -import org.onap.sdc.utils.DistributionActionResultEnum; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.event.ApplicationReadyEvent; -import org.springframework.context.event.EventListener; -import org.springframework.stereotype.Component; - -@Component -public class CdsSdcListenerClient { - - private static Logger LOG = LoggerFactory.getLogger(CdsSdcListenerClient.class); - - @Autowired - private CdsSdcListenerConfiguration configuration; - - @Autowired - private CdsSdcListenerNotificationCallback notification; - - @Autowired - private CdsSdcListenerDto listenerDto; - - private IDistributionClient distributionClient; - - /** - * This method initializes the SDC Distribution client. - */ - @EventListener(ApplicationReadyEvent.class) - public void initSdcClient() throws CdsSdcListenerException { - LOG.info("Initialize the SDC distribution client"); - - distributionClient = Optional.of(DistributionClientFactory.createDistributionClient()) - .orElseThrow(() -> new CdsSdcListenerException("Could not able to create SDC Distribution client")); - - listenerDto.setDistributionClient(distributionClient); - - IDistributionClientResult result = distributionClient.init(configuration, notification); - - startSdcClientBasedOnTheResult(result); - } - - private void startSdcClientBasedOnTheResult(IDistributionClientResult result) throws CdsSdcListenerException { - if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) { - throw new CdsSdcListenerException( - "SDC distribution client init failed with reason:" + result.getDistributionMessageResult()); - } - - // Start the client. - result = this.distributionClient.start(); - - if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) { - throw new CdsSdcListenerException( - "Startup of the SDC distribution client failed with reason: " + result.getDistributionMessageResult()); - } - } - - private void closeSdcDistributionclient() throws CdsSdcListenerException { - - IDistributionClientResult status = this.distributionClient.stop(); - - LOG.info("Closing SDC distribution client"); - if (status.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) { - throw new CdsSdcListenerException( - "Failed to close the SDC distribution client due to : " + status.getDistributionMessageResult()); - } - } -} diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerConfiguration.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerConfiguration.java deleted file mode 100644 index 0cbb917f..00000000 --- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerConfiguration.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2019 Bell Canada. All rights reserved. - * - * NOTICE: All the intellectual and technical concepts contained herein are - * proprietary to Bell Canada and are protected by trade secret or copyright law. - * Unauthorized copying of this file, via any medium is strictly prohibited. - */ - -package org.onap.ccsdk.apps.cdssdclistener; - -import java.util.List; -import org.onap.sdc.api.consumer.IConfiguration; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * In order to initiate a SDC distribution client we need to supply some pre-configuration values that - * distribution client needs. - */ -@ConfigurationProperties("listenerservice") -public class CdsSdcListenerConfiguration implements IConfiguration { - - public static final String TOSCA_CSAR = "TOSCA_CSAR"; - - @Value("${listenerservice.config.asdcAddress}") - private String asdcAddress; - - @Value("${listenerservice.config.messageBusAddress}") - private List<String> messageBusAddress; - - @Value("${listenerservice.config.user}") - private String user; - - @Value("${listenerservice.config.password}") - private String password; - - @Value("${listenerservice.config.pollingTimeout}") - private int pollingTimeout; - - @Value("${listenerservice.config.pollingInterval}") - private int pollingInterval; - - @Value("${listenerservice.config.relevantArtifactTypes}") - private List<String> relevantArtifactTypes; - - @Value("${listenerservice.config.consumerGroup}") - private String consumerGroup; - - @Value("${listenerservice.config.environmentName}") - private String envName; - - @Value("${listenerservice.config.consumerId}") - private String consumerId; - - @Value("${listenerservice.config.activateServerTLSAuth}") - private boolean activateServerTLSAuth; - - @Value("${listenerservice.config.isUseHttpsWithDmaap}") - private boolean isUseHttpsWithDmaap; - - - @Override - public String getAsdcAddress() { - return asdcAddress; - } - - @Override - public List<String> getMsgBusAddress() { - return messageBusAddress; - } - - @Override - public String getUser() { - return user; - } - - @Override - public String getPassword() { - return password; - } - - @Override - public int getPollingInterval() { - return pollingInterval; - } - - @Override - public int getPollingTimeout() { - return pollingTimeout; - } - - @Override - public List<String> getRelevantArtifactTypes() { - return relevantArtifactTypes; - } - - @Override - public String getConsumerGroup() { - return consumerGroup; - } - - @Override - public String getEnvironmentName() { - return envName; - } - - @Override - public String getConsumerID() { - return consumerId; - } - - @Override - public String getKeyStorePath() { - return null; - } - - @Override - public String getKeyStorePassword() { - return null; - } - - @Override - public boolean activateServerTLSAuth() { - return activateServerTLSAuth; - } - - @Override - public boolean isFilterInEmptyResources() { - return false; - } - - @Override - public Boolean isUseHttpsWithDmaap() { - return isUseHttpsWithDmaap; - } -} - diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerDto.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerDto.java deleted file mode 100644 index afa753e5..00000000 --- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerDto.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2019 Bell Canada. All rights reserved. - * - * NOTICE: All the intellectual and technical concepts contained herein are - * proprietary to Bell Canada and are protected by trade secret or copyright law. - * Unauthorized copying of this file, via any medium is strictly prohibited. - */ -package org.onap.ccsdk.apps.cdssdclistener; - -import org.onap.sdc.api.IDistributionClient; - -public class CdsSdcListenerDto { - - private IDistributionClient distributionClient; - - public IDistributionClient getDistributionClient() { - return distributionClient; - } - - public void setDistributionClient(IDistributionClient distributionClient) { - this.distributionClient = distributionClient; - } -} diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerNotificationCallback.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerNotificationCallback.java deleted file mode 100644 index 35747635..00000000 --- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerNotificationCallback.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2019 Bell Canada. All rights reserved. - * - * NOTICE: All the intellectual and technical concepts contained herein are - * proprietary to Bell Canada and are protected by trade secret or copyright law. - * Unauthorized copying of this file, via any medium is strictly prohibited. - */ - -package org.onap.ccsdk.apps.cdssdclistener; - -import static org.onap.sdc.utils.DistributionActionResultEnum.SUCCESS; -import java.util.List; -import org.onap.sdc.api.IDistributionClient; -import org.onap.sdc.api.consumer.INotificationCallback; -import org.onap.sdc.api.notification.IArtifactInfo; -import org.onap.sdc.api.notification.INotificationData; -import org.onap.sdc.api.results.IDistributionClientDownloadResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class CdsSdcListenerNotificationCallback implements INotificationCallback { - - @Autowired - private CdsSdcListenerDto cdsSdcListenerDto; - - private static final Logger LOGGER = LoggerFactory.getLogger(CdsSdcListenerNotificationCallback.class); - - @Override - public void activateCallback(INotificationData notificationData) { - LOGGER.info(notificationData.getDistributionID(), "The UUID generated by SDC {}"); - processNotification(notificationData); - } - - private void processNotification(INotificationData notificationData) { - downlaodCsarArtifacts(notificationData.getServiceArtifacts()); - } - - /** - * Download the TOSCA CSAR artifact. - * @param artifactInfo - An object consists of Artifact information. - */ - private void downlaodCsarArtifacts(List<IArtifactInfo> artifactInfo) { - final IDistributionClient distributionClient = cdsSdcListenerDto.getDistributionClient(); - - artifactInfo.forEach(info -> { - final String url = info.getArtifactURL(); - final String id = info.getArtifactUUID(); - if (info.getArtifactType().equals(CdsSdcListenerConfiguration.TOSCA_CSAR)) { - LOGGER.info("Trying to download the artifact from : {} and UUID is {} ", url, id); - - IDistributionClientDownloadResult result = distributionClient.download(info); - - if (!result.getDistributionActionResult().equals(SUCCESS)) { - LOGGER.info("Failed to download the artifact from : {} due to {} ", url, - result.getDistributionActionResult()); - } else { - parseCBAFileFromCsar(result); - } - } - }); - } - - private void parseCBAFileFromCsar(IDistributionClientDownloadResult result) { - - } -} diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/exceptions/CdsSdcListenerException.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/exceptions/CdsSdcListenerException.java deleted file mode 100644 index 3f83b6ac..00000000 --- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/exceptions/CdsSdcListenerException.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2019 Bell Canada. All rights reserved. - * - * NOTICE: All the intellectual and technical concepts contained herein are - * proprietary to Bell Canada and are protected by trade secret or copyright law. - * Unauthorized copying of this file, via any medium is strictly prohibited. - */ - -package org.onap.ccsdk.apps.cdssdclistener.exceptions; - -public class CdsSdcListenerException extends Exception { - - /** - * @param message The message to dump - */ - public CdsSdcListenerException(final String message) { - super(message); - } - - /** - * @param message The message to dump - * @param cause The Throwable cause object - */ - public CdsSdcListenerException(final String message, final Throwable cause) { - super(message, cause); - } -} diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/service/ListenerService.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/service/ListenerService.java deleted file mode 100644 index d6c2c4f4..00000000 --- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/service/ListenerService.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (C) 2019 Bell Canada. All rights reserved. - * - * NOTICE: All the intellectual and technical concepts contained herein are - * proprietary to Bell Canada and are protected by trade secret or copyright law. - * Unauthorized copying of this file, via any medium is strictly prohibited. - */ - -package org.onap.ccsdk.apps.cdssdclistener.service; - -import java.io.File; - -public interface ListenerService { - - void extractBluePrint(File file); - - void storeBluePrint(File file); -} diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/service/ListenerServiceImpl.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/service/ListenerServiceImpl.java deleted file mode 100644 index 864c485c..00000000 --- a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/apps/cdssdclistener/service/ListenerServiceImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2019 Bell Canada. All rights reserved. - * - * NOTICE: All the intellectual and technical concepts contained herein are - * proprietary to Bell Canada and are protected by trade secret or copyright law. - * Unauthorized copying of this file, via any medium is strictly prohibited. - */ - -package org.onap.ccsdk.apps.cdssdclistener.service; - -import java.io.File; -import org.springframework.stereotype.Component; - -@Component -public class ListenerServiceImpl implements ListenerService { - - @Override - public void extractBluePrint(File file) { - //TODO - - } - - @Override - public void storeBluePrint(File file) { - //TODO - } -} diff --git a/ms/cds-sdc-listener/application/src/main/resources/application.yml b/ms/cds-sdc-listener/application/src/main/resources/application.yml deleted file mode 100644 index 1daef585..00000000 --- a/ms/cds-sdc-listener/application/src/main/resources/application.yml +++ /dev/null @@ -1,17 +0,0 @@ -listenerservice: - config: - asdcAddress: localhost:8443 - messageBusAddress: localhost - user: vid - password: Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U - pollingInterval: 15 - pollingTimeout: 15 - relevantArtifactTypes: TOSCA_CSAR - consumerGroup: cds-id-local - environmentName: AUTO - consumerId: cds-id-local - keyStorePassword: - keyStorePath: - activateServerTLSAuth : false - isUseHttpsWithDmaap: false - diff --git a/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerClientTest.java b/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerClientTest.java deleted file mode 100644 index 3a634b8c..00000000 --- a/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerClientTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2019 Bell Canada. All rights reserved. - * - * NOTICE: All the intellectual and technical concepts contained herein are - * proprietary to Bell Canada and are protected by trade secret or copyright law. - * Unauthorized copying of this file, via any medium is strictly prohibited. - */ - -package org.onap.ccsdk.apps.cdssdclistener; - -import mockit.Expectations; -import mockit.Injectable; -import mockit.Mock; -import mockit.MockUp; -import mockit.Tested; -import mockit.VerificationsInOrder; -import mockit.integration.junit4.JMockit; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.ccsdk.apps.cdssdclistener.exceptions.CdsSdcListenerException; -import org.onap.sdc.api.IDistributionClient; -import org.onap.sdc.api.results.IDistributionClientResult; -import org.onap.sdc.impl.DistributionClientFactory; -import org.onap.sdc.impl.DistributionClientResultImpl; -import org.onap.sdc.utils.DistributionActionResultEnum; - -@RunWith(JMockit.class) -public class CdsSdcListenerClientTest { - - @Tested - private CdsSdcListenerClient cdsSdcListenerClient; - - @Test - public void testInitCdsClientSuccesfully(@Injectable IDistributionClient distributionClient, - @Injectable CdsSdcListenerConfiguration configuration, - @Injectable CdsSdcListenerNotificationCallback notification, - @Injectable CdsSdcListenerDto cdsSdcListenerDto) throws CdsSdcListenerException { - - // Arrange - new MockUp<DistributionClientFactory>() { - @Mock - public IDistributionClient createDistributionClient() { - return distributionClient; - } - }; - - new Expectations() {{ - distributionClient.init(configuration, notification); - result = getResult(); - }}; - - new Expectations() {{ - distributionClient.start(); - result = getResult(); - }}; - - // Act - cdsSdcListenerClient.initSdcClient(); - - // Verify - new VerificationsInOrder() {{ - distributionClient.init(configuration, notification); - distributionClient.start(); - }}; - } - - public IDistributionClientResult getResult() { - return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS, - DistributionActionResultEnum.SUCCESS.name()); - } -} diff --git a/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerConfigurationTest.java b/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerConfigurationTest.java deleted file mode 100644 index 886049df..00000000 --- a/ms/cds-sdc-listener/application/src/test/java/org/onap/ccsdk/apps/cdssdclistener/CdsSdcListenerConfigurationTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2019 Bell Canada. All rights reserved. - * - * NOTICE: All the intellectual and technical concepts contained herein are - * proprietary to Bell Canada and are protected by trade secret or copyright law. - * Unauthorized copying of this file, via any medium is strictly prohibited. - */ - -package org.onap.ccsdk.apps.cdssdclistener; - -import static org.junit.Assert.assertEquals; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@EnableConfigurationProperties(CdsSdcListenerConfiguration.class) -@SpringBootTest(classes = {CdsSdcListenerConfigurationTest.class}) -public class CdsSdcListenerConfigurationTest { - - @Autowired - private CdsSdcListenerConfiguration listenerConfiguration; - - @Test - public void testCdsSdcListenerConfiguration() { - assertEquals(listenerConfiguration.getAsdcAddress(), "localhost:8443"); - assertEquals(listenerConfiguration.getMsgBusAddress().stream().findFirst().get(), "localhost"); - assertEquals(listenerConfiguration.getUser(), "vid"); - assertEquals(listenerConfiguration.getPassword(), "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"); - assertEquals(listenerConfiguration.getPollingInterval(), 15); - assertEquals(listenerConfiguration.getPollingTimeout(), 15); - assertEquals(listenerConfiguration.getRelevantArtifactTypes().stream().findFirst().get(), "TOSCA_CSAR"); - assertEquals(listenerConfiguration.getConsumerGroup(), "cds-id-local"); - assertEquals(listenerConfiguration.getEnvironmentName(), "AUTO"); - assertEquals(listenerConfiguration.getConsumerID(), "cds-id-local"); - assertEquals(listenerConfiguration.activateServerTLSAuth(), false); - } -} |