aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/clamp
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2020-01-16 14:35:57 +0100
committerSébastien Determe <sebastien.determe@intl.att.com>2020-01-16 13:39:34 +0000
commit2e7b15f6a71764e2dba81b70187b17f1fbbb32ab (patch)
tree2824436b712292a3525127ae7b37e7cdcbccf4df /src/main/java/org/onap/clamp
parent5dfa4b58906921dea2aab38d20d761f460f49964 (diff)
Fix checkstyle issue
Fix checkstyle issues and remove useless files Issue-ID: CLAMP-555 Change-Id: I02382ed48d7321b0a6b8650efbf7663f943f17ba Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/main/java/org/onap/clamp')
-rw-r--r--src/main/java/org/onap/clamp/clds/config/spring/CldsConfiguration.java2
-rw-r--r--src/main/java/org/onap/clamp/clds/config/spring/SdcControllerConfiguration.java6
-rw-r--r--src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java15
-rw-r--r--src/main/java/org/onap/clamp/clds/util/JsonUtils.java120
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopService.java7
-rw-r--r--src/main/java/org/onap/clamp/loop/common/AuditEntity.java42
-rw-r--r--src/main/java/org/onap/clamp/loop/service/Service.java3
-rw-r--r--src/main/java/org/onap/clamp/util/PassDecoder.java4
8 files changed, 57 insertions, 142 deletions
diff --git a/src/main/java/org/onap/clamp/clds/config/spring/CldsConfiguration.java b/src/main/java/org/onap/clamp/clds/config/spring/CldsConfiguration.java
index fdac85232..b2478462f 100644
--- a/src/main/java/org/onap/clamp/clds/config/spring/CldsConfiguration.java
+++ b/src/main/java/org/onap/clamp/clds/config/spring/CldsConfiguration.java
@@ -58,7 +58,7 @@ public class CldsConfiguration {
/**
* This loads the file system.properties.
*
- * @return
+ * @return The PropertiesFactoryBean
*/
@Bean(name = "mapper")
public PropertiesFactoryBean mapper() {
diff --git a/src/main/java/org/onap/clamp/clds/config/spring/SdcControllerConfiguration.java b/src/main/java/org/onap/clamp/clds/config/spring/SdcControllerConfiguration.java
index 261288503..5a3e22a35 100644
--- a/src/main/java/org/onap/clamp/clds/config/spring/SdcControllerConfiguration.java
+++ b/src/main/java/org/onap/clamp/clds/config/spring/SdcControllerConfiguration.java
@@ -69,9 +69,9 @@ public class SdcControllerConfiguration {
@PostConstruct
public void loadSdcControllers() {
SdcControllersConfiguration sdcControllersConfig = getSdcControllersConfiguration();
- sdcControllersConfig.getAllDefinedControllers().forEach((k, v) -> {
- logger.info("Creating controller instance:" + k);
- SdcSingleController sdcController = new SdcSingleController(clampProp, csarInstaller, v, null);
+ sdcControllersConfig.getAllDefinedControllers().forEach((key, value) -> {
+ logger.info("Creating controller instance:" + key);
+ SdcSingleController sdcController = new SdcSingleController(clampProp, csarInstaller, value, null);
sdcControllersList.add(sdcController);
});
}
diff --git a/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java b/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java
index 2e025ba7d..232db48c4 100644
--- a/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java
+++ b/src/main/java/org/onap/clamp/clds/tosca/ToscaYamlToJsonConvertor.java
@@ -360,21 +360,6 @@ public class ToscaYamlToJsonConvertor {
JSONArray jsonArray = new JSONArray();
((LinkedHashMap<String, Object>) dataNodes.get(typeValue)).entrySet().stream().forEach(pmap -> {
if (pmap.getKey().equalsIgnoreCase(ToscaSchemaConstants.PROPERTIES)) {
-
- ((LinkedHashMap<String, Object>) pmap.getValue()).entrySet().stream().forEach(p -> {
- if (p.getValue() instanceof Map) {
- LinkedHashMap<String, Object> childNodeMap2 = (LinkedHashMap<String, Object>) p
- .getValue();
- if (childNodeMap2.containsKey(ToscaSchemaConstants.TYPE)
- && (((String) childNodeMap2.get(ToscaSchemaConstants.TYPE))
- .contains(ToscaSchemaConstants.POLICY_DATA))) {
- }
- }
- });
- }
- });
- ((LinkedHashMap<String, Object>) dataNodes.get(typeValue)).entrySet().stream().forEach(pmap -> {
- if (pmap.getKey().equalsIgnoreCase(ToscaSchemaConstants.PROPERTIES)) {
parseToscaPropertiesForType(childObjectKey,
(LinkedHashMap<String, Object>) pmap.getValue(), entrySchemaObject, childArray,
jsonEntrySchema, dataNodes, true, incrementComplexSimpleTypeOrder());
diff --git a/src/main/java/org/onap/clamp/clds/util/JsonUtils.java b/src/main/java/org/onap/clamp/clds/util/JsonUtils.java
index cc875d6d9..704d3ac37 100644
--- a/src/main/java/org/onap/clamp/clds/util/JsonUtils.java
+++ b/src/main/java/org/onap/clamp/clds/util/JsonUtils.java
@@ -25,21 +25,10 @@ package org.onap.clamp.clds.util;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonPrimitive;
import java.time.Instant;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.Spliterator;
-import java.util.Spliterators;
-import java.util.stream.Collectors;
-import java.util.stream.StreamSupport;
import org.onap.clamp.clds.service.SecureServicePermission;
import org.onap.clamp.clds.service.SecureServicePermissionDeserializer;
@@ -52,8 +41,6 @@ import org.onap.clamp.dao.model.gson.converter.InstantSerializer;
public class JsonUtils {
protected static final EELFLogger logger = EELFManager.getInstance().getLogger(JsonUtils.class);
- private static final String LOG_ELEMENT_NOT_FOUND = "Value '{}' for key 'name' not found in JSON";
- private static final String LOG_ELEMENT_NOT_FOUND_IN_JSON = "Value '{}' for key 'name' not found in JSON {}";
public static final Gson GSON = new GsonBuilder()
.registerTypeAdapter(SecureServicePermission.class, new SecureServicePermissionDeserializer()).create();
@@ -65,111 +52,4 @@ public class JsonUtils {
private JsonUtils() {
}
-
- /**
- * typeAdapter Return the value field of the json node element that has a name
- * field equals to the given name.
- */
- public static String getStringValueByName(JsonElement jsonElement, String name) {
- String value = extractJsonValueFromElement(jsonElement, name).map(JsonUtils::extractStringValueFromElement)
- .orElse(null);
- if (value == null) {
- if (logger.isDebugEnabled()) {
- logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, jsonElement.toString());
- } else {
- logger.warn(LOG_ELEMENT_NOT_FOUND, name);
- }
- }
- return value;
- }
-
- /**
- * 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> getStringValuesByName(JsonElement jsonElement, String name) {
- List<String> values = extractJsonValueFromElement(jsonElement, name)
- .map(JsonUtils::extractStringValuesFromElement).orElse(new ArrayList<>());
- if (values.isEmpty()) {
- if (logger.isDebugEnabled()) {
- logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, jsonElement.toString());
- } else {
- logger.warn(LOG_ELEMENT_NOT_FOUND, name);
- }
- }
- return values;
- }
-
- /**
- * Return the int value field of the json node element that has a name field
- * equals to the given name.
- */
- public static Integer getIntValueByName(JsonElement element, String name) {
- String value = getStringValueByName(element, name);
- return Integer.valueOf(value);
- }
-
- /**
- * Return the Json value field of the json node element that has a name field
- * equals to the given name.
- */
- public static JsonObject getJsonObjectByName(JsonElement jsonElement, String name) {
- JsonObject jsonObject = extractJsonValueFromElement(jsonElement, name).map(JsonElement::getAsJsonObject)
- .orElse(null);
- if (jsonObject == null) {
- logger.warn(LOG_ELEMENT_NOT_FOUND, name);
- } else {
- logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, jsonElement.toString());
- }
- return jsonObject;
- }
-
- private static Optional<JsonElement> extractJsonValueFromElement(JsonElement jsonElement, String name) {
- if (jsonElement != null) {
- if (jsonElement.isJsonArray()) {
- return extractValueJsonFromArray(jsonElement, name);
- } else if (hasMatchingParameterName(name, jsonElement)) {
- return Optional.of(jsonElement);
- }
- }
- return Optional.empty();
- }
-
- private static Optional<JsonElement> extractValueJsonFromArray(JsonElement jsonElement, String name) {
- for (JsonElement element : jsonElement.getAsJsonArray()) {
- if (hasMatchingParameterName(name, element)) {
- return Optional.of(element.getAsJsonObject().get("value"));
- }
- }
- return Optional.empty();
- }
-
- private static boolean hasMatchingParameterName(String name, JsonElement element) {
- return element.isJsonObject() && element.getAsJsonObject().has("name")
- && name.equals(element.getAsJsonObject().get("name").getAsString());
- }
-
- private static String extractStringValueFromElement(JsonElement element) {
- if (element.isJsonArray()) {
- return element.getAsJsonArray().get(0).getAsString();
- } else if (element.isJsonPrimitive()) {
- return element.getAsJsonPrimitive().getAsString();
- } else {
- return GSON.toJson(element);
- }
- }
-
- private static List<String> extractStringValuesFromElement(JsonElement element) {
- if (element.isJsonArray()) {
- return StreamSupport
- .stream(Spliterators.spliteratorUnknownSize(element.getAsJsonArray().iterator(),
- Spliterator.ORDERED), false)
- .filter(JsonElement::isJsonPrimitive).map(JsonElement::getAsJsonPrimitive)
- .filter(JsonPrimitive::isString).map(JsonPrimitive::getAsString).collect(Collectors.toList());
- } else {
- String value = extractStringValueFromElement(element);
- return Lists.newArrayList(value);
- }
-
- }
}
diff --git a/src/main/java/org/onap/clamp/loop/LoopService.java b/src/main/java/org/onap/clamp/loop/LoopService.java
index e52029662..fb857fbf4 100644
--- a/src/main/java/org/onap/clamp/loop/LoopService.java
+++ b/src/main/java/org/onap/clamp/loop/LoopService.java
@@ -65,6 +65,13 @@ public class LoopService {
loopsRepository.deleteById(loopName);
}
+ /**
+ * This method is used to refresh the DCAE deployment status fields.
+ *
+ * @param loop The loop instance to be modified
+ * @param deploymentId The deployment ID as returned by DCAE
+ * @param deploymentUrl The Deployment URL as returned by DCAE
+ */
public void updateDcaeDeploymentFields(Loop loop, String deploymentId, String deploymentUrl) {
loop.setDcaeDeploymentId(deploymentId);
loop.setDcaeDeploymentStatusUrl(deploymentUrl);
diff --git a/src/main/java/org/onap/clamp/loop/common/AuditEntity.java b/src/main/java/org/onap/clamp/loop/common/AuditEntity.java
index 445f5b9e8..bf9d10d74 100644
--- a/src/main/java/org/onap/clamp/loop/common/AuditEntity.java
+++ b/src/main/java/org/onap/clamp/loop/common/AuditEntity.java
@@ -38,6 +38,10 @@ import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+/**
+ * This class is the parent of the hibernate entities requiring to be audited.
+ *
+ */
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class AuditEntity {
@@ -66,6 +70,11 @@ public class AuditEntity {
return createdDate;
}
+ /**
+ * createdDate setter.
+ *
+ * @param createdDate The created Date object
+ */
public void setCreatedDate(Instant createdDate) {
if (createdDate != null) {
this.createdDate = createdDate.truncatedTo(ChronoUnit.SECONDS);
@@ -74,10 +83,20 @@ public class AuditEntity {
}
}
+ /**
+ * updatedDate getter.
+ *
+ * @return the updatedDate
+ */
public Instant getUpdatedDate() {
return updatedDate;
}
+ /**
+ * updatedDate setter.
+ *
+ * @param updatedDate updatedDate to set
+ */
public void setUpdatedDate(Instant updatedDate) {
if (updatedDate != null) {
this.updatedDate = updatedDate.truncatedTo(ChronoUnit.SECONDS);
@@ -86,22 +105,45 @@ public class AuditEntity {
}
}
+ /**
+ * updatedBy getter.
+ *
+ * @return the updatedBy
+ */
public String getUpdatedBy() {
return updatedBy;
}
+ /**
+ * updatedBy setter.
+ *
+ * @param updatedBy the updatedBy
+ */
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
+ /**
+ * createdBy getter.
+ *
+ * @return the createdBy
+ */
public String getCreatedBy() {
return createdBy;
}
+ /**
+ * createdBy setter.
+ *
+ * @param createdBy the createdBy to set
+ */
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
+ /**
+ * Empty constructor.
+ */
public AuditEntity() {
}
diff --git a/src/main/java/org/onap/clamp/loop/service/Service.java b/src/main/java/org/onap/clamp/loop/service/Service.java
index b74ee0b0d..33b8e02da 100644
--- a/src/main/java/org/onap/clamp/loop/service/Service.java
+++ b/src/main/java/org/onap/clamp/loop/service/Service.java
@@ -86,11 +86,10 @@ public class Service implements Serializable {
*/
public Service(String serviceDetails, String resourceDetails) {
JsonObject serviceDetailsJson = JsonUtils.GSON.fromJson(serviceDetails, JsonObject.class);
- JsonObject resourceDetailsJson = JsonUtils.GSON.fromJson(resourceDetails, JsonObject.class);
this.name = serviceDetailsJson.get("name").getAsString();
this.serviceUuid = serviceDetailsJson.get("UUID").getAsString();
this.serviceDetails = serviceDetailsJson;
- this.resourceDetails = resourceDetailsJson;
+ this.resourceDetails = JsonUtils.GSON.fromJson(resourceDetails, JsonObject.class);
}
/**
diff --git a/src/main/java/org/onap/clamp/util/PassDecoder.java b/src/main/java/org/onap/clamp/util/PassDecoder.java
index 70a47477e..029f55d69 100644
--- a/src/main/java/org/onap/clamp/util/PassDecoder.java
+++ b/src/main/java/org/onap/clamp/util/PassDecoder.java
@@ -29,6 +29,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+
import org.onap.aaf.cadi.Symm;
import org.onap.clamp.clds.util.ResourceFileUtil;
@@ -43,8 +44,9 @@ public class PassDecoder {
/**
* Decode the password.
+ *
* @param encryptedPass The encrypted password
- * @param keyFileIs The key file in InputStream format
+ * @param keyFile The key file name in String
*/
public static String decode(String encryptedPass, String keyFile) {
if (null == keyFile) {