aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main
diff options
context:
space:
mode:
authorDmitry Puzikov <dmitry.puzikov@tieto.com>2020-01-28 18:04:40 +0100
committerDmitry Puzikov <d.puzikov2@partner.samsung.com>2020-02-25 10:11:49 +0100
commitb4aaa6d004c4643e593fc789bbe9776a6226315d (patch)
tree9d0f93bb56dce0c7bea2f40efa838e00d08a24b6 /catalog-model/src/main
parent0c274e9356fc77c53340828b0ec18869dad71631 (diff)
Policies import when import VSP
Polices import implemented. Error type added for invalid policies. Import tests added. Fix test failures. Got rid of Either in the new code. Change-Id: I3e91cc6d24433c2b3862f407348e71e1e67c3b4e Issue-ID: SDC-2728 Signed-off-by: Dmitry Puzikov <d.puzikov2@partner.samsung.com>
Diffstat (limited to 'catalog-model/src/main')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ParsedToscaYamlInfo.java39
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java27
2 files changed, 34 insertions, 32 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ParsedToscaYamlInfo.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ParsedToscaYamlInfo.java
index f975806c88..a6f4165aeb 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ParsedToscaYamlInfo.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ParsedToscaYamlInfo.java
@@ -21,41 +21,16 @@
package org.openecomp.sdc.be.model;
import java.util.Map;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+@ToString
+@Getter
+@Setter
public class ParsedToscaYamlInfo {
Map<String, InputDefinition> inputs;
-
Map<String, UploadComponentInstanceInfo> instances;
-
Map<String, GroupDefinition> groups;
-
- public Map<String, UploadComponentInstanceInfo> getInstances() {
- return instances;
- }
-
- public void setInstances(Map<String, UploadComponentInstanceInfo> instances) {
- this.instances = instances;
- }
-
- public Map<String, GroupDefinition> getGroups() {
- return groups;
- }
-
- public void setGroups(Map<String, GroupDefinition> groups) {
- this.groups = groups;
- }
-
- public Map<String, InputDefinition> getInputs() {
- return inputs;
- }
-
- public void setInputs(Map<String, InputDefinition> inputs) {
- this.inputs = inputs;
- }
-
- @Override
- public String toString() {
- return "ParsedToscaYamlInfo [inputs=" + inputs + ", instances=" + instances + ", groups=" + groups + "]";
- }
-
+ Map<String, PolicyDefinition> policies;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java
index fb49762736..25a305ed9b 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.be.model.cache;
import fj.data.Either;
+import lombok.Getter;
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
@@ -34,6 +35,9 @@ import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
import org.openecomp.sdc.be.resources.data.DataTypeData;
import org.openecomp.sdc.common.log.wrappers.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationEvent;
+import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@@ -74,6 +78,9 @@ public class ApplicationDataTypeCache implements ApplicationCache<DataTypeDefini
@Resource
private PropertyOperation propertyOperation;
+ @Autowired
+ private ApplicationEventPublisher applicationEventPublisher;
+
@PostConstruct
public void init() {
@@ -313,6 +320,8 @@ public class ApplicationDataTypeCache implements ApplicationCache<DataTypeDefini
w.lock();
data = allDataTypes.left().value();
+ // send notification on data types change
+ onDataChangeEventEmit(data);
BeEcompErrorManager.getInstance().logInternalFlowError("ReplaceDataTypesCache",
"Succeed to replace the data types cache", ErrorSeverity.INFO);
@@ -325,4 +334,22 @@ public class ApplicationDataTypeCache implements ApplicationCache<DataTypeDefini
}
+ private void onDataChangeEventEmit(Map<String, DataTypeDefinition> newData) {
+ log.trace("Cache data has changed, sending event to all listening for this change.");
+ DataTypesCacheChangedEvent dataTypesCacheChangedEvent = new DataTypesCacheChangedEvent(this, newData);
+ applicationEventPublisher.publishEvent(dataTypesCacheChangedEvent);
+ }
+
+ /**
+ * Custom event to notify all interested in cached data changes
+ */
+ public static class DataTypesCacheChangedEvent extends ApplicationEvent {
+ @Getter
+ private Map<String, DataTypeDefinition> newData;
+
+ public DataTypesCacheChangedEvent(Object source, Map<String, DataTypeDefinition> newData) {
+ super(source);
+ this.newData = newData;
+ }
+ }
}