summaryrefslogtreecommitdiffstats
path: root/catalog-model
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-model')
-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
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCacheTest.java4
3 files changed, 38 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;
+ }
+ }
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCacheTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCacheTest.java
index 481894c0c3..7186d2a8bf 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCacheTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCacheTest.java
@@ -39,6 +39,7 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import org.springframework.context.ApplicationEventPublisher;
public class ApplicationDataTypeCacheTest extends ModelConfDependentTest{
@@ -48,6 +49,9 @@ public class ApplicationDataTypeCacheTest extends ModelConfDependentTest{
@Mock
PropertyOperation propertyOperation;
+ @Mock
+ ApplicationEventPublisher applicationEventPublisher;
+
@Before
public void setUpMocks() throws Exception {
MockitoAnnotations.initMocks(this);