From aed22f51f05a31d3189d8882d4f9e6c82470598b Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Fri, 1 Dec 2017 05:02:29 +0530 Subject: Optimze invalid params check Issue-ID: CLI-83 Change-Id: I163251d99ff1cfaf3cbc20cf397cbab0b5d9a264 Signed-off-by: Kanagaraj Manickam k00365106 --- .../main/java/org/onap/cli/fw/utils/OnapCommandUtils.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java index 77d50171..4a340dab 100644 --- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java +++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java @@ -218,7 +218,7 @@ public class OnapCommandUtils { private static InputStream loadSchemaFromFile(String schemaLocation) throws OnapCommandInvalidSchema { File schemaFile = new File(schemaLocation); try { - FileInputStream inputFileStream = new FileInputStream(schemaFile); + FileInputStream inputFileStream = new FileInputStream(schemaFile); // NOSONAR if (!schemaFile.isFile()) { throw new OnapCommandInvalidSchema(schemaFile.getName(), SCHEMA_FILE_NOT_EXIST); } @@ -294,15 +294,14 @@ public class OnapCommandUtils { } } - List invalidExclude = excludeAuthParams.stream().filter(includeParams::contains) + List invalidParams = excludeAuthParams.stream().filter(includeParams::contains) .collect(Collectors.toList()); - List invalidInclude = includeAuthParams.stream().filter(excludeParams::contains) - .filter(p->!includeParams.contains(p)).collect(Collectors.toList()); + invalidParams.addAll(includeAuthParams.stream().filter(excludeParams::contains) + .filter(p->!includeParams.contains(p)).collect(Collectors.toList())); - if (!invalidExclude.isEmpty() || !invalidInclude.isEmpty()) { - throw new OnapCommandInvalidDefaultParameter(Stream.concat(invalidExclude.stream(), invalidInclude.stream()) - .collect(Collectors.toList())); + if (!invalidParams.isEmpty()) { + throw new OnapCommandInvalidDefaultParameter(invalidParams); } -- cgit 1.2.3-korg