summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-11-08 12:54:46 +0000
committerGerrit Code Review <gerrit@onap.org>2019-11-08 12:54:46 +0000
commit0588d03bb8e9ea5faebf65d4af8e4bff735a96ae (patch)
treef39fe1bcd6a111f489ed9f9083c55bf371bec274
parenta42adf807f21116b7a952233d448d18afa7980b9 (diff)
parent445f4bc51c9a635502fcb1cfd68afdb2240af4a7 (diff)
Merge "Fix new sonar issues in RestManager"
-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();
}
/**