Automatic verification when call fails
This commit is contained in:
parent
fd18efe4b4
commit
5337728368
@ -18,19 +18,32 @@ public class userVerify
|
||||
String varFileName;
|
||||
|
||||
Scanner myObj = new Scanner(System.in); // Create a Scanner object
|
||||
while (true)
|
||||
|
||||
if (args.length > 0)
|
||||
{
|
||||
System.out.print(varPrompt);
|
||||
varFileName = myObj.nextLine().trim();
|
||||
File thisFile = new File(varFileName);
|
||||
boolean isValidFile = fileProcessor.validFile(varFileName);
|
||||
if ( thisFile.exists() && isValidFile )
|
||||
{
|
||||
break;
|
||||
}
|
||||
varPrompt = "\nThe CSV file does not exist or cannot be read!\nPlease enter the name of the CSV file to validate : ";
|
||||
System.out.println("Running verification [file] : " + args[0]);
|
||||
System.out.println("Running verification [invalidate line] : " + args[1]);
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
if (args.length > 0)
|
||||
{
|
||||
varFileName = args[0];
|
||||
System.out.println("Please enter the name of the CSV file to validate : " + varFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (true) {
|
||||
System.out.print(varPrompt);
|
||||
varFileName = myObj.nextLine().trim();
|
||||
File thisFile = new File(varFileName);
|
||||
boolean isValidFile = fileProcessor.validFile(varFileName);
|
||||
if (thisFile.exists() && isValidFile) {
|
||||
break;
|
||||
}
|
||||
varPrompt = "\nThe CSV file does not exist or cannot be read!\nPlease enter the name of the CSV file to validate : ";
|
||||
}
|
||||
}
|
||||
boolean varUserBlockEmpty = false;
|
||||
|
||||
HashMap<String, Boolean> valueMap = new HashMap();
|
||||
@ -38,19 +51,27 @@ public class userVerify
|
||||
valueMap.put("N", false);
|
||||
valueMap.put("", true);
|
||||
|
||||
while (true)
|
||||
String varSanitized = new String();
|
||||
if (args.length > 0)
|
||||
{
|
||||
System.out.print("Invalidate a line if there are empty column values? (Y/n) : ");
|
||||
String varAnswer = myObj.nextLine();
|
||||
String varSanitized = varAnswer.toUpperCase().trim();
|
||||
String varAnswer = args[1];
|
||||
varSanitized = varAnswer.toUpperCase().trim();
|
||||
System.out.println("Invalidate a line if there are empty column values? (Y/n) : " + varAnswer);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (true) {
|
||||
System.out.print("Invalidate a line if there are empty column values? (Y/n) : ");
|
||||
String varAnswer = myObj.nextLine();
|
||||
varSanitized = varAnswer.toUpperCase().trim();
|
||||
|
||||
if (varSanitized.equals("Y") || varSanitized.equals("N") || varSanitized.isEmpty())
|
||||
{
|
||||
varUserBlockEmpty = valueMap.get(varSanitized);
|
||||
break;
|
||||
if (varSanitized.equals("Y") || varSanitized.equals("N") || varSanitized.isEmpty())
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
varUserBlockEmpty = valueMap.get(varSanitized);
|
||||
System.out.println();
|
||||
debugProcessor.writer(true, "CSV filename to validate : " + varFileName);
|
||||
debugProcessor.writer(true, "CSV invalidate on empty : " + varUserBlockEmpty);
|
||||
@ -74,7 +95,7 @@ public class userVerify
|
||||
debugProcessor.writer(true, "");
|
||||
}
|
||||
boolean validFile = (!thisCSV.isEmpty());
|
||||
debugProcessor.writer(true, "CSV file records : " + varIter);
|
||||
debugProcessor.writer(true, "CSV record count : " + varIter);
|
||||
debugProcessor.writer(true, "CSV file is valid : " + validFile);
|
||||
System.out.println();
|
||||
}
|
||||
@ -103,7 +124,7 @@ public class userVerify
|
||||
varHeader = fileProcessor.readFirstLine(thisFile);
|
||||
if (varHeader.length() == 0)
|
||||
{
|
||||
System.out.println("CSV failure error : Header line not found!");
|
||||
System.out.println("CSV failure error : Header line not found!");
|
||||
return finalArray;
|
||||
}
|
||||
|
||||
|
@ -232,12 +232,24 @@ public class webService {
|
||||
|
||||
boolean validFile = (!thisCSV.isEmpty());
|
||||
debugProcessor.writer(varDebug, "");
|
||||
debugProcessor.writer(true, "CSV file is valid : " + validFile);
|
||||
debugProcessor.writer(true, "CSV records to process : " + thisCSV.size());
|
||||
debugProcessor.writer(true, "CSV record count : " + thisCSV.size());
|
||||
debugProcessor.writer(true, "CSV file is valid : " + validFile);
|
||||
|
||||
if (!validFile)
|
||||
{
|
||||
debugProcessor.writer(true, varRoleFile + " => verification failed : please verify the file with com.belkast.soap.userVerify!");
|
||||
System.out.println();
|
||||
String response = credentialsProcessor.getCredential("To verify the " + varRoleFile + " file, please type yes", "^$|^.+$", false);
|
||||
HashMap<Boolean, String> valueMap = new HashMap();
|
||||
valueMap.put(true, "Y");
|
||||
valueMap.put(false, "N");
|
||||
|
||||
if (response.equals("yes"))
|
||||
{
|
||||
String[] arguments = new String[] {varRoleFile,valueMap.get(!varEmptyColumns)};
|
||||
userVerify.main(arguments);
|
||||
}
|
||||
System.out.println();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
int varCount = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user