aboutsummaryrefslogtreecommitdiffstats
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/spring/SSLConfiguration.java56
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java40
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java18
-rw-r--r--src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java2
4 files changed, 90 insertions, 26 deletions
diff --git a/src/main/java/org/onap/clamp/clds/config/spring/SSLConfiguration.java b/src/main/java/org/onap/clamp/clds/config/spring/SSLConfiguration.java
new file mode 100644
index 000000000..ac5849b80
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/config/spring/SSLConfiguration.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 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============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.config.spring;
+
+import java.net.URL;
+
+import javax.annotation.PostConstruct;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.env.Environment;
+
+@Configuration
+public class SSLConfiguration {
+ @Autowired
+ private Environment env;
+
+ @PostConstruct
+ private void configureSSL() {
+ if (env.getProperty("server.ssl.trust-store") != null) {
+ URL storeResource = SSLConfiguration.class
+ .getResource(env.getProperty("server.ssl.trust-store").replaceAll("classpath:", ""));
+ System.setProperty("javax.net.ssl.trustStore", storeResource.getPath());
+ System.setProperty("javax.net.ssl.trustStorePassword", env.getProperty("server.ssl.trust-store-password"));
+ System.setProperty("javax.net.ssl.trustStoreType", env.getProperty("server.ssl.key-store-type"));
+
+ storeResource = SSLConfiguration.class
+ .getResource(env.getProperty("server.ssl.key-store").replaceAll("classpath:", ""));
+ System.setProperty("javax.net.ssl.keyStore", storeResource.getPath());
+ System.setProperty("javax.net.ssl.keyStorePassword", env.getProperty("server.ssl.key-store-password"));
+ System.setProperty("javax.net.ssl.keyStoreType", env.getProperty("server.ssl.key-store-type"));
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java
index 809904f22..aca2ed01d 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java
@@ -29,6 +29,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import java.util.AbstractMap;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -61,12 +62,12 @@ public class BlueprintParser {
public Set<MicroService> getMicroServices(String blueprintString) {
Set<MicroService> microServices = new HashSet<>();
JsonObject jsonObject = BlueprintParser.convertToJson(blueprintString);
- JsonObject results = jsonObject.get(NODE_TEMPLATES).getAsJsonObject();
+ JsonObject nodeTemplateList = jsonObject.get(NODE_TEMPLATES).getAsJsonObject();
- for (Entry<String, JsonElement> entry : results.entrySet()) {
+ for (Entry<String, JsonElement> entry : nodeTemplateList.entrySet()) {
JsonObject nodeTemplate = entry.getValue().getAsJsonObject();
if (nodeTemplate.get(TYPE).getAsString().contains(DCAE_NODES)) {
- MicroService microService = getNodeRepresentation(entry);
+ MicroService microService = getNodeRepresentation(entry, nodeTemplateList);
microServices.add(microService);
}
}
@@ -89,7 +90,7 @@ public class BlueprintParser {
}
String msName = theBiggestMicroServiceKey.toLowerCase().contains(HOLMES_PREFIX) ? HOLMES : TCA;
return Collections
- .singletonList(new MicroService(msName, "onap.policies.monitoring.cdap.tca.hi.lo.app", "", "", ""));
+ .singletonList(new MicroService(msName, "onap.policies.monitoring.cdap.tca.hi.lo.app", "", ""));
}
String getName(Entry<String, JsonElement> entry) {
@@ -118,8 +119,22 @@ public class BlueprintParser {
return "";
}
- String getModelType(Entry<String, JsonElement> entry) {
+ String findModelTypeInTargetArray(JsonArray jsonArray, JsonObject nodeTemplateList) {
+ for (JsonElement elem : jsonArray) {
+ String modelType = getModelType(
+ new AbstractMap.SimpleEntry<String, JsonElement>(elem.getAsJsonObject().get(TARGET).getAsString(),
+ nodeTemplateList.get(elem.getAsJsonObject().get(TARGET).getAsString()).getAsJsonObject()),
+ nodeTemplateList);
+ if (!modelType.isEmpty()) {
+ return modelType;
+ }
+ }
+ return "";
+ }
+
+ String getModelType(Entry<String, JsonElement> entry, JsonObject nodeTemplateList) {
JsonObject ob = entry.getValue().getAsJsonObject();
+ // Search first in this node template
if (ob.has(PROPERTIES)) {
JsonObject properties = ob.get(PROPERTIES).getAsJsonObject();
if (properties.has(POLICYID)) {
@@ -129,19 +144,18 @@ public class BlueprintParser {
}
}
}
+ // Then it's may be a relationship
+ if (ob.has(RELATIONSHIPS)) {
+ return findModelTypeInTargetArray(ob.get(RELATIONSHIPS).getAsJsonArray(), nodeTemplateList);
+ }
return "";
}
- String getBlueprintName(Entry<String, JsonElement> entry) {
- return entry.getKey();
- }
-
- MicroService getNodeRepresentation(Entry<String, JsonElement> entry) {
+ MicroService getNodeRepresentation(Entry<String, JsonElement> entry, JsonObject nodeTemplateList) {
String name = getName(entry);
String getInputFrom = getInput(entry);
- String modelType = getModelType(entry);
- String blueprintName = getBlueprintName(entry);
- return new MicroService(name, modelType, getInputFrom, "", blueprintName);
+ String modelType = getModelType(entry, nodeTemplateList);
+ return new MicroService(name, modelType, getInputFrom, "");
}
private String getTarget(JsonObject elementObject) {
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java
index ac4daeffb..9bc7a022a 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java
@@ -29,16 +29,14 @@ import java.util.Objects;
public class MicroService {
private final String name;
private final String modelType;
- private final String blueprintName;
private final String inputFrom;
private String mappedNameJpa;
- public MicroService(String name, String modelType, String inputFrom, String mappedNameJpa, String blueprintName) {
+ public MicroService(String name, String modelType, String inputFrom, String mappedNameJpa) {
this.name = name;
this.inputFrom = inputFrom;
this.mappedNameJpa = mappedNameJpa;
- this.modelType = modelType;
- this.blueprintName = blueprintName;
+ this.modelType = modelType;
}
public String getName() {
@@ -53,15 +51,10 @@ public class MicroService {
return inputFrom;
}
- public String getBlueprintName() {
- return blueprintName;
- }
-
@Override
public String toString() {
return "MicroService{" + "name='" + name + '\'' + ", modelType='" + modelType + '\'' + ", inputFrom='"
- + inputFrom + '\'' + ", mappedNameJpa='" + mappedNameJpa + '\'' + ", blueprintName='"
- + blueprintName + '\'' + '}';
+ + inputFrom + '\'' + ", mappedNameJpa='" + mappedNameJpa + '\'' + '}';
}
public String getMappedNameJpa() {
@@ -81,11 +74,12 @@ public class MicroService {
return false;
}
MicroService that = (MicroService) o;
- return name.equals(that.name) && modelType.equals(that.modelType) && inputFrom.equals(that.inputFrom) && mappedNameJpa.equals(that.mappedNameJpa) && blueprintName.equals(that.blueprintName);
+ return name.equals(that.name) && modelType.equals(that.modelType) && inputFrom.equals(that.inputFrom)
+ && mappedNameJpa.equals(that.mappedNameJpa);
}
@Override
public int hashCode() {
- return Objects.hash(name, modelType, inputFrom, mappedNameJpa, blueprintName);
+ return Objects.hash(name, modelType, inputFrom, mappedNameJpa);
}
}
diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
index b2f6109f7..906c3cfa8 100644
--- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
+++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
@@ -206,7 +206,7 @@ public class OperationalPolicy implements Serializable, Policy {
for (Entry<String, JsonElement> guardElem : guardsList.getAsJsonObject().entrySet()) {
JsonObject guard = new JsonObject();
guard.addProperty("policy-id", guardElem.getKey());
- guard.add("contents", guardElem.getValue());
+ guard.add("content", guardElem.getValue());
result.put(guardElem.getKey(), new GsonBuilder().create().toJson(guard));
}
}