aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-03-05 13:38:34 +0100
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-03-05 13:38:34 +0100
commit912e5e9201bf60169ad39686ba5bd9d9bc6e3579 (patch)
tree2f11bc4045218ef5d9714e607523562d32d6ab16 /src/main/java
parent886191eea29a6a87b891d869e8b3855c95967c49 (diff)
Rework configuration
Move the JSON content from the properties file to json files for all configuration defined in clds-reference.properties Issue-ID: CLAMP-136 Change-Id: Idfb21be729d7260518756e5f585371de78d18944 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/client/DcaeDispatcherServices.java2
-rw-r--r--src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java2
-rw-r--r--src/main/java/org/onap/clamp/clds/config/CldsReferenceProperties.java74
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/DistributionStatusMessage.java70
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleControllerStatus.java28
-rw-r--r--src/main/java/org/onap/clamp/clds/util/ResourceFileUtil.java2
6 files changed, 165 insertions, 13 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 ab3a71159..f92405813 100644
--- a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
+++ b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
@@ -50,7 +50,7 @@ public class DcaeDispatcherServices {
private CldsReferenceProperties refProp;
private static final String STATUS_URL_LOG = "Status URL extracted: ";
private static final String DCAE_URL_PREFIX = "/dcae-deployments/";
- private static final String DCAE_URL_PROPERTY_NAME = "DCAE_DISPATCHER_URL";
+ private static final String DCAE_URL_PROPERTY_NAME = "dcae.dispatcher.url";
private static final String DCAE_REQUEST_FAILED_LOG = "RequestFailed - responseStr=";
public static final String DCAE_REQUESTID_PROPERTY_NAME = "dcae.header.requestId";
private static final String DCAE_LINK_FIELD = "links";
diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java
index 1abd88985..4a2f32e6e 100644
--- a/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java
+++ b/src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java
@@ -61,7 +61,7 @@ public class DcaeInventoryServices {
protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeInventoryServices.class);
protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- private static final String DCAE_INVENTORY_URL = "DCAE_INVENTORY_URL";
+ private static final String DCAE_INVENTORY_URL = "dcae.inventory.url";
@Autowired
private CldsReferenceProperties refProp;
@Autowired
diff --git a/src/main/java/org/onap/clamp/clds/config/CldsReferenceProperties.java b/src/main/java/org/onap/clamp/clds/config/CldsReferenceProperties.java
index c0f7a7286..b234b9329 100644
--- a/src/main/java/org/onap/clamp/clds/config/CldsReferenceProperties.java
+++ b/src/main/java/org/onap/clamp/clds/config/CldsReferenceProperties.java
@@ -27,10 +27,13 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.util.Properties;
import javax.annotation.PostConstruct;
+import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
@@ -65,10 +68,11 @@ public class CldsReferenceProperties {
}
/**
- * get property value
+ * get property value.
*
* @param key
- * @return
+ * The first key
+ * @return The string with the value
*/
public String getStringValue(String key) {
return prop.getProperty(key);
@@ -79,8 +83,10 @@ public class CldsReferenceProperties {
* use key1.
*
* @param key1
+ * The first key
* @param key2
- * @return
+ * The second key after a dot
+ * @return The string with the value
*/
public String getStringValue(String key1, String key2) {
String value = getStringValue(key1 + "." + key2);
@@ -91,29 +97,77 @@ public class CldsReferenceProperties {
}
/**
- * Return json as objects that can be updated
+ * Return json as objects that can be updated. The value obtained from the
+ * clds-reference file will be used as a filename.
*
* @param key
- * @return
+ * The key that will be used to access the clds-reference file
+ * @return A jsonNode
* @throws IOException
+ * In case of issues with the JSON parser
*/
public JsonNode getJsonTemplate(String key) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
- return objectMapper.readValue(getStringValue(key), JsonNode.class);
+ String fileReference = getStringValue(key);
+ return (fileReference != null) ? objectMapper.readValue(getFileContentFromPath(fileReference), JsonNode.class)
+ : null;
}
/**
* Return json as objects that can be updated. First try with combo key
- * (key1 + "." + key2), otherwise default to just key1.
+ * (key1 + "." + key2), otherwise default to just key1. The value obtained
+ * from the clds-reference file will be used as a filename.
*
* @param key1
+ * The first key
* @param key2
- * @return
+ * The second key after a dot
+ * @return A JsonNode
* @throws IOException
+ * In case of issues with the JSON parser
*/
public JsonNode getJsonTemplate(String key1, String key2) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
- String result = getStringValue(key1, key2);
- return (result != null) ? objectMapper.readValue(result, JsonNode.class) : null;
+ String fileReference = getStringValue(key1, key2);
+ return (fileReference != null) ? objectMapper.readValue(getFileContentFromPath(fileReference), JsonNode.class)
+ : null;
+ }
+
+ /**
+ * Return the file content. The value obtained from the clds-reference file
+ * will be used as a filename.
+ *
+ * @param key
+ * The key that will be used to access the clds-reference file
+ * @return File content in String
+ * @throws IOException
+ * In case of issues with the JSON parser
+ */
+ public String getFileContent(String key) throws IOException {
+ String fileReference = getStringValue(key);
+ return (fileReference != null) ? getFileContentFromPath(fileReference) : null;
+ }
+
+ /**
+ * Return the file content. First try with combo key (key1 + "." + key2),
+ * otherwise default to just key1. The value obtained from the
+ * clds-reference file will be used as a filename.
+ *
+ * @param key1
+ * The first key
+ * @param key2
+ * The second key after a dot
+ * @return File content in String
+ * @throws IOException
+ * In case of issues with the JSON parser
+ */
+ public String getFileContent(String key1, String key2) throws IOException {
+ String fileReference = getStringValue(key1, key2);
+ return (fileReference != null) ? getFileContentFromPath(fileReference) : null;
+ }
+
+ private String getFileContentFromPath(String filepath) throws IOException {
+ URL url = appContext.getResource(filepath).getURL();
+ return IOUtils.toString(url, StandardCharsets.UTF_8);
}
}
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/DistributionStatusMessage.java b/src/main/java/org/onap/clamp/clds/sdc/controller/DistributionStatusMessage.java
new file mode 100644
index 000000000..db5d271b0
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/DistributionStatusMessage.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 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.
+ * 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
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.clamp.clds.sdc.controller;
+
+import org.openecomp.sdc.api.consumer.IDistributionStatusMessage;
+import org.openecomp.sdc.utils.DistributionStatusEnum;
+
+public class DistributionStatusMessage implements IDistributionStatusMessage {
+
+ private String artifactURL;
+ private String consumerID;
+ private String distributionID;
+ private DistributionStatusEnum distributionStatus;
+ private long timestamp;
+
+ public DistributionStatusMessage(final String artifactUrl, final String consumerId, final String distributionId,
+ final DistributionStatusEnum distributionStatusEnum, final long timestampL) {
+ artifactURL = artifactUrl;
+ consumerID = consumerId;
+ distributionID = distributionId;
+ distributionStatus = distributionStatusEnum;
+ timestamp = timestampL;
+ }
+
+ @Override
+ public String getArtifactURL() {
+ return artifactURL;
+ }
+
+ @Override
+ public String getConsumerID() {
+ return consumerID;
+ }
+
+ @Override
+ public String getDistributionID() {
+ return distributionID;
+ }
+
+ @Override
+ public DistributionStatusEnum getStatus() {
+ return distributionStatus;
+ }
+
+ @Override
+ public long getTimestamp() {
+ return timestamp;
+ }
+}
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleControllerStatus.java b/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleControllerStatus.java
new file mode 100644
index 000000000..8fbf41614
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleControllerStatus.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 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.
+ * 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
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.clamp.clds.sdc.controller;
+
+public enum SdcSingleControllerStatus {
+ STOPPED, IDLE, BUSY
+}
diff --git a/src/main/java/org/onap/clamp/clds/util/ResourceFileUtil.java b/src/main/java/org/onap/clamp/clds/util/ResourceFileUtil.java
index 57705d8fd..720576c47 100644
--- a/src/main/java/org/onap/clamp/clds/util/ResourceFileUtil.java
+++ b/src/main/java/org/onap/clamp/clds/util/ResourceFileUtil.java
@@ -28,7 +28,7 @@ import java.io.InputStream;
import java.util.Scanner;
/**
- * Utility methods supporting transforms.
+ * Utility methods supporting resources accesses.
*/
public final class ResourceFileUtil {