summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/clamp/clds/config/CldsReferenceProperties.java13
-rw-r--r--src/main/java/org/onap/clamp/clds/config/sdc/SdcControllersConfiguration.java94
-rw-r--r--src/main/java/org/onap/clamp/clds/exception/sdc/controller/SdcArtifactInstallerException.java55
-rw-r--r--src/main/java/org/onap/clamp/clds/exception/sdc/controller/SdcControllerException.java55
-rw-r--r--src/main/java/org/onap/clamp/clds/exception/sdc/controller/SdcDownloadException.java55
-rw-r--r--src/main/java/org/onap/clamp/clds/exception/sdc/controller/SdcParametersException.java55
6 files changed, 325 insertions, 2 deletions
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 a8acdee14..c0f7a7286 100644
--- a/src/main/java/org/onap/clamp/clds/config/CldsReferenceProperties.java
+++ b/src/main/java/org/onap/clamp/clds/config/CldsReferenceProperties.java
@@ -50,12 +50,20 @@ public class CldsReferenceProperties {
private String cldsReferenceValuesFile;
@PostConstruct
- public void loadConfig() throws IOException {
+ public void loadConfiguration() throws IOException {
prop = new Properties();
Resource resource = appContext.getResource(cldsReferenceValuesFile);
prop.load(resource.getInputStream());
}
+ public CldsReferenceProperties(String referenceValuesFile) throws IOException {
+ cldsReferenceValuesFile = referenceValuesFile;
+ loadConfiguration();
+ }
+
+ public CldsReferenceProperties() {
+ }
+
/**
* get property value
*
@@ -105,6 +113,7 @@ public class CldsReferenceProperties {
*/
public JsonNode getJsonTemplate(String key1, String key2) throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
- return objectMapper.readValue(getStringValue(key1, key2), JsonNode.class);
+ String result = getStringValue(key1, key2);
+ return (result != null) ? objectMapper.readValue(result, JsonNode.class) : null;
}
}
diff --git a/src/main/java/org/onap/clamp/clds/config/sdc/SdcControllersConfiguration.java b/src/main/java/org/onap/clamp/clds/config/sdc/SdcControllersConfiguration.java
new file mode 100644
index 000000000..c99dd21fd
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/config/sdc/SdcControllersConfiguration.java
@@ -0,0 +1,94 @@
+/*-
+ * ============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.config.sdc;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+
+import org.onap.clamp.clds.exception.sdc.controller.SdcParametersException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.ApplicationContext;
+import org.springframework.core.io.Resource;
+import org.springframework.stereotype.Component;
+
+/**
+ * This class maps the SDC config JSON file. This JSON can have multiple
+ * sdc-controller config. So the json is loaded in a static way and the instance
+ * must specify the controller name that it represents.
+ */
+@Component
+public class SdcControllersConfiguration {
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcControllersConfiguration.class);
+ public static final String CONTROLLER_SUBTREE_KEY = "sdc-connections";
+ @Autowired
+ protected ApplicationContext appContext;
+ /**
+ * The file name that will be loaded by Spring.
+ */
+ @Value("${org.onap.clamp.config.files.sdcController:'classpath:/clds/sdc-controllers-config.json'}")
+ protected String sdcControllerFile;
+ /**
+ * The root of the JSON.
+ */
+ private JsonNode jsonRootNode;
+
+ @PostConstruct
+ public void loadConfiguration() throws IOException {
+ Resource resource = appContext.getResource(sdcControllerFile);
+ // Try to load json tree
+ jsonRootNode = new ObjectMapper().readValue(resource.getInputStream(), JsonNode.class);
+ }
+
+ public SdcSingleControllerConfiguration getSdcSingleControllerConfiguration(String controllerName) {
+ Map<String, SdcSingleControllerConfiguration> controllerMap = getAllDefinedControllers();
+ return controllerMap.get(controllerName);
+ }
+
+ /**
+ * This method reads all Controllers configurations and returns them.
+ *
+ * @return A list of controller Names defined in the config
+ */
+ public Map<String, SdcSingleControllerConfiguration> getAllDefinedControllers() {
+ Map<String, SdcSingleControllerConfiguration> result = new HashMap<>();
+ if (jsonRootNode.get(CONTROLLER_SUBTREE_KEY) != null) {
+ jsonRootNode.get(CONTROLLER_SUBTREE_KEY).fields().forEachRemaining(entry -> result.put(entry.getKey(),
+ new SdcSingleControllerConfiguration(entry.getValue(), entry.getKey())));
+ } else {
+ throw new SdcParametersException(
+ CONTROLLER_SUBTREE_KEY + " key not found in the file: " + sdcControllerFile);
+ }
+ return result;
+ }
+}
diff --git a/src/main/java/org/onap/clamp/clds/exception/sdc/controller/SdcArtifactInstallerException.java b/src/main/java/org/onap/clamp/clds/exception/sdc/controller/SdcArtifactInstallerException.java
new file mode 100644
index 000000000..973081c27
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/exception/sdc/controller/SdcArtifactInstallerException.java
@@ -0,0 +1,55 @@
+/*-
+ * ============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.exception.sdc.controller;
+
+/**
+ * Exception during SDC artifact installation.
+ */
+public class SdcArtifactInstallerException extends Exception {
+
+ /**
+ * serialization id.
+ */
+ private static final long serialVersionUID = 4095937499475915021L;
+
+ /**
+ * @param message
+ * The message to dump
+ * @param cause
+ * The Throwable cause object
+ */
+ public SdcArtifactInstallerException(final String message) {
+ super(message);
+ }
+
+ /**
+ * @param message
+ * The message to dump
+ * @param cause
+ * The Throwable cause object
+ */
+ public SdcArtifactInstallerException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/src/main/java/org/onap/clamp/clds/exception/sdc/controller/SdcControllerException.java b/src/main/java/org/onap/clamp/clds/exception/sdc/controller/SdcControllerException.java
new file mode 100644
index 000000000..9c347572f
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/exception/sdc/controller/SdcControllerException.java
@@ -0,0 +1,55 @@
+/*-
+ * ============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.exception.sdc.controller;
+
+/**
+ * Exception of the SDC controller.
+ */
+public class SdcControllerException extends Exception {
+
+ /**
+ * serialization id.
+ */
+ private static final long serialVersionUID = -4236006447255525130L;
+
+ /**
+ * @param message
+ * The message to dump
+ * @param cause
+ * The Throwable cause object
+ */
+ public SdcControllerException(final String message) {
+ super(message);
+ }
+
+ /**
+ * @param message
+ * The message to dump
+ * @param cause
+ * The Throwable cause object
+ */
+ public SdcControllerException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/src/main/java/org/onap/clamp/clds/exception/sdc/controller/SdcDownloadException.java b/src/main/java/org/onap/clamp/clds/exception/sdc/controller/SdcDownloadException.java
new file mode 100644
index 000000000..bace1ac48
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/exception/sdc/controller/SdcDownloadException.java
@@ -0,0 +1,55 @@
+/*-
+ * ============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.exception.sdc.controller;
+
+/**
+ * Exception during download from SDC.
+ */
+public class SdcDownloadException extends Exception {
+
+ /**
+ * serialization id.
+ */
+ private static final long serialVersionUID = -5276848693231134901L;
+
+ /**
+ * @param message
+ * The message to dump
+ * @param cause
+ * The Throwable cause object
+ */
+ public SdcDownloadException(final String message) {
+ super(message);
+ }
+
+ /**
+ * @param message
+ * The message to dump
+ * @param cause
+ * The Throwable cause object
+ */
+ public SdcDownloadException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/src/main/java/org/onap/clamp/clds/exception/sdc/controller/SdcParametersException.java b/src/main/java/org/onap/clamp/clds/exception/sdc/controller/SdcParametersException.java
new file mode 100644
index 000000000..6ff0f1546
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/exception/sdc/controller/SdcParametersException.java
@@ -0,0 +1,55 @@
+/*-
+ * ============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.exception.sdc.controller;
+
+/**
+ * Exception of the SDC controller.
+ */
+public class SdcParametersException extends RuntimeException {
+
+ /**
+ * serialization id.
+ */
+ private static final long serialVersionUID = 8425657297510362736L;
+
+ /**
+ * @param message
+ * The message to dump
+ * @param cause
+ * The Throwable cause object
+ */
+ public SdcParametersException(final String message) {
+ super(message);
+ }
+
+ /**
+ * @param message
+ * The message to dump
+ * @param cause
+ * The Throwable cause object
+ */
+ public SdcParametersException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+}