2 * Copyright (C) 2019 Bell Canada. All rights reserved.
4 * NOTICE: All the intellectual and technical concepts contained herein are
5 * proprietary to Bell Canada and are protected by trade secret or copyright law.
6 * Unauthorized copying of this file, via any medium is strictly prohibited.
9 package org.onap.ccsdk.apps.cdssdclistener;
11 import static org.onap.sdc.utils.DistributionActionResultEnum.SUCCESS;
12 import java.util.List;
13 import org.onap.sdc.api.IDistributionClient;
14 import org.onap.sdc.api.consumer.INotificationCallback;
15 import org.onap.sdc.api.notification.IArtifactInfo;
16 import org.onap.sdc.api.notification.INotificationData;
17 import org.onap.sdc.api.results.IDistributionClientDownloadResult;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20 import org.springframework.beans.factory.annotation.Autowired;
21 import org.springframework.stereotype.Component;
24 public class CdsSdcListenerNotificationCallback implements INotificationCallback {
27 private CdsSdcListenerDto cdsSdcListenerDto;
29 private static final Logger LOGGER = LoggerFactory.getLogger(CdsSdcListenerNotificationCallback.class);
32 public void activateCallback(INotificationData notificationData) {
33 LOGGER.info(notificationData.getDistributionID(), "The UUID generated by SDC {}");
34 processNotification(notificationData);
37 private void processNotification(INotificationData notificationData) {
38 downlaodCsarArtifacts(notificationData.getServiceArtifacts());
42 * Download the TOSCA CSAR artifact.
43 * @param artifactInfo - An object consists of Artifact information.
45 private void downlaodCsarArtifacts(List<IArtifactInfo> artifactInfo) {
46 final IDistributionClient distributionClient = cdsSdcListenerDto.getDistributionClient();
48 artifactInfo.forEach(info -> {
49 final String url = info.getArtifactURL();
50 final String id = info.getArtifactUUID();
51 if (info.getArtifactType().equals(CdsSdcListenerConfiguration.TOSCA_CSAR)) {
52 LOGGER.info("Trying to download the artifact from : {} and UUID is {} ", url, id);
54 IDistributionClientDownloadResult result = distributionClient.download(info);
56 if (!result.getDistributionActionResult().equals(SUCCESS)) {
57 LOGGER.info("Failed to download the artifact from : {} due to {} ", url,
58 result.getDistributionActionResult());
60 parseCBAFileFromCsar(result);
66 private void parseCBAFileFromCsar(IDistributionClientDownloadResult result) {