aboutsummaryrefslogtreecommitdiffstats
path: root/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/PersistenceUnitPropertiesProvider.java
diff options
context:
space:
mode:
authoreikrwaq <waqas.ikram@ericsson.com>2018-03-28 15:50:57 +0100
committereikrwaq <waqas.ikram@ericsson.com>2018-03-28 15:53:34 +0100
commitaef13ca06a91db18b82a9e6c8aeee8961aedbf4e (patch)
tree4d686d278bcd3111d80d7f486f1dcb6652b60ce6 /site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/PersistenceUnitPropertiesProvider.java
parentd625f8e805c12301e36392d550b4ca8f8cfa3b5f (diff)
Removed checkstyle warnings
Change-Id: I350bbd414477fe0b480c1bc4e7fa60b1e63842a7 Issue-ID: POLICY-712 Signed-off-by: eikrwaq <waqas.ikram@ericsson.com>
Diffstat (limited to 'site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/PersistenceUnitPropertiesProvider.java')
-rw-r--r--site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/PersistenceUnitPropertiesProvider.java41
1 files changed, 29 insertions, 12 deletions
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. <br>
+ * valid and mandatory property name
+ *
+ * <ul>
+ * <li>javax.persistence.jdbc.driver</li>
+ * <li>javax.persistence.jdbc.url</li>
+ * <li>javax.persistence.jdbc.user</li>
+ * <li>javax.persistence.jdbc.password</li>
+ * </ul>
+ *
+ * @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;
+ }
}