summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-22 21:07:43 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-22 21:15:22 +0100
commit6973ec9109fd2651e2284663b6c8039bd830a677 (patch)
treef1f02ef9e5400805e6c2179dc539ad15c3ce5334 /plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java
parenta02548ec2e98a8a13cd76ecc83379b13cd26030b (diff)
Fix sonar problems in Apex
Fixed some easy to resolve Sonar issues. Issue-ID: POLICY-1034 Change-Id: Ia8e4606bd4307daca499b4a74c96135211e572fd Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java')
-rw-r--r--plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java40
1 files changed, 38 insertions, 2 deletions
diff --git a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java
index 4bf10e4ae..f3afdde32 100644
--- a/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java
+++ b/plugins/plugins-event/plugins-event-protocol/plugins-event-protocol-yaml/src/main/java/org/onap/policy/apex/plugins/event/protocol/yaml/Apex2YamlEventConverter.java
@@ -267,6 +267,23 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
version = eventDefinition.getKey().getVersion();
}
+ String namespace = getEventHeaderNamespace(yamlMap, name, eventDefinition);
+
+ String source = getEventHeaderSource(yamlMap, eventDefinition);
+
+ String target = getHeaderTarget(yamlMap, eventDefinition);
+
+ return new ApexEvent(name, version, namespace, source, target);
+ }
+
+ /**
+ * Get the event header name space.
+ *
+ * @param yamlMap the YAML map to read from
+ * @param eventDefinition the event definition
+ * @return the event header name space
+ */
+ private String getEventHeaderNamespace(final Map<?, ?> yamlMap, String name, final AxEvent eventDefinition) {
// Check the name space is OK if it is defined, if not, use the name space from the model
String namespace = getYamlStringField(yamlMap, ApexEvent.NAMESPACE_HEADER_FIELD, yamlPars.getNameSpaceAlias(),
ApexEvent.NAMESPACE_REGEXP, false);
@@ -279,22 +296,41 @@ public class Apex2YamlEventConverter implements ApexEventProtocolConverter {
} else {
namespace = eventDefinition.getNameSpace();
}
+ return namespace;
+ }
+ /**
+ * Get the event header source.
+ *
+ * @param yamlMap the YAML map to read from
+ * @param eventDefinition the event definition
+ * @return the event header source
+ */
+ private String getEventHeaderSource(final Map<?, ?> yamlMap, final AxEvent eventDefinition) {
// For source, use the defined source only if the source is not found on the incoming event
String source = getYamlStringField(yamlMap, ApexEvent.SOURCE_HEADER_FIELD, yamlPars.getSourceAlias(),
ApexEvent.SOURCE_REGEXP, false);
if (source == null) {
source = eventDefinition.getSource();
}
+ return source;
+ }
+ /**
+ * Get the event header target.
+ *
+ * @param yamlMap the YAML map to read from
+ * @param eventDefinition the event definition
+ * @return the event header target
+ */
+ private String getHeaderTarget(final Map<?, ?> yamlMap, final AxEvent eventDefinition) {
// For target, use the defined source only if the source is not found on the incoming event
String target = getYamlStringField(yamlMap, ApexEvent.TARGET_HEADER_FIELD, yamlPars.getTargetAlias(),
ApexEvent.TARGET_REGEXP, false);
if (target == null) {
target = eventDefinition.getTarget();
}
-
- return new ApexEvent(name, version, namespace, source, target);
+ return target;
}
/**