summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-03-23 11:12:50 +0100
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-03-23 11:12:50 +0100
commit8561671bacac36db04b34351df9ddb9d3f5e79cc (patch)
tree9333d105587f05f42917679ed833cee1bf358dd1 /src/main/java
parentd9b46ded4ec845cd34d2ff628c9a24d5917ccf64 (diff)
Sonar fixes
Rework the class due to sonar report Issue-ID: CLAMP-81 Change-Id: I5f99728b3aa1c194d0bf7b2cf727e8dbdf99684f Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java68
1 files changed, 38 insertions, 30 deletions
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java b/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java
index f8fef3943..d09362669 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java
@@ -56,10 +56,14 @@ import org.openecomp.sdc.utils.DistributionStatusEnum;
public class SdcSingleController {
private static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcSingleController.class);
- protected boolean isAsdcClientAutoManaged = false;
- protected CsarInstaller csarInstaller;
- protected ClampProperties refProp;
+ private boolean isAsdcClientAutoManaged = false;
+ private CsarInstaller csarInstaller;
+ private ClampProperties refProp;
public static final String CONFIG_SDC_FOLDER = "sdc.csarFolder";
+ private int nbOfNotificationsOngoing = 0;
+ private SdcSingleControllerStatus controllerStatus = SdcSingleControllerStatus.STOPPED;
+ private SdcSingleControllerConfiguration sdcConfig;
+ private IDistributionClient distributionClient;
/**
* Inner class for Notification callback
@@ -88,14 +92,18 @@ public class SdcSingleController {
}
}
- // ***** Controller STATUS code
- protected int nbOfNotificationsOngoing = 0;
-
public int getNbOfNotificationsOngoing() {
return nbOfNotificationsOngoing;
}
- private SdcSingleControllerStatus controllerStatus = SdcSingleControllerStatus.STOPPED;
+ private void changeControllerStatusIdle() {
+ if (this.nbOfNotificationsOngoing > 1) {
+ --this.nbOfNotificationsOngoing;
+ } else {
+ this.nbOfNotificationsOngoing = 0;
+ this.controllerStatus = SdcSingleControllerStatus.IDLE;
+ }
+ }
protected final synchronized void changeControllerStatus(SdcSingleControllerStatus newControllerStatus) {
switch (newControllerStatus) {
@@ -104,12 +112,7 @@ public class SdcSingleController {
this.controllerStatus = newControllerStatus;
break;
case IDLE:
- if (this.nbOfNotificationsOngoing > 1) {
- --this.nbOfNotificationsOngoing;
- } else {
- this.nbOfNotificationsOngoing = 0;
- this.controllerStatus = newControllerStatus;
- }
+ this.changeControllerStatusIdle();
break;
default:
this.controllerStatus = newControllerStatus;
@@ -121,10 +124,6 @@ public class SdcSingleController {
return this.controllerStatus;
}
- // ***** END of Controller STATUS code
- protected SdcSingleControllerConfiguration sdcConfig;
- private IDistributionClient distributionClient;
-
public SdcSingleController(ClampProperties clampProp, CsarInstaller csarInstaller,
SdcSingleControllerConfiguration sdcSingleConfig, boolean isClientAutoManaged) {
this.isAsdcClientAutoManaged = isClientAutoManaged;
@@ -234,10 +233,11 @@ public class SdcSingleController {
e.getMessage(), System.currentTimeMillis());
} catch (CsarHandlerException e) {
logger.error("CsarHandlerException exception caught during the notification processing", e);
- this.sendASDCNotification(NotificationType.DOWNLOAD, csar.getArtifactElement().getArtifactURL(),
- sdcConfig.getConsumerID(), iNotif.getDistributionID(), DistributionStatusEnum.DOWNLOAD_ERROR,
- e.getMessage(), System.currentTimeMillis());
+ this.sendASDCNotification(NotificationType.DOWNLOAD, null, sdcConfig.getConsumerID(),
+ iNotif.getDistributionID(), DistributionStatusEnum.DOWNLOAD_ERROR, e.getMessage(),
+ System.currentTimeMillis());
} catch (SdcToscaParserException e) {
+ logger.error("SdcToscaParserException exception caught during the notification processing", e);
this.sendASDCNotification(NotificationType.DEPLOY, csar.getArtifactElement().getArtifactURL(),
sdcConfig.getConsumerID(), iNotif.getDistributionID(), DistributionStatusEnum.DEPLOY_ERROR,
e.getMessage(), System.currentTimeMillis());
@@ -291,19 +291,11 @@ public class SdcSingleController {
status, timestamp);
switch (notificationType) {
case DOWNLOAD:
- if (errorReason != null) {
- this.distributionClient.sendDownloadStatus(message, errorReason);
- } else {
- this.distributionClient.sendDownloadStatus(message);
- }
+ this.sendDownloadStatus(message, errorReason);
action = "sendDownloadStatus";
break;
case DEPLOY:
- if (errorReason != null) {
- this.distributionClient.sendDeploymentStatus(message, errorReason);
- } else {
- this.distributionClient.sendDeploymentStatus(message);
- }
+ this.sendDeploymentStatus(message, errorReason);
action = "sendDeploymentdStatus";
break;
default:
@@ -314,4 +306,20 @@ public class SdcSingleController {
}
logger.info("Sdc Notification sent successfully(" + action + ")");
}
+
+ private void sendDownloadStatus(IDistributionStatusMessage message, String errorReason) {
+ if (errorReason != null) {
+ this.distributionClient.sendDownloadStatus(message, errorReason);
+ } else {
+ this.distributionClient.sendDownloadStatus(message);
+ }
+ }
+
+ private void sendDeploymentStatus(IDistributionStatusMessage message, String errorReason) {
+ if (errorReason != null) {
+ this.distributionClient.sendDeploymentStatus(message, errorReason);
+ } else {
+ this.distributionClient.sendDeploymentStatus(message);
+ }
+ }
}