From 4b005ff11a6321d92340228cb10de717880db448 Mon Sep 17 00:00:00 2001 From: "mark.j.leonard" Date: Fri, 15 Feb 2019 18:21:23 +0000 Subject: Various Sonar and Checkstyle issues Issue-ID: AAI-2057 Change-Id: I3b24ce6e5baddb409e3b1d89f411ee934c465284 Signed-off-by: mark.j.leonard --- .../org/onap/aai/auth/AAIMicroServiceAuth.java | 20 +++++++++---- .../org/onap/aai/auth/AAIMicroServiceAuthCore.java | 30 +++++-------------- .../validation/ValidationServiceApplication.java | 10 +++---- .../java/org/onap/aai/validation/Validator.java | 19 +++++++----- .../validation/config/TopicPropertiesConfig.java | 13 +++++---- .../ruledriven/rule/builtin/DataDictionary.java | 34 ++++++++++------------ src/main/resources/application.properties | 17 ++++++----- 7 files changed, 71 insertions(+), 72 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/onap/aai/auth/AAIMicroServiceAuth.java b/src/main/java/org/onap/aai/auth/AAIMicroServiceAuth.java index c565c9c..8181b43 100644 --- a/src/main/java/org/onap/aai/auth/AAIMicroServiceAuth.java +++ b/src/main/java/org/onap/aai/auth/AAIMicroServiceAuth.java @@ -1,19 +1,22 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright ?? 2018-2019 AT&T Intellectual Property. All rights reserved. + * Copyright ?? 2018-2019 European Software Marketing Ltd. + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END===================================================== + * ============LICENSE_END========================================================= */ package org.onap.aai.auth; @@ -32,6 +35,11 @@ public class AAIMicroServiceAuth { private ValidationServiceAuthConfig validationServiceAuthConfig; private AAIMicroServiceAuthCore authCore; + /** + * @param validationServiceAuthConfig + * @throws AAIAuthException + * if the policy file cannot be loaded + */ @Inject public AAIMicroServiceAuth(final ValidationServiceAuthConfig validationServiceAuthConfig) throws AAIAuthException { this.validationServiceAuthConfig = validationServiceAuthConfig; diff --git a/src/main/java/org/onap/aai/auth/AAIMicroServiceAuthCore.java b/src/main/java/org/onap/aai/auth/AAIMicroServiceAuthCore.java index 9bd8e2b..681d0ea 100644 --- a/src/main/java/org/onap/aai/auth/AAIMicroServiceAuthCore.java +++ b/src/main/java/org/onap/aai/auth/AAIMicroServiceAuthCore.java @@ -9,7 +9,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -49,9 +49,8 @@ public class AAIMicroServiceAuthCore { private Path appConfigAuthDir; - private static boolean usersInitialized = false; - private static HashMap users; - private static boolean timerSet = false; + private boolean usersInitialized = false; + private HashMap users; private String policyAuthFileName; public enum HttpMethods { @@ -64,8 +63,7 @@ public class AAIMicroServiceAuthCore { /** * @param authPolicyFile - * @throws AAIAuthException - * if the policy file cannot be loaded + * @throws AAIAuthException if the policy file cannot be loaded */ public void init(String authPolicyFile) throws AAIAuthException { try { @@ -95,13 +93,8 @@ public class AAIMicroServiceAuthCore { } }; - if (!timerSet) { - timerSet = true; - Timer timer = new Timer(); - long period = TimeUnit.SECONDS.toMillis(1); - timer.schedule(task, new Date(), period); - applicationLogger.debug("Config Watcher Interval = " + period); - } + new Timer().schedule(task, new Date(), TimeUnit.SECONDS.toMillis(1)); + applicationLogger.debug("Config Watcher Interval = " + TimeUnit.SECONDS.toMillis(1)); } public String getConfigFile(String authPolicyFile) throws IOException { @@ -167,7 +160,7 @@ public class AAIMicroServiceAuthCore { * @param roleName * @param functionNode */ - private static void addFunctionToRole(AAIAuthRole role, String roleName, JsonNode functionNode) { + private void addFunctionToRole(AAIAuthRole role, String roleName, JsonNode functionNode) { String functionName = functionNode.path("name").asText(); JsonNode methodsNode = functionNode.path("methods"); @@ -207,7 +200,6 @@ public class AAIMicroServiceAuthCore { } return false; } - } public static class AAIAuthRole { @@ -221,12 +213,6 @@ public class AAIMicroServiceAuthCore { this.allowedFunctions.add(func); } - public void delAllowedFunction(String delFunc) { - if (this.allowedFunctions.contains(delFunc)) { - this.allowedFunctions.remove(delFunc); - } - } - public boolean hasAllowedFunction(String functionName) { return allowedFunctions.contains(functionName); } @@ -251,7 +237,7 @@ public class AAIMicroServiceAuthCore { } } - private static void logAuthenticationResult(String username, String authFunction, String result) { + private void logAuthenticationResult(String username, String authFunction, String result) { applicationLogger.debug(result + ": " + username + " on function " + authFunction); } diff --git a/src/main/java/org/onap/aai/validation/ValidationServiceApplication.java b/src/main/java/org/onap/aai/validation/ValidationServiceApplication.java index b3220cb..5db497d 100644 --- a/src/main/java/org/onap/aai/validation/ValidationServiceApplication.java +++ b/src/main/java/org/onap/aai/validation/ValidationServiceApplication.java @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ - * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2019 European Software Marketing Ltd. + * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2018-2019 European Software Marketing Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,7 +54,7 @@ public class ValidationServiceApplication extends SpringBootServletInitializer { JAVA_TRUST_STORE_PASSWORD("javax.net.ssl.trustStorePassword") // JVM ; - final private String propertyName; + private final String propertyName; SystemProperty() { propertyName = this.toString(); @@ -73,7 +73,7 @@ public class ValidationServiceApplication extends SpringBootServletInitializer { } public void set(String propertyValue) { - System.setProperty(propertyName, propertyValue); + System.setProperty(propertyName, propertyValue); } } @@ -84,7 +84,7 @@ public class ValidationServiceApplication extends SpringBootServletInitializer { SCHEMA_SERVICE_TRUST_STORE_PASSWORD("schema.service.ssl.trust-store-password") // aai-schema-ingest ; - final private String propertyName; + private final String propertyName; ApplicationProperty(String property) { propertyName = property; diff --git a/src/main/java/org/onap/aai/validation/Validator.java b/src/main/java/org/onap/aai/validation/Validator.java index c3ecc2a..be2b995 100644 --- a/src/main/java/org/onap/aai/validation/Validator.java +++ b/src/main/java/org/onap/aai/validation/Validator.java @@ -1,19 +1,22 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2018-2019 European Software Marketing Ltd. + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END===================================================== + * ============LICENSE_END========================================================= */ package org.onap.aai.validation; @@ -22,14 +25,14 @@ import org.onap.aai.validation.exception.ValidationServiceException; import org.onap.aai.validation.result.ValidationResult; /** - * Validator (e.g. model-driven or rule-based) + * Validator (e.g. model-driven or rule-based). * */ public interface Validator { /** * This method should be called (once) before validate() to ensure that all configuration is correctly loaded. - * + * * @throws ValidationServiceException */ public void initialise() throws ValidationServiceException; diff --git a/src/main/java/org/onap/aai/validation/config/TopicPropertiesConfig.java b/src/main/java/org/onap/aai/validation/config/TopicPropertiesConfig.java index 4a2dc16..53d6cc7 100644 --- a/src/main/java/org/onap/aai/validation/config/TopicPropertiesConfig.java +++ b/src/main/java/org/onap/aai/validation/config/TopicPropertiesConfig.java @@ -1,7 +1,10 @@ /** - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2018-2019 European Software Marketing Ltd. + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,7 +16,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END===================================================== + * ============LICENSE_END========================================================= */ package org.onap.aai.validation.config; @@ -40,7 +43,7 @@ public class TopicPropertiesConfig { @Value("${topics.properties.location}") private String topicsPropertiesLocation; - private static final String[] propertyFilePatterns = { "file:./%s/*.properties", "classpath:/%s/*.properties" }; + private static final String[] propertyFilePatterns = {"file:./%s/*.properties", "classpath:/%s/*.properties"}; @Bean(name = "topicProperties") public Properties topicProperties() throws IOException { diff --git a/src/main/java/org/onap/aai/validation/ruledriven/rule/builtin/DataDictionary.java b/src/main/java/org/onap/aai/validation/ruledriven/rule/builtin/DataDictionary.java index 9eaef94..dd6380e 100644 --- a/src/main/java/org/onap/aai/validation/ruledriven/rule/builtin/DataDictionary.java +++ b/src/main/java/org/onap/aai/validation/ruledriven/rule/builtin/DataDictionary.java @@ -1,32 +1,34 @@ -/* - * ============LICENSE_START=================================================== +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. * Copyright (c) 2018-2019 European Software Marketing Ltd. - * ============================================================================ + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ============LICENSE_END===================================================== + * ============LICENSE_END========================================================= */ + package org.onap.aai.validation.ruledriven.rule.builtin; +import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import java.text.MessageFormat; -import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.Collections; import java.util.Properties; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedHashMap; @@ -46,9 +48,7 @@ public class DataDictionary { private static org.onap.aai.restclient.client.RestClient restClient; public enum COMMON_MODEL_ELEMENT_TYPE { - INSTANCE, - ATTRIBUTE, - UNSUPPORTED; + INSTANCE, ATTRIBUTE, UNSUPPORTED; } private DataDictionary() { @@ -87,9 +87,9 @@ public class DataDictionary { * /commonModelElements/attribute~nfRole~1.0/validateInstance * * @param commonModelElementType - * "instance" or "attribute" + * "instance" or "attribute" * @param commonModelElementName - * name of common model element + * name of common model element * @param attributeName * @param attributeValue * @return @@ -162,11 +162,7 @@ public class DataDictionary { public Request(COMMON_MODEL_ELEMENT_TYPE cmeType, String attributeName, String attributeValue) { switch (cmeType) { case INSTANCE: - Map map = new HashMap<>(); - map.put(attributeName, attributeValue); - List list = new ArrayList<>(); - list.add(map); - instance = list; + instance = Collections.singletonList(ImmutableMap.of(attributeName, attributeValue)); break; case ATTRIBUTE: instance = attributeValue; diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 38b3d34..2c93762 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,18 +1,21 @@ -# ============LICENSE_START=================================================== -# Copyright (c) 2018-2019 Amdocs -# ============================================================================ +# ============LICENSE_START======================================================= +# org.onap.aai +# ================================================================================ +# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. +# Copyright (c) 2018-2019 European Software Marketing Ltd. +# ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# +# +# http://www.apache.org/licenses/LICENSE-2.0 +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -# ============LICENSE_END===================================================== +# ============LICENSE_END========================================================= # Note that the start.sh script sets the following System Properties # We provide default values here for testing purposes -- cgit 1.2.3-korg