aboutsummaryrefslogtreecommitdiffstats
path: root/policy-management/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-11-06 16:38:19 -0500
committerJim Hahn <jrh3@att.com>2019-11-06 16:38:19 -0500
commit445f4bc51c9a635502fcb1cfd68afdb2240af4a7 (patch)
tree46d3a574627e0c4c029fa5eeafbe5d47a0ea12ac /policy-management/src
parent6d7b161d73cb0b6e69c8df84de3b7094eda9119d (diff)
Fix new sonar issues in RestManager
Eliminated duplicate code issues. Unfortunately, introduced new sonar issues with lambda expressions. Issue-ID: POLICY-2203 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: Ib5853fab6135d2177da449ef6261a352ee4f203e
Diffstat (limited to 'policy-management/src')
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java62
1 files changed, 31 insertions, 31 deletions
diff --git a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
index 7140d293..cd3951d7 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
@@ -593,11 +593,10 @@ public class RestManager {
public Response controller(@ApiParam(value = "Policy Controller Name",
required = true) @PathParam("controller") String controllerName) {
- return catchArgStateGenericEx(() -> {
- return Response.status(Response.Status.OK)
- .entity(PolicyControllerConstants.getFactory().get(controllerName)).build();
-
- }, e -> {
+ return catchArgStateGenericEx(
+ () -> Response.status(Response.Status.OK)
+ .entity(PolicyControllerConstants.getFactory().get(controllerName)).build(),
+ e -> {
logger.debug(FETCH_POLICY_BY_NAME_FAILED, this, controllerName, e.getMessage(), e);
return (controllerName);
});
@@ -1401,37 +1400,38 @@ public class RestManager {
@ApiParam(value = "Fact Type", required = true) @PathParam("factType") String factClass,
@ApiParam(value = "JsonPath filter expression", required = true) String rule) {
- return catchArgStateGenericEx(() -> {
- final DroolsController drools = this.getDroolsController(controllerName);
- final ProtocolCoderToolset decoder = EventProtocolCoderConstants.getManager()
- .getDecoders(drools.getGroupId(), drools.getArtifactId(), topic);
+ return catchArgStateGenericEx(() -> decoderFilterRule2(controllerName, topic, factClass, rule), e -> {
+ logger.debug("{}: cannot access decoder filter rules for policy-controller {} "
+ + "topic {} type {} because of {}",
+ this, controllerName, topic, factClass, e.getMessage(), e);
+ return (controllerName + ":" + topic + ":" + factClass);
+ });
+ }
- final CoderFilters filters = decoder.getCoder(factClass);
- if (filters == null) {
- return Response.status(Response.Status.BAD_REQUEST)
- .entity(new Error(controllerName + ":" + topic + ":" + factClass + DOES_NOT_EXIST_MSG)).build();
- }
+ private Object decoderFilterRule2(String controllerName, String topic, String factClass, String rule) {
+ final DroolsController drools = this.getDroolsController(controllerName);
+ final ProtocolCoderToolset decoder = EventProtocolCoderConstants.getManager()
+ .getDecoders(drools.getGroupId(), drools.getArtifactId(), topic);
- final JsonProtocolFilter filter = filters.getFilter();
- if (filter == null) {
- return Response.status(Response.Status.BAD_REQUEST)
- .entity(new Error(controllerName + ":" + topic + ":" + factClass + NO_FILTERS)).build();
- }
+ final CoderFilters filters = decoder.getCoder(factClass);
+ if (filters == null) {
+ return Response.status(Response.Status.BAD_REQUEST)
+ .entity(new Error(controllerName + ":" + topic + ":" + factClass + DOES_NOT_EXIST_MSG)).build();
+ }
- if (rule == null || rule.isEmpty()) {
- return Response.status(Response.Status.BAD_REQUEST).entity(new Error(controllerName + ":" + topic + ":"
- + factClass + " no filter rule provided")).build();
- }
+ final JsonProtocolFilter filter = filters.getFilter();
+ if (filter == null) {
+ return Response.status(Response.Status.BAD_REQUEST)
+ .entity(new Error(controllerName + ":" + topic + ":" + factClass + NO_FILTERS)).build();
+ }
- filter.setRule(rule);
- return filter.getRule();
+ if (rule == null || rule.isEmpty()) {
+ return Response.status(Response.Status.BAD_REQUEST).entity(new Error(controllerName + ":" + topic + ":"
+ + factClass + " no filter rule provided")).build();
+ }
- }, e -> {
- logger.debug("{}: cannot access decoder filter rules for policy-controller {} "
- + "topic {} type {} because of {}",
- this, controllerName, topic, factClass, e.getMessage(), e);
- return (controllerName + ":" + topic + ":" + factClass);
- });
+ filter.setRule(rule);
+ return filter.getRule();
}
/**