From aef13ca06a91db18b82a9e6c8aeee8961aedbf4e Mon Sep 17 00:00:00 2001 From: eikrwaq Date: Wed, 28 Mar 2018 15:50:57 +0100 Subject: Removed checkstyle warnings Change-Id: I350bbd414477fe0b480c1bc4e7fa60b1e63842a7 Issue-ID: POLICY-712 Signed-off-by: eikrwaq --- .../utils/PersistenceUnitPropertiesProvider.java | 41 +++++++++++++++------- 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/PersistenceUnitPropertiesProvider.java') diff --git a/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/PersistenceUnitPropertiesProvider.java b/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/PersistenceUnitPropertiesProvider.java index 5d7abe7d..ffc48694 100644 --- a/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/PersistenceUnitPropertiesProvider.java +++ b/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/PersistenceUnitPropertiesProvider.java @@ -26,12 +26,14 @@ import static org.onap.policy.common.sitemanager.utils.Constants.JDBC_URL_PROPER import static org.onap.policy.common.sitemanager.utils.Constants.JDBC_USER_PROPERTY_NAME; import static org.onap.policy.common.sitemanager.utils.ErrorMessages.SITE_MANAGER_PROPERY_FILE_MISSING_PROPERTY; import static org.onap.policy.common.sitemanager.utils.ErrorMessages.SITE_MANAGER_PROPERY_FILE_NOT_DEFINED_MESSAGE; + import java.io.BufferedReader; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Properties; + import org.onap.policy.common.sitemanager.exception.MissingPropertyException; import org.onap.policy.common.sitemanager.exception.PropertyFileProcessingException; @@ -41,6 +43,21 @@ public class PersistenceUnitPropertiesProvider { super(); } + /** + * Parser and validate properties in give property file.
+ * valid and mandatory property name + * + * + * + * @param propertiesFileName the properties filename + * @param printable {@link Printable} + * @return {@link Properties} + */ public static Properties getProperties(final String propertiesFileName, final Printable printable) { if (propertiesFileName == null) { printable.println(SITE_MANAGER_PROPERY_FILE_NOT_DEFINED_MESSAGE); @@ -61,18 +78,6 @@ public class PersistenceUnitPropertiesProvider { return properties; } - private static boolean isNotValid(final Properties properties, final String... values) { - if (values == null || values.length == 0) { - return true; - } - for (final String val : values) { - if (properties.get(val) == null) { - return true; - } - } - return false; - } - private static Properties getProperties(final Path filePath, final Printable printable) { if (!filePath.toFile().exists()) { printable.println(SITE_MANAGER_PROPERY_FILE_NOT_DEFINED_MESSAGE); @@ -91,4 +96,16 @@ public class PersistenceUnitPropertiesProvider { throw new PropertyFileProcessingException("Exception loading properties: ", exception); } } + + private static boolean isNotValid(final Properties properties, final String... values) { + if (values == null || values.length == 0) { + return true; + } + for (final String val : values) { + if (properties.get(val) == null) { + return true; + } + } + return false; + } } -- cgit 1.2.3-korg