summaryrefslogtreecommitdiffstats
path: root/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils
diff options
context:
space:
mode:
Diffstat (limited to 'site-manager/src/main/java/org/onap/policy/common/sitemanager/utils')
-rw-r--r--site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/CommandLineHelper.java6
-rw-r--r--site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/ErrorMessages.java2
-rw-r--r--site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/ExtraCommandLineArgument.java6
-rw-r--r--site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/JmxOpProcessor.java5
-rw-r--r--site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/PersistenceUnitPropertiesProvider.java41
5 files changed, 46 insertions, 14 deletions
diff --git a/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/CommandLineHelper.java b/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/CommandLineHelper.java
index 58db7bc8..cfc68785 100644
--- a/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/CommandLineHelper.java
+++ b/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/CommandLineHelper.java
@@ -21,6 +21,7 @@
package org.onap.policy.common.sitemanager.utils;
import java.util.List;
+
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
@@ -76,6 +77,11 @@ public class CommandLineHelper {
}
}
+ /**
+ * validate given command line arguments.
+ *
+ * @return true if valid
+ */
public boolean isValid() {
// fetch options, and remaining arguments
final String sOption = commandLine.getOptionValue(SITE_ARGUMENT_NAME);
diff --git a/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/ErrorMessages.java b/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/ErrorMessages.java
index 81145462..54695c65 100644
--- a/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/ErrorMessages.java
+++ b/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/ErrorMessages.java
@@ -49,6 +49,8 @@ public class ErrorMessages {
public static final String NO_COMMAND_SPECIFIED = "No command specified";
+ public static final String NO_MATCHING_ENTRIES = ": No matching entries";
+
public static final String HELP_STRING = "Usage:\n" + " siteManager show [ -s <site> | -r <resourceName> ] :\n"
+ " display node information\n" + " siteManager setAdminState { -s <site> | -r <resourceName> }"
+ " <new-state> :\n" + " update admin state on selected nodes\n"
diff --git a/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/ExtraCommandLineArgument.java b/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/ExtraCommandLineArgument.java
index a28deece..55dfea7e 100644
--- a/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/ExtraCommandLineArgument.java
+++ b/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/ExtraCommandLineArgument.java
@@ -119,6 +119,12 @@ public enum ExtraCommandLineArgument {
return value;
}
+ /**
+ * Get {@link ExtraCommandLineArgument} for given command line argument.
+ *
+ * @param value the input command line argument
+ * @return {@link ExtraCommandLineArgument}
+ */
public static ExtraCommandLineArgument getExtraCommandLineArgument(final String value) {
for (final ExtraCommandLineArgument argument : ExtraCommandLineArgument.values()) {
if (argument.getValue().equals(value)) {
diff --git a/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/JmxOpProcessor.java b/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/JmxOpProcessor.java
index 2e354d3b..33a2238a 100644
--- a/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/JmxOpProcessor.java
+++ b/site-manager/src/main/java/org/onap/policy/common/sitemanager/utils/JmxOpProcessor.java
@@ -38,10 +38,11 @@ public class JmxOpProcessor {
}
/**
- * Process a 'lock' or 'unlock' operation on a single 'ResourceRegistrationEntity'
+ * Process a 'lock' or 'unlock' operation on a single {@link ResourceRegistrationEntity}.
*
* @param action this is the string "lock" or "unlock"
- * @param resourceRegistrationEntity this is the ResourceRegistrationEntity to lock or unlock
+ * @param resourceRegistrationEntity this is the {@link ResourceRegistrationEntity} to lock or
+ * unlock
*/
public static void jmxOp(final String action, final ResourceRegistrationEntity resourceRegistrationEntity,
final Printable printable) {
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;
+ }
}