Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

  1. The "firstName", "lastName", and "preferredName" fields must exist and have a length of at least 2 characters
  2. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 18th International Conference Dasfaa 2013 Wuhan China April 22 25 2013 Proceedings Part 2 Lncs 7826

Authors: Weiyi Meng ,Ling Feng ,Stephane Bressan ,Werner Winiwarter ,Wei Song

2013th Edition

3642374492, 978-3642374494

More Books

Students also viewed these Databases questions

Question

c. What were you expected to do when you grew up?

Answered: 1 week ago

Question

4. Describe how cultural values influence communication.

Answered: 1 week ago

Question

3. Identify and describe nine cultural value orientations.

Answered: 1 week ago