aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2018-12-20 16:41:55 +0100
committersebdet <sebastien.determe@intl.att.com>2018-12-20 16:41:55 +0100
commite463a1572a0155363665c321fc9b70a22d2952cb (patch)
tree44a007bb70bbe64ef425197e5043dcdfe88c81b1 /src/main/java
parentb650caf4fbed4615eaacd84ba1cc2d6da573f32c (diff)
Remove useless code
Remove code not used anymore + add tests to increase coverage Issue-ID: CLAMP-252 Change-Id: I7a1ec163f73fe88f62fe0981148087ea8f7b7341 Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java48
-rw-r--r--src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java20
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java51
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java129
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java126
5 files changed, 149 insertions, 225 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
index 16c18ae0e..4151c7aad 100644
--- a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
+++ b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
@@ -18,7 +18,7 @@
* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.client;
@@ -64,7 +64,6 @@ public class DcaeDispatcherServices {
this.dcaeHttpConnectionManager = dcaeHttpConnectionManager;
}
-
public String getOperationStatusWithRetry(String operationStatusUrl) throws InterruptedException {
String operationStatus = "";
for (int i = 0; i < Integer.valueOf(refProp.getStringValue("dcae.dispatcher.retry.limit")); i++) {
@@ -83,9 +82,9 @@ public class DcaeDispatcherServices {
/**
* Get the Operation Status from a specified URL.
- *
+ *
* @param statusUrl
- * The URL provided by a previous DCAE Query
+ * The URL provided by a previous DCAE Query
* @return The status
*/
public String getOperationStatus(String statusUrl) {
@@ -113,35 +112,14 @@ public class DcaeDispatcherServices {
}
/**
- * This method send a getDeployments operation to DCAE.
- */
- public void getDeployments() {
- Date startTime = new Date();
- LoggingUtils.setTargetContext("DCAE", "getDeployments");
- try {
- String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX;
- dcaeHttpConnectionManager.doDcaeHttpQuery(url, "GET", null, null);
- LoggingUtils.setResponseContext("0", "Get deployments success", this.getClass().getName());
- } catch (Exception e) {
- LoggingUtils.setResponseContext("900", "Get deployments failed", this.getClass().getName());
- LoggingUtils.setErrorContext("900", "Get deployments error");
- logger.error("Exception occurred during getDeployments Operation with DCAE", e);
- throw new DcaeDeploymentException("Exception occurred during getDeployments Operation with DCAE", e);
- } finally {
- LoggingUtils.setTimeContext(startTime, new Date());
- metricsLogger.info("getDeployments complete");
- }
- }
-
- /**
* Returns status URL for createNewDeployment operation.
*
* @param deploymentId
- * The deployment ID
+ * The deployment ID
* @param serviceTypeId
- * Service type ID
+ * Service type ID
* @param blueprintInputJson
- * The value for each blueprint parameters in a flat JSON
+ * The value for each blueprint parameters in a flat JSON
* @return The status URL
*/
public String createNewDeployment(String deploymentId, String serviceTypeId, JsonNode blueprintInputJson) {
@@ -157,7 +135,7 @@ public class DcaeDispatcherServices {
logger.info("Dcae api Body String - " + apiBodyString);
String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX + deploymentId;
String statusUrl = getDcaeResponse(url, "PUT", apiBodyString, "application/json", DCAE_LINK_FIELD,
- DCAE_STATUS_FIELD);
+ DCAE_STATUS_FIELD);
LoggingUtils.setResponseContext("0", "Create new deployment failed", this.getClass().getName());
return statusUrl;
} catch (Exception e) {
@@ -173,11 +151,11 @@ public class DcaeDispatcherServices {
/***
* Returns status URL for deleteExistingDeployment operation.
- *
+ *
* @param deploymentId
- * The deployment ID
+ * The deployment ID
* @param serviceTypeId
- * The service Type ID
+ * The service Type ID
* @return The status URL
*/
public String deleteExistingDeployment(String deploymentId, String serviceTypeId) {
@@ -188,7 +166,7 @@ public class DcaeDispatcherServices {
logger.info("Dcae api Body String - " + apiBodyString);
String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX + deploymentId;
String statusUrl = getDcaeResponse(url, "DELETE", apiBodyString, "application/json", DCAE_LINK_FIELD,
- DCAE_STATUS_FIELD);
+ DCAE_STATUS_FIELD);
LoggingUtils.setResponseContext("0", "Delete existing deployment success", this.getClass().getName());
return statusUrl;
@@ -197,7 +175,7 @@ public class DcaeDispatcherServices {
LoggingUtils.setErrorContext("900", "Delete existing deployment error");
logger.error("Exception occurred during deleteExistingDeployment Operation with DCAE", e);
throw new DcaeDeploymentException("Exception occurred during deleteExistingDeployment Operation with DCAE",
- e);
+ e);
} finally {
LoggingUtils.setTimeContext(startTime, new Date());
metricsLogger.info("deleteExistingDeployment complete");
@@ -205,7 +183,7 @@ public class DcaeDispatcherServices {
}
private String getDcaeResponse(String url, String requestMethod, String payload, String contentType, String node,
- String nodeAttr) throws IOException, ParseException {
+ String nodeAttr) throws IOException, ParseException {
Date startTime = new Date();
try {
String responseStr = dcaeHttpConnectionManager.doDcaeHttpQuery(url, requestMethod, payload, contentType);
diff --git a/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java b/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java
index 055847085..1fb86c0ce 100644
--- a/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java
+++ b/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java
@@ -5,20 +5,20 @@
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.config.spring;
@@ -61,7 +61,7 @@ public class CldsSdcControllerConfiguration {
SdcControllersConfiguration sdcControllersConfig = getSdcControllersConfiguration();
sdcControllersConfig.getAllDefinedControllers().forEach((k, v) -> {
logger.info("Creating controller instance:" + k);
- SdcSingleController sdcController = new SdcSingleController(clampProp, csarInstaller, v, true);
+ SdcSingleController sdcController = new SdcSingleController(clampProp, csarInstaller, v, null);
sdcControllersList.add(sdcController);
});
}
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java b/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java
index 6bf4194bd..571e5b1bc 100644
--- a/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java
+++ b/src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java
@@ -18,7 +18,7 @@
* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.model.properties;
@@ -50,8 +50,8 @@ public abstract class AbstractModelElement {
private static final String LOG_ELEMENT_NOT_FOUND_IN_JSON = "Value '{}' for key 'name' not found in JSON {}";
/**
- * Perform base parsing of properties for a ModelElement (such as,
- * VesCollector, Policy and Tca)
+ * Perform base parsing of properties for a ModelElement (such as, VesCollector,
+ * Policy and Tca)
*/
protected AbstractModelElement(String type, ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) {
this.type = type;
@@ -63,23 +63,6 @@ public abstract class AbstractModelElement {
}
/**
- * topicSubscribes is the topicPublishes of the from Model Element (the
- * previous one in the chain).
- *
- * @return the topicSubscribes
- */
- public String getTopicSubscribes() {
- // get fromId for this type
- String fromId = modelBpmn.getFromId(type);
- // find the type of the from model element
- String fromType = modelBpmn.getType(fromId);
- // get the model element for the type
- AbstractModelElement me = modelProp.getModelElementByType(fromType);
- // get the topic publishes for the model element
- return me.topicPublishes;
- }
-
- /**
* @return the topicPublishes
*/
public String getTopicPublishes() {
@@ -87,8 +70,8 @@ public abstract class AbstractModelElement {
}
/**
- * Return the value field of the json node element that has a name field
- * equals to the given name.
+ * Return the value field of the json node element that has a name field equals
+ * to the given name.
*/
public static String getValueByName(JsonNode nodeIn, String name) {
String value = null;
@@ -115,8 +98,8 @@ public abstract class AbstractModelElement {
}
/**
- * Return the Json value field of the json node element that has a name
- * field equals to the given name.
+ * Return the Json value field of the json node element that has a name field
+ * equals to the given name.
*/
public static JsonNode getJsonNodeByName(JsonNode nodeIn, String name) {
JsonNode vnode = null;
@@ -136,8 +119,8 @@ public abstract class AbstractModelElement {
}
/**
- * Return the value field of the json node element that has a name field
- * that equals the given name.
+ * Return the value field of the json node element that has a name field that
+ * equals the given name.
*/
public static String getNodeValueByName(JsonNode nodeIn, String name) {
String value = null;
@@ -153,8 +136,8 @@ public abstract class AbstractModelElement {
}
/**
- * Return the value field of the json node element that has a name field
- * that equals the given name.
+ * Return the value field of the json node element that has a name field that
+ * equals the given name.
*/
public static List<String> getNodeValuesByName(JsonNode nodeIn, String name) {
List<String> values = new ArrayList<>();
@@ -185,8 +168,8 @@ public abstract class AbstractModelElement {
}
/**
- * Return an array of values for the field of the json node element that has
- * a name field equals to the given name.
+ * Return an array of values for the field of the json node element that has a
+ * name field equals to the given name.
*/
public static List<String> getValuesByName(JsonNode nodeIn, String name) {
List<String> values = null;
@@ -221,8 +204,8 @@ public abstract class AbstractModelElement {
}
/**
- * Return the value field of the json node element that has a name field
- * equals to the given name.
+ * Return the value field of the json node element that has a name field equals
+ * to the given name.
*/
public String getValueByName(String name) {
return getValueByName(modelElementJsonNode, name);
@@ -237,8 +220,8 @@ public abstract class AbstractModelElement {
}
/**
- * Return an array of values for the field of the json node element that has
- * a name field equals to the given name.
+ * Return an array of values for the field of the json node element that has a
+ * name field equals to the given name.
*/
public List<String> getValuesByName(String name) {
return getValuesByName(modelElementJsonNode, name);
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java b/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java
index b56794005..3d7bbcc3a 100644
--- a/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java
+++ b/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java
@@ -39,7 +39,6 @@ import org.apache.camel.Exchange;
import org.onap.clamp.clds.client.req.policy.PolicyClient;
import org.onap.clamp.clds.config.ClampProperties;
import org.onap.clamp.clds.exception.ModelBpmnException;
-import org.onap.clamp.clds.model.CldsEvent;
import org.onap.clamp.clds.model.CldsModel;
import org.onap.clamp.clds.service.CldsService;
import org.onap.clamp.clds.util.JacksonUtils;
@@ -75,22 +74,22 @@ public class ModelProperties {
}
/**
- * Retain data required to parse the ModelElement objects. (Rather than
- * parse them all - parse them on demand if requested.)
+ * Retain data required to parse the ModelElement objects. (Rather than parse
+ * them all - parse them on demand if requested.)
*
* @param modelName
- * The model name coming form the UI
+ * The model name coming form the UI
* @param controlName
- * The closed loop name coming from the UI
+ * The closed loop name coming from the UI
* @param actionCd
- * Type of operation PUT,UPDATE,DELETE
+ * Type of operation PUT,UPDATE,DELETE
* @param isATest
- * The test flag coming from the UI (for validation only, no
- * query are physically executed)
+ * The test flag coming from the UI (for validation only, no query are
+ * physically executed)
* @param modelBpmnText
- * The BPMN flow in JSON from the UI
+ * The BPMN flow in JSON from the UI
* @param modelPropText
- * The BPMN parameters for all boxes defined in modelBpmnTest
+ * The BPMN parameters for all boxes defined in modelBpmnTest
*/
public ModelProperties(String modelName, String controlName, String actionCd, boolean isATest, String modelBpmnText,
String modelPropText) {
@@ -108,10 +107,10 @@ public class ModelProperties {
}
/**
- * This method is meant to ensure that one ModelElement instance exists for
- * each ModelElement class. As new ModelElement classes could have been
- * registered after instantiation of this ModelProperties, we need to build
- * the missing ModelElement instances.
+ * This method is meant to ensure that one ModelElement instance exists for each
+ * ModelElement class. As new ModelElement classes could have been registered
+ * after instantiation of this ModelProperties, we need to build the missing
+ * ModelElement instances.
*/
private final void instantiateMissingModelElements() {
if (modelElementClasses.size() != modelElements.size()) {
@@ -120,19 +119,18 @@ public class ModelProperties {
// Parse the list of base Model Elements and build up the
// ModelElements
modelElementClasses.entrySet().stream().parallel()
- .filter(entry -> (AbstractModelElement.class.isAssignableFrom(entry.getKey())
- && missingTypes.contains(entry.getValue())))
- .forEach(entry -> {
- try {
- modelElements.put(entry.getValue(),
- (entry.getKey()
- .getConstructor(ModelProperties.class, ModelBpmn.class, JsonNode.class)
- .newInstance(this, modelBpmn, modelJson)));
- } catch (InstantiationException | NoSuchMethodException | IllegalAccessException
- | InvocationTargetException e) {
- logger.warn("Unable to instantiate a ModelElement, exception follows: ", e);
- }
- });
+ .filter(entry -> (AbstractModelElement.class.isAssignableFrom(entry.getKey())
+ && missingTypes.contains(entry.getValue())))
+ .forEach(entry -> {
+ try {
+ modelElements.put(entry.getValue(),
+ (entry.getKey().getConstructor(ModelProperties.class, ModelBpmn.class, JsonNode.class)
+ .newInstance(this, modelBpmn, modelJson)));
+ } catch (InstantiationException | NoSuchMethodException | IllegalAccessException
+ | InvocationTargetException e) {
+ logger.warn("Unable to instantiate a ModelElement, exception follows: ", e);
+ }
+ });
}
}
@@ -162,10 +160,9 @@ public class ModelProperties {
* Create ModelProperties extracted from a CamelExchange.
*
* @param camelExchange
- * The camel Exchange object that contains all info provided to
- * the flow
- * @return A model Properties created from the parameters found in
- * camelExchange object
+ * The camel Exchange object that contains all info provided to the flow
+ * @return A model Properties created from the parameters found in camelExchange
+ * object
*/
public static ModelProperties create(Exchange camelExchange) {
String modelProp = (String) camelExchange.getProperty("modelProp");
@@ -178,20 +175,6 @@ public class ModelProperties {
}
/**
- * return appropriate model element given the type
- *
- * @param type
- * @return
- */
- public AbstractModelElement getModelElementByType(String type) {
- AbstractModelElement modelElement = modelElements.get(type);
- if (modelElement == null) {
- throw new IllegalArgumentException("Invalid or not found ModelElement type: " + type);
- }
- return modelElement;
- }
-
- /**
* @return the modelName
*/
public String getModelName() {
@@ -231,12 +214,11 @@ public class ModelProperties {
}
/**
- * @return The policyName that wil be used in input parameters of DCAE
- * deploy
+ * @return The policyName that wil be used in input parameters of DCAE deploy
*/
public String getPolicyNameForDcaeDeploy(ClampProperties refProp) {
return normalizePolicyScopeName(modelName + createScopeSeparator(modelName)
- + refProp.getStringValue(PolicyClient.POLICY_MS_NAME_PREFIX_PROPERTY_NAME) + getCurrentPolicyName());
+ + refProp.getStringValue(PolicyClient.POLICY_MS_NAME_PREFIX_PROPERTY_NAME) + getCurrentPolicyName());
}
/**
@@ -251,8 +233,8 @@ public class ModelProperties {
* @return the policyScopeAndNameWithUniqueId
*/
public String getPolicyScopeAndNameWithUniqueGuardId() {
- return normalizePolicyScopeName(
- modelName + createScopeSeparator(modelName) + getCurrentPolicyName() + "_" + policyUniqueId+POLICY_GUARD_SUFFIX+guardUniqueId);
+ return normalizePolicyScopeName(modelName + createScopeSeparator(modelName) + getCurrentPolicyName() + "_"
+ + policyUniqueId + POLICY_GUARD_SUFFIX + guardUniqueId);
}
/**
@@ -266,18 +248,19 @@ public class ModelProperties {
/**
* @return the PolicyNameWithScopeContext
*/
- public String getPolicyNameWithScopeContext(String policyScope, String policyType, String vnfScope, String context, String userDefinedName) {
- return normalizePolicyScopeName(
- policyScope + createScopeSeparator(policyScope) + policyType + "_" + vnfScope + "_" + context + "_" + modelName + "_" + userDefinedName);
+ public String getPolicyNameWithScopeContext(String policyScope, String policyType, String vnfScope, String context,
+ String userDefinedName) {
+ return normalizePolicyScopeName(policyScope + createScopeSeparator(policyScope) + policyType + "_" + vnfScope
+ + "_" + context + "_" + modelName + "_" + userDefinedName);
}
/**
* @return the PolicyNameWithPrefixScopeContext
*/
- public String getPolicyNameWithPrefixScopeContext(String policyScope, String policyType, String vnfScope, String context,
- String userDefinedName, String policyPrefix) {
- return normalizePolicyScopeName(policyScope + createScopeSeparator(policyScope) + policyPrefix + policyType + "_" + vnfScope + "_"
- + context + "_" + modelName + "_" + userDefinedName);
+ public String getPolicyNameWithPrefixScopeContext(String policyScope, String policyType, String vnfScope,
+ String context, String userDefinedName, String policyPrefix) {
+ return normalizePolicyScopeName(policyScope + createScopeSeparator(policyScope) + policyPrefix + policyType
+ + "_" + vnfScope + "_" + context + "_" + modelName + "_" + userDefinedName);
}
/**
@@ -298,11 +281,11 @@ public class ModelProperties {
}
/**
- * When generating a policy request for a model element, must set the id of
- * that model element using this method. Used to generate the policy name.
+ * When generating a policy request for a model element, must set the id of that
+ * model element using this method. Used to generate the policy name.
*
* @param currentModelElementId
- * the currentModelElementId to set
+ * the currentModelElementId to set
*/
public void setCurrentModelElementId(String currentModelElementId) {
this.currentModelElementId = currentModelElementId;
@@ -324,11 +307,11 @@ public class ModelProperties {
}
/**
- * When generating a policy request for a model element, must set the unique
- * id of that policy using this method. Used to generate the policy name.
+ * When generating a policy request for a model element, must set the unique id
+ * of that policy using this method. Used to generate the policy name.
*
* @param policyUniqueId
- * the policyUniqueId to set
+ * the policyUniqueId to set
*/
public void setPolicyUniqueId(String policyUniqueId) {
this.policyUniqueId = policyUniqueId;
@@ -349,26 +332,6 @@ public class ModelProperties {
}
/**
- * @return the isCreateRequest
- */
- public boolean isCreateRequest() {
- switch (actionCd) {
- case CldsEvent.ACTION_SUBMIT:
- case CldsEvent.ACTION_RESTART:
- return true;
- }
- return false;
- }
-
- public boolean isStopRequest() {
- switch (actionCd) {
- case CldsEvent.ACTION_STOP:
- return true;
- }
- return false;
- }
-
- /**
* @return the global
*/
public Global getGlobal() {
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 8796bae1c..5959c0fb5 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
@@ -19,7 +19,7 @@
* ============LICENSE_END============================================
* Modifications copyright (c) 2018 Nokia
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.sdc.controller;
@@ -81,8 +81,8 @@ public class SdcSingleController {
}
/**
- * This method can be called multiple times at the same moment. The
- * controller must be thread safe !
+ * This method can be called multiple times at the same moment. The controller
+ * must be thread safe !
*/
@Override
public void activateCallback(INotificationData iNotif) {
@@ -91,7 +91,7 @@ public class SdcSingleController {
sdcController.treatNotification(iNotif);
LoggingUtils.setTimeContext(startTime, new Date());
LoggingUtils.setResponseContext("0", "SDC Notification received and processed successfully",
- this.getClass().getName());
+ this.getClass().getName());
}
}
@@ -110,16 +110,16 @@ public class SdcSingleController {
protected final synchronized void changeControllerStatus(SdcSingleControllerStatus newControllerStatus) {
switch (newControllerStatus) {
- case BUSY:
- ++this.nbOfNotificationsOngoing;
- this.controllerStatus = newControllerStatus;
- break;
- case IDLE:
- this.changeControllerStatusIdle();
- break;
- default:
- this.controllerStatus = newControllerStatus;
- break;
+ case BUSY:
+ ++this.nbOfNotificationsOngoing;
+ this.controllerStatus = newControllerStatus;
+ break;
+ case IDLE:
+ this.changeControllerStatusIdle();
+ break;
+ default:
+ this.controllerStatus = newControllerStatus;
+ break;
}
}
@@ -128,8 +128,9 @@ public class SdcSingleController {
}
public SdcSingleController(ClampProperties clampProp, CsarInstaller csarInstaller,
- SdcSingleControllerConfiguration sdcSingleConfig, boolean isClientAutoManaged) {
- this.isSdcClientAutoManaged = isClientAutoManaged;
+ SdcSingleControllerConfiguration sdcSingleConfig, IDistributionClient distributionClient) {
+ this.distributionClient = distributionClient;
+ isSdcClientAutoManaged = (distributionClient == null);
this.sdcConfig = sdcSingleConfig;
this.refProp = clampProp;
this.csarInstaller = csarInstaller;
@@ -139,11 +140,10 @@ public class SdcSingleController {
* This method initializes the SDC Controller and the SDC Client.
*
* @throws SdcControllerException
- * It throws an exception if the SDC Client cannot be
- * instantiated or if an init attempt is done when already
- * initialized
+ * It throws an exception if the SDC Client cannot be instantiated or if
+ * an init attempt is done when already initialized
* @throws SdcParametersException
- * If there is an issue with the parameters provided
+ * If there is an issue with the parameters provided
*/
public void initSdc() throws SdcControllerException {
logger.info("Attempt to initialize the SDC Controller: " + sdcConfig.getSdcControllerName());
@@ -157,8 +157,8 @@ public class SdcSingleController {
if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
logger.error("SDC distribution client init failed with reason:" + result.getDistributionMessageResult());
this.changeControllerStatus(SdcSingleControllerStatus.STOPPED);
- throw new SdcControllerException("Initialization of the SDC Controller failed with reason: "
- + result.getDistributionMessageResult());
+ throw new SdcControllerException(
+ "Initialization of the SDC Controller failed with reason: " + result.getDistributionMessageResult());
}
logger.info("SDC Controller successfully initialized: " + sdcConfig.getSdcControllerName());
logger.info("Attempt to start the SDC Controller: " + sdcConfig.getSdcControllerName());
@@ -167,7 +167,7 @@ public class SdcSingleController {
logger.error("SDC distribution client start failed with reason:" + result.getDistributionMessageResult());
this.changeControllerStatus(SdcSingleControllerStatus.STOPPED);
throw new SdcControllerException(
- "Startup of the SDC Controller failed with reason: " + result.getDistributionMessageResult());
+ "Startup of the SDC Controller failed with reason: " + result.getDistributionMessageResult());
}
logger.info("SDC Controller successfully started: " + sdcConfig.getSdcControllerName());
this.changeControllerStatus(SdcSingleControllerStatus.IDLE);
@@ -177,8 +177,8 @@ public class SdcSingleController {
* This method closes the SDC Controller and the SDC Client.
*
* @throws SdcControllerException
- * It throws an exception if the SDC Client cannot be closed
- * because it's currently BUSY in processing notifications.
+ * It throws an exception if the SDC Client cannot be closed because
+ * it's currently BUSY in processing notifications.
*/
public void closeSdc() throws SdcControllerException {
if (this.getControllerStatus() == SdcSingleControllerStatus.BUSY) {
@@ -198,33 +198,33 @@ public class SdcSingleController {
}
private void sendAllNotificationForCsarHandler(INotificationData iNotif, CsarHandler csar,
- NotificationType notificationType, DistributionStatusEnum distributionStatus, String errorMessage) {
+ NotificationType notificationType, DistributionStatusEnum distributionStatus, String errorMessage) {
if (csar != null) {
// Notify for the CSAR
this.sendSdcNotification(notificationType, csar.getArtifactElement().getArtifactURL(),
- sdcConfig.getConsumerID(), iNotif.getDistributionID(), distributionStatus, errorMessage,
- System.currentTimeMillis());
+ sdcConfig.getConsumerID(), iNotif.getDistributionID(), distributionStatus, errorMessage,
+ System.currentTimeMillis());
// Notify for all VF resources found
for (Entry<String, BlueprintArtifact> blueprint : csar.getMapOfBlueprints().entrySet()) {
// Normally always 1 artifact in resource for Clamp as we
// specified
// only VF_METADATA type
this.sendSdcNotification(notificationType,
- blueprint.getValue().getResourceAttached().getArtifacts().get(0).getArtifactURL(),
- sdcConfig.getConsumerID(), iNotif.getDistributionID(), distributionStatus, errorMessage,
- System.currentTimeMillis());
+ blueprint.getValue().getResourceAttached().getArtifacts().get(0).getArtifactURL(),
+ sdcConfig.getConsumerID(), iNotif.getDistributionID(), distributionStatus, errorMessage,
+ System.currentTimeMillis());
}
} else {
this.sendSdcNotification(notificationType, null, sdcConfig.getConsumerID(), iNotif.getDistributionID(),
- distributionStatus, errorMessage, System.currentTimeMillis());
+ distributionStatus, errorMessage, System.currentTimeMillis());
}
}
/**
* This method processes the notification received from Sdc.
- *
+ *
* @param iNotif
- * The INotificationData
+ * The INotificationData
*/
public void treatNotification(INotificationData iNotif) {
CsarHandler csar = null;
@@ -235,37 +235,37 @@ public class SdcSingleController {
logger.info("Notification received for service UUID:" + iNotif.getServiceUUID());
this.changeControllerStatus(SdcSingleControllerStatus.BUSY);
csar = new CsarHandler(iNotif, this.sdcConfig.getSdcControllerName(),
- refProp.getStringValue(CONFIG_SDC_FOLDER));
+ refProp.getStringValue(CONFIG_SDC_FOLDER));
csar.save(downloadTheArtifact(csar.getArtifactElement()));
if (csarInstaller.isCsarAlreadyDeployed(csar)) {
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DOWNLOAD,
- DistributionStatusEnum.ALREADY_DOWNLOADED, null);
+ DistributionStatusEnum.ALREADY_DOWNLOADED, null);
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,
- DistributionStatusEnum.ALREADY_DEPLOYED, null);
+ DistributionStatusEnum.ALREADY_DEPLOYED, null);
} else {
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DOWNLOAD,
- DistributionStatusEnum.DOWNLOAD_OK, null);
+ DistributionStatusEnum.DOWNLOAD_OK, null);
csarInstaller.installTheCsar(csar);
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,
- DistributionStatusEnum.DEPLOY_OK, null);
+ DistributionStatusEnum.DEPLOY_OK, null);
}
} catch (SdcArtifactInstallerException | SdcToscaParserException e) {
logger.error("SdcArtifactInstallerException exception caught during the notification processing", e);
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,
- DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
+ DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
} catch (SdcDownloadException | CsarHandlerException e) {
logger.error("SdcDownloadException exception caught during the notification processing", e);
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DOWNLOAD,
- DistributionStatusEnum.DOWNLOAD_ERROR, e.getMessage());
+ DistributionStatusEnum.DOWNLOAD_ERROR, e.getMessage());
} catch (InterruptedException e) {
logger.error("Interrupt exception caught during the notification processing", e);
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,
- DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
+ DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
Thread.currentThread().interrupt();
} catch (RuntimeException e) {
logger.error("Unexpected exception caught during the notification processing", e);
sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,
- DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
+ DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
} finally {
this.changeControllerStatus(SdcSingleControllerStatus.IDLE);
}
@@ -276,8 +276,8 @@ public class SdcSingleController {
}
private IDistributionClientDownloadResult downloadTheArtifact(IArtifactInfo artifact) throws SdcDownloadException {
- logger.info("Trying to download the artifact : " + artifact.getArtifactURL() + " UUID: "
- + artifact.getArtifactUUID());
+ logger.info(
+ "Trying to download the artifact : " + artifact.getArtifactURL() + " UUID: " + artifact.getArtifactUUID());
IDistributionClientDownloadResult downloadResult;
try {
downloadResult = distributionClient.download(artifact);
@@ -290,20 +290,20 @@ public class SdcSingleController {
}
if (DistributionActionResultEnum.SUCCESS.equals(downloadResult.getDistributionActionResult())) {
logger.info("Successfully downloaded the artifact " + artifact.getArtifactURL() + " UUID "
- + artifact.getArtifactUUID() + "Size of payload " + downloadResult.getArtifactPayload().length);
+ + artifact.getArtifactUUID() + "Size of payload " + downloadResult.getArtifactPayload().length);
} else {
- throw new SdcDownloadException("Artifact " + artifact.getArtifactName()
- + " could not be downloaded from SDC URL " + artifact.getArtifactURL() + " UUID "
- + artifact.getArtifactUUID() + ")" + System.lineSeparator() + "Error message is "
- + downloadResult.getDistributionMessageResult() + System.lineSeparator());
+ throw new SdcDownloadException(
+ "Artifact " + artifact.getArtifactName() + " could not be downloaded from SDC URL "
+ + artifact.getArtifactURL() + " UUID " + artifact.getArtifactUUID() + ")" + System.lineSeparator()
+ + "Error message is " + downloadResult.getDistributionMessageResult() + System.lineSeparator());
}
return downloadResult;
}
private void sendSdcNotification(NotificationType notificationType, String artifactURL, String consumerID,
- String distributionID, DistributionStatusEnum status, String errorReason, long timestamp) {
+ String distributionID, DistributionStatusEnum status, String errorReason, long timestamp) {
String event = "Sending " + notificationType.name() + "(" + status.name() + ")"
- + " notification to SDC for artifact:" + artifactURL;
+ + " notification to SDC for artifact:" + artifactURL;
if (errorReason != null) {
event = event + "(" + errorReason + ")";
}
@@ -311,18 +311,18 @@ public class SdcSingleController {
String action = "";
try {
IDistributionStatusMessage message = new DistributionStatusMessage(artifactURL, consumerID, distributionID,
- status, timestamp);
+ status, timestamp);
switch (notificationType) {
- case DOWNLOAD:
- this.sendDownloadStatus(message, errorReason);
- action = "sendDownloadStatus";
- break;
- case DEPLOY:
- this.sendDeploymentStatus(message, errorReason);
- action = "sendDeploymentdStatus";
- break;
- default:
- break;
+ case DOWNLOAD:
+ this.sendDownloadStatus(message, errorReason);
+ action = "sendDownloadStatus";
+ break;
+ case DEPLOY:
+ this.sendDeploymentStatus(message, errorReason);
+ action = "sendDeploymentdStatus";
+ break;
+ default:
+ break;
}
} catch (RuntimeException e) {
logger.warn("Unable to send the SDC Notification (" + action + ") due to an exception", e);