aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event/plugins-event-carrier
diff options
context:
space:
mode:
authorJorge Hernandez <jorge.hernandez-herrero@att.com>2020-07-06 18:40:12 +0000
committerGerrit Code Review <gerrit@onap.org>2020-07-06 18:40:12 +0000
commit47fd33606b7a4991fb6c3e1c3416bcc142865ec7 (patch)
treead404fce8d09004210be6e3e7697095ac08d6b1b /plugins/plugins-event/plugins-event-carrier
parentfb826f241cb78b70910f842bbed0bb507b1236ca (diff)
parent042a8f5ec583a7431971847995f1aabd9bc48366 (diff)
Merge "Fix URL checking on REST plugins"
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier')
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java17
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParameters.java32
2 files changed, 17 insertions, 32 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java
index 47e94ff51..d5bca3f5a 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restclient/src/main/java/org/onap/policy/apex/plugins/event/carrier/restclient/RestClientCarrierTechnologyParameters.java
@@ -24,6 +24,8 @@ package org.onap.policy.apex.plugins.event.carrier.restclient;
import lombok.Getter;
import lombok.Setter;
import org.onap.policy.apex.service.parameters.carriertechnology.RestPluginCarrierTechnologyParameters;
+import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationStatus;
// @formatter:off
/**
@@ -59,4 +61,19 @@ public class RestClientCarrierTechnologyParameters extends RestPluginCarrierTech
this.setEventProducerPluginClass(ApexRestClientProducer.class.getName());
this.setEventConsumerPluginClass(ApexRestClientConsumer.class.getName());
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public GroupValidationResult validateUrl(final GroupValidationResult result) {
+ // Check if the URL has been set for event output
+ final String urlNullMessage = "no URL has been set for event sending on " + getLabel();
+ if (getUrl() == null) {
+ result.setResult("url", ValidationStatus.INVALID, urlNullMessage);
+ return result;
+ }
+
+ return super.validateUrl(result);
+ }
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParameters.java
index 9f3a631e1..9e55e22d6 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorCarrierTechnologyParameters.java
@@ -21,12 +21,9 @@
package org.onap.policy.apex.plugins.event.carrier.restrequestor;
-import java.util.regex.Matcher;
import lombok.Getter;
import lombok.Setter;
import org.onap.policy.apex.service.parameters.carriertechnology.RestPluginCarrierTechnologyParameters;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ValidationStatus;
// @formatter:off
/**
@@ -70,33 +67,4 @@ public class RestRequestorCarrierTechnologyParameters extends RestPluginCarrierT
this.setEventProducerPluginClass(ApexRestRequestorProducer.class.getName());
this.setEventConsumerPluginClass(ApexRestRequestorConsumer.class.getName());
}
-
- // @formatter:off
- /**
- * Validate the URL.
- *
- * <p>Checks:
- * http://www.blah.com/{par1/somethingelse (Missing end tag) use {[^\\{}]*$
- * http://www.blah.com/{par1/{some}thingelse (Nested tag) use {[^}]*{
- * http://www.blah.com/{par1}/some}thingelse (Missing start tag1) use }[^{}]*.}
- * http://www.blah.com/par1}/somethingelse (Missing start tag2) use }[^{}]*}
- * http://www.blah.com/{}/somethingelse (Empty tag) use {[\s]*}
- * @param result the result of the validation
- */
- // @formatter:on
- @Override
- public GroupValidationResult validateUrl(final GroupValidationResult result) {
- // URL is only set on Requestor consumers
- if (getUrl() == null) {
- return result;
- }
-
- Matcher matcher = patternErrorKey.matcher(getUrl());
- if (matcher.find()) {
- result.setResult("url", ValidationStatus.INVALID,
- "no proper URL has been set for event sending on REST requestor");
- }
-
- return result;
- }
}