Question
Based on the code below implement the following changes in JAVA: 1.Enhance SwissArmyKnife so that it implements the feature: -JSONValidateIndex This feature should read the
Based on the code below implement the following changes in JAVA:
1.Enhance SwissArmyKnife so that it implements the feature:
-JSONValidateIndex
This feature should read the "url-list.json" index file at the following URL [https://thunderbird-data.azurewebsites.net/url-list.json], parse the index file for additional personal information URLs, make an HTTP request to get each of the files identified in the "url-list.json" file, and validate each personal information JSON file referenced in the index file.
Validation should include:
- The "firstName", "lastName", and "preferredName" fields must exist and have a length of at least 2 characters
- The phoneNumber field is optional
The feature should report an error to the command prompt whenever it finds and error in a URL or JSON file. The error message should include a meaningful message along with the name and email address associated with the JSON file if possible.
2.-JSONValidateIndexThreaded
This feature should enhance the "-JSONValidateIndex" feature above so that it utilizes multiple threads either by extending Thread or implementing Runnable. You should be able to directly compare the threaded and non-threaded versions of this feature by comparing the timing reported for the application.
sak.java
public class sak {
public static void main(String[] args) { System.out.println("Welcome to SwissArmyKnife"); // Argument sanity checking if ((args.length < 1) || (args[0].equalsIgnoreCase("-Help"))) { // If no argument specified, or Help argument specified, refer the user to help if (args.length < 1) { System.out.println("You must supply at least one argument to utilize this application. Please use the \"-Help\" argument for" + " more information. For your convenience, the help section will be printed below:"); } Help.printHelp(); System.exit(0); } else if (((args[0].equalsIgnoreCase("-HttpRequest")) || (args[0].equalsIgnoreCase("-HttpRequestIndex"))) && (args.length != 2)) { // User specified valid function argument, but did not supply a URL System.out.format("The %s argument requires a valid URL as the second argument. Please use the -Help argument for" + " more information", args[0]); System.exit(0); } else if ((args.length > 2) || (args.length < 2)) { // User did not specify a valid function argument System.out.println("The argument specified is not a valid function of this application. Please use the -Help argument for" + "more information"); System.exit(0); }
String url = args[1]; if (args[0].equalsIgnoreCase("-HttpRequest")) { // HttpRequest handling method HttpRequest request = new HttpRequest();
System.out.println("-Executing HttpRequest"); if (request.readURL(url)) { System.out.println(request); } else { System.out.format("Unable to access requested URL: ", url); } } else if (args[0].equalsIgnoreCase("-HttpRequestIndex")) { // HttpRequestIndex handling method HttpRequestIndex requestIndex = new HttpRequestIndex(); System.out.println("-Executing HttpRequestIndex");
if (requestIndex.readURL(url)) { // System.out.println(requestIndex); } else { System.out.format("Unable to access requested URL: ", url); } } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started